not sync after every install

This commit is contained in:
Julian Freeman
2026-03-31 18:28:07 -04:00
parent 61caeba242
commit 517ee39707

View File

@@ -45,7 +45,8 @@ export const useSoftwareStore = defineStore('software', {
loading: false,
isInitialized: false,
initStatus: '正在检查系统环境...',
lastFetched: 0
lastFetched: 0,
refreshTimer: null as any
}),
getters: {
mergedEssentials: (state) => {
@@ -244,6 +245,26 @@ export const useSoftwareStore = defineStore('software', {
}
}
},
// 引入防抖刷新:在批量安装期间,仅在最后一次成功后的 5 秒执行全量扫描
scheduleDataRefresh() {
if (this.refreshTimer) clearTimeout(this.refreshTimer);
this.refreshTimer = setTimeout(async () => {
// 执行全量刷新
await this.fetchAllData();
// 刷新完成后清理所有已成功的任务状态,让卡片恢复正常显示
Object.keys(this.activeTasks).forEach(id => {
if (this.activeTasks[id].status === 'success') {
delete this.activeTasks[id];
}
});
this.refreshTimer = null;
}, 5000);
},
findSoftware(id: string) {
return this.essentials.find(s => s.id === id) ||
this.updates.find(s => s.id === id) ||
@@ -260,15 +281,12 @@ export const useSoftwareStore = defineStore('software', {
if (status === 'success') {
this.lastFetched = 0;
// 立即更新勾选状态,提升响应感
this.selectedEssentialIds = this.selectedEssentialIds.filter(i => i !== id);
this.selectedUpdateIds = this.selectedUpdateIds.filter(i => i !== id);
setTimeout(() => {
if (this.activeTasks[id]?.status === 'success') {
delete this.activeTasks[id];
this.fetchAllData();
}
}, 3000);
// 触发防抖刷新
this.scheduleDataRefresh();
}
})