fix fetch bug
This commit is contained in:
@@ -20,6 +20,19 @@ export const useCatalogStore = defineStore('catalog', {
|
||||
lastFetched: 0
|
||||
}),
|
||||
actions: {
|
||||
async ensureEssentialsAvailable() {
|
||||
const cachedRepo = await invoke('get_essentials') as unknown
|
||||
if (cachedRepo) return true
|
||||
|
||||
try {
|
||||
await invoke('sync_essentials')
|
||||
return true
|
||||
} catch (err) {
|
||||
console.error('Initial sync failed:', err)
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
async initializeApp() {
|
||||
if (this.isInitialized) return
|
||||
this.initStatus = '正在加载应用配置...'
|
||||
@@ -51,15 +64,8 @@ export const useCatalogStore = defineStore('catalog', {
|
||||
},
|
||||
|
||||
async fetchEssentials() {
|
||||
await this.ensureEssentialsAvailable()
|
||||
let response = await invoke('get_essentials_status') as EssentialsStatusResponse
|
||||
if ((!response || !response[1]) && !(await invoke('get_essentials') as unknown)) {
|
||||
try {
|
||||
await invoke('sync_essentials')
|
||||
response = await invoke('get_essentials_status') as EssentialsStatusResponse
|
||||
} catch (err) {
|
||||
console.error('Initial sync failed:', err)
|
||||
}
|
||||
}
|
||||
if (response && Array.isArray(response[1])) {
|
||||
this.essentialsVersion = response[0] || ''
|
||||
this.essentials = response[1]
|
||||
@@ -93,6 +99,7 @@ export const useCatalogStore = defineStore('catalog', {
|
||||
async fetchAllData() {
|
||||
this.loading = true
|
||||
try {
|
||||
await this.ensureEssentialsAvailable()
|
||||
const snapshot = await invoke('get_dashboard_snapshot') as DashboardSnapshot
|
||||
this.applyDashboardSnapshot(snapshot)
|
||||
await this.loadIconsForUpdates()
|
||||
|
||||
Reference in New Issue
Block a user