mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🎨 简化代码,统一返回数组
This commit is contained in:
@@ -453,15 +453,11 @@ async function confirmDelCache(): Promise<void> {
|
|||||||
loadingSub.value = "耗时较久,请稍作等候";
|
loadingSub.value = "耗时较久,请稍作等候";
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const timeStart = Date.now();
|
const timeStart = Date.now();
|
||||||
if (Array.isArray(CacheDir)) {
|
for (const dir of CacheDir) {
|
||||||
for (const dir of CacheDir) {
|
const size: number = await invoke("get_dir_size", { path: dir });
|
||||||
const size: number = await invoke("get_dir_size", { path: dir });
|
cacheBSize += size;
|
||||||
cacheBSize += size;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cacheBSize = await invoke("get_dir_size", { path: CacheDir });
|
|
||||||
}
|
}
|
||||||
let cacheSize = bytesToSize(cacheBSize);
|
const cacheSize = bytesToSize(cacheBSize);
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
const timeEnd = Date.now();
|
const timeEnd = Date.now();
|
||||||
const res = await showConfirm({
|
const res = await showConfirm({
|
||||||
@@ -475,12 +471,8 @@ async function confirmDelCache(): Promise<void> {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Array.isArray(CacheDir)) {
|
for (const dir of CacheDir) {
|
||||||
for (const dir of CacheDir) {
|
await fs.removeDir(dir, { recursive: true });
|
||||||
await fs.removeDir(dir, { recursive: true });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
await fs.removeDir(CacheDir, { recursive: true });
|
|
||||||
}
|
}
|
||||||
showSnackbar({
|
showSnackbar({
|
||||||
text: "缓存已清除!请重新启动应用!",
|
text: "缓存已清除!请重新启动应用!",
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export async function getDirSize(
|
|||||||
* @since Beta v0.3.4
|
* @since Beta v0.3.4
|
||||||
* @returns {string|string[]} 缓存目录
|
* @returns {string|string[]} 缓存目录
|
||||||
*/
|
*/
|
||||||
export async function getCacheDir(): Promise<string | string[] | false> {
|
export async function getCacheDir(): Promise<string[] | false> {
|
||||||
const cacheDir = await path.appCacheDir();
|
const cacheDir = await path.appCacheDir();
|
||||||
const osType = await os.type();
|
const osType = await os.type();
|
||||||
if (osType === "Windows_NT") {
|
if (osType === "Windows_NT") {
|
||||||
@@ -91,7 +91,7 @@ export async function getCacheDir(): Promise<string | string[] | false> {
|
|||||||
const codeCache = `${cacheDir}EBWebview${path.sep}Default${path.sep}Code Cache`;
|
const codeCache = `${cacheDir}EBWebview${path.sep}Default${path.sep}Code Cache`;
|
||||||
return [cache, codeCache];
|
return [cache, codeCache];
|
||||||
} else if (osType === "Darwin") {
|
} else if (osType === "Darwin") {
|
||||||
return `${cacheDir}WebKit`;
|
return [`${cacheDir}WebKit`];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user