This commit is contained in:
Julian Freeman
2026-03-14 16:18:11 -04:00
commit 375b6fdb11
46 changed files with 7988 additions and 0 deletions

47
src/store/software.ts Normal file
View File

@@ -0,0 +1,47 @@
import { defineStore } from 'pinia'
import { invoke } from '@tauri-apps/api/core'
import { listen } from '@tauri-apps/api/event'
export const useSoftwareStore = defineStore('software', {
state: () => ({
essentials: [] as any[],
updates: [] as any[],
allSoftware: [] as any[],
loading: false
}),
actions: {
async fetchEssentials() {
this.essentials = await invoke('get_essentials')
},
async fetchUpdates() {
this.loading = true
this.updates = await invoke('get_updates')
this.loading = false
},
async fetchAll() {
this.loading = true
this.allSoftware = await invoke('get_all_software')
this.loading = false
},
async install(id: string) {
const software = this.findSoftware(id)
if (software) software.status = 'pending'
await invoke('install_software', { id })
},
findSoftware(id: string) {
return this.essentials.find(s => s.id === id) ||
this.updates.find(s => s.id === id) ||
this.allSoftware.find(s => s.id === id)
},
initListener() {
listen('install-status', (event: any) => {
const { id, status, progress } = event.payload
const software = this.findSoftware(id)
if (software) {
software.status = status
software.progress = progress
}
})
}
}
})