diff --git a/src/pages/common/Config.vue b/src/pages/common/Config.vue index 3d8d64e6..c0bc7ab2 100644 --- a/src/pages/common/Config.vue +++ b/src/pages/common/Config.vue @@ -453,15 +453,11 @@ async function confirmDelCache(): Promise { loadingSub.value = "耗时较久,请稍作等候"; loading.value = true; const timeStart = Date.now(); - if (Array.isArray(CacheDir)) { - for (const dir of CacheDir) { - const size: number = await invoke("get_dir_size", { path: dir }); - cacheBSize += size; - } - } else { - cacheBSize = await invoke("get_dir_size", { path: CacheDir }); + for (const dir of CacheDir) { + const size: number = await invoke("get_dir_size", { path: dir }); + cacheBSize += size; } - let cacheSize = bytesToSize(cacheBSize); + const cacheSize = bytesToSize(cacheBSize); loading.value = false; const timeEnd = Date.now(); const res = await showConfirm({ @@ -475,12 +471,8 @@ async function confirmDelCache(): Promise { }); return; } - if (Array.isArray(CacheDir)) { - for (const dir of CacheDir) { - await fs.removeDir(dir, { recursive: true }); - } - } else { - await fs.removeDir(CacheDir, { recursive: true }); + for (const dir of CacheDir) { + await fs.removeDir(dir, { recursive: true }); } showSnackbar({ text: "缓存已清除!请重新启动应用!", diff --git a/src/utils/toolFunc.ts b/src/utils/toolFunc.ts index 75beebc1..8f583503 100644 --- a/src/utils/toolFunc.ts +++ b/src/utils/toolFunc.ts @@ -83,7 +83,7 @@ export async function getDirSize( * @since Beta v0.3.4 * @returns {string|string[]} 缓存目录 */ -export async function getCacheDir(): Promise { +export async function getCacheDir(): Promise { const cacheDir = await path.appCacheDir(); const osType = await os.type(); if (osType === "Windows_NT") { @@ -91,7 +91,7 @@ export async function getCacheDir(): Promise { const codeCache = `${cacheDir}EBWebview${path.sep}Default${path.sep}Code Cache`; return [cache, codeCache]; } else if (osType === "Darwin") { - return `${cacheDir}WebKit`; + return [`${cacheDir}WebKit`]; } return false; }