From d74e7a7a317ad00bafc261f0a63c0c94a19f9253 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Sat, 15 Nov 2025 14:50:46 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20=E5=A4=84=E7=90=86=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=EF=BC=8C=E6=B8=85=E9=99=A4=E7=BC=93=E5=AD=98=E5=90=8E?= =?UTF-8?q?=E9=87=8D=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/PageConfig.vue | 12 ++++++++---- src/utils/toolFunc.ts | 12 +++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/pages/common/PageConfig.vue b/src/pages/common/PageConfig.vue index 932334b1..163698d2 100644 --- a/src/pages/common/PageConfig.vue +++ b/src/pages/common/PageConfig.vue @@ -166,7 +166,7 @@ import { emit } from "@tauri-apps/api/event"; import { open } from "@tauri-apps/plugin-dialog"; import { remove } from "@tauri-apps/plugin-fs"; import { platform } from "@tauri-apps/plugin-os"; -import { exit } from "@tauri-apps/plugin-process"; +import { relaunch } from "@tauri-apps/plugin-process"; import { backUpUserData, restoreUserData } from "@utils/dataBS.js"; import { getBuildTime } from "@utils/TGBuild.js"; import TGLogger from "@utils/TGLogger.js"; @@ -391,14 +391,18 @@ async function confirmDelCache(): Promise { } await showLoading.start("正在清除缓存"); for (const dir of CacheDir) { - await showLoading.update(dir); - await remove(dir, { recursive: true }); + try { + await showLoading.update(dir); + await remove(dir, { recursive: true }); + } catch (e) { + await TGLogger.Error(`[Config][confirmDelCache] 清除缓存失败 ${dir} ${e}`); + } } await showLoading.end(); await TGLogger.Info("[Config][confirmDelCache] 缓存清除完成"); showSnackbar.success("缓存已清除!即将退出应用!"); await new Promise((resolve) => setTimeout(resolve, 1500)); - await exit(); + await relaunch(); } // 恢复默认设置 diff --git a/src/utils/toolFunc.ts b/src/utils/toolFunc.ts index bd94c2f9..0a7d15b5 100644 --- a/src/utils/toolFunc.ts +++ b/src/utils/toolFunc.ts @@ -1,7 +1,5 @@ /** - * @file utils/toolFunc.ts - * @description 一些工具函数 - * @since Beta v0.8.2 + * 一些工具函数 */ import { AvatarExtResTypeEnum, AvatarExtTypeEnum } from "@enum/bbs.js"; @@ -122,14 +120,14 @@ export function bytesToSize(bytes: number): string { } /** - * @description 获取缓存目录 - * @since Beta v0.5.0 - * @returns {string|string[]} 缓存目录 + * 获取缓存目录 + * @returns {Array|false} 缓存目录 */ -export async function getCacheDir(): Promise { +export async function getCacheDir(): Promise | false> { const cacheDir = await path.appCacheDir(); const osType = type().toLowerCase(); if (osType === "windows") { + // TODO: 会报错显示占用 const cache = `${cacheDir}${path.sep()}EBWebview${path.sep()}Default${path.sep()}Cache`; const codeCache = `${cacheDir}${path.sep()}EBWebview${path.sep()}Default${path.sep()}Code Cache`; return [cache, codeCache];