From 0a8f34ab86eb64c46934c2ffdaa54e3332b626a7 Mon Sep 17 00:00:00 2001 From: Net Date: Tue, 23 Jul 2024 11:46:08 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20fetch=20=E0=B9=80?= =?UTF-8?q?=E0=B9=80=E0=B8=A5=E0=B9=89=E0=B8=A7=E0=B8=AA=E0=B8=96=E0=B8=B2?= =?UTF-8?q?=E0=B8=99=E0=B8=B0=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B9=80=E0=B8=9B?= =?UTF-8?q?=E0=B8=A5=E0=B8=B5=E0=B9=88=E0=B8=A2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/04_system/stores/main.ts | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/modules/04_system/stores/main.ts b/src/modules/04_system/stores/main.ts index 5a55dced..ff7d04b4 100644 --- a/src/modules/04_system/stores/main.ts +++ b/src/modules/04_system/stores/main.ts @@ -62,7 +62,7 @@ export const useDataStore = defineStore("systemStore", () => { await http .post(config.API.backup + "/create") .then(async (res) => { - await backupRunningList(); + await backupRunningList(fetchListBackup); }) .finally(() => { hideLoader(); @@ -99,24 +99,24 @@ export const useDataStore = defineStore("systemStore", () => { recordRestore.value[res.data] = tempValue; } - restoreRunningList(); + restoreRunningList(fetchListBackup); }); } - async function backupRunningList() { + async function backupRunningList(cb: () => void) { await http .get(config.API.backup + "/backup-running-list") .then(async (res) => { backupRunTotal.value = res.data.length; - if (backupRunTotal.value == 0) { - fetchListBackup(); + if (backupRunTotal.value === 0 && prevBackupRunTotal.value !== 0) { + cb(); prevBackupRunTotal.value = backupRunTotal.value; return; } setTimeout(async () => { - backupRunningList(); + backupRunningList(cb); }, 3000); if (prevBackupRunTotal.value !== backupRunTotal.value) { @@ -142,22 +142,19 @@ export const useDataStore = defineStore("systemStore", () => { }); } - async function restoreRunningList() { + async function restoreRunningList(cb: () => void) { await http .get(config.API.backup + "/restore-running-list") .then(async (res) => { - console.log(res.data); - restoreRunTotal.value = res.data.length; - - if (restoreRunTotal.value == 0) { - fetchListBackup(); + if (restoreRunTotal.value === 0 && prevRestoreRunTotal.value !== 0) { + cb(); prevRestoreRunTotal.value = restoreRunTotal.value; return; } setTimeout(async () => { - restoreRunningList(); + restoreRunningList(cb); }, 3000); if (prevRestoreRunTotal.value !== restoreRunTotal.value) {