add splashscreen

This commit is contained in:
Julian Freeman
2026-03-14 21:19:57 -04:00
parent 60113e9629
commit 63b469be97
5 changed files with 172 additions and 34 deletions

View File

@@ -20,6 +20,8 @@ export const useSoftwareStore = defineStore('software', {
selectedUpdateIds: [] as string[],
logs: [] as LogEntry[],
loading: false,
isInitialized: false,
initStatus: '正在检查系统环境...',
lastFetched: 0
}),
getters: {
@@ -47,6 +49,20 @@ export const useSoftwareStore = defineStore('software', {
sortedAllSoftware: (state) => [...state.allSoftware].sort(sortByName)
},
actions: {
async initializeApp() {
if (this.isInitialized) return;
this.initStatus = '正在同步 Winget 模块...';
try {
await invoke('initialize_app');
this.isInitialized = true;
} catch (err) {
this.initStatus = '环境配置失败,请检查运行日志';
console.error('Init failed:', err);
// 即使失败也允许进入,让用户看日志
setTimeout(() => { this.isInitialized = true; }, 2000);
}
},
toggleSelection(id: string, type: 'essential' | 'update') {
const list = type === 'essential' ? this.selectedEssentialIds : this.selectedUpdateIds;
const index = list.indexOf(id);
@@ -151,10 +167,8 @@ export const useSoftwareStore = defineStore('software', {
}
})
// 监听日志事件
listen('log-event', (event: any) => {
this.logs.unshift(event.payload as LogEntry);
// 限制日志条数,防止内存溢出
if (this.logs.length > 200) this.logs.pop();
})
}