From 56c6c4f70fe4cfdc80cc4b8967c66672d4d0866e Mon Sep 17 00:00:00 2001 From: BTMuli Date: Thu, 26 Oct 2023 21:11:39 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B1=20=E5=B0=9D=E8=AF=95=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=B8=85=E9=99=A4=20#55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 4 ++++ src/pages/common/Config.vue | 28 +++++++++++++++++++--------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 9a4de912..c124c19f 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" tauri-build = { version = "1.4", features = [] } [dependencies] -tauri = { version = "1.4", features = [ "window-hide", "os-all", "clipboard-all", "dialog-open", "dialog-save", "fs-create-dir", "fs-remove-dir", "fs-write-file", "fs-remove-file", "fs-read-file", "path-all", "fs-exists", "window-close", "window-set-title", "window-unminimize", "window-show", "window-set-focus", "http-request", "shell-open"] } +tauri = { version = "1.4", features = [ "process-relaunch", "window-hide", "os-all", "clipboard-all", "dialog-open", "dialog-save", "fs-create-dir", "fs-remove-dir", "fs-write-file", "fs-remove-file", "fs-read-file", "path-all", "fs-exists", "window-close", "window-set-title", "window-unminimize", "window-show", "window-set-focus", "http-request", "shell-open"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" webview2-com = "0.27.0" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index a2d0b2da..553fdcbc 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -54,6 +54,10 @@ }, "os": { "all": true + }, + "process": { + "all": false, + "relaunch": true } }, "bundle": { diff --git a/src/pages/common/Config.vue b/src/pages/common/Config.vue index 2692c1dd..6f3ad196 100644 --- a/src/pages/common/Config.vue +++ b/src/pages/common/Config.vue @@ -122,7 +122,7 @@ /> - + import { app, fs, os } from "@tauri-apps/api"; +import { relaunch } from "@tauri-apps/api/process"; import { computed, onMounted, ref } from "vue"; import showConfirm from "../../components/func/confirm"; @@ -437,25 +438,34 @@ async function confirmUpdate(title?: string): Promise { } // 清除用户缓存 -async function confirmDelUC(): Promise { +async function confirmDelCache(): Promise { const res = await showConfirm({ - title: "确认清除用户缓存吗?", - text: "备份数据也将被清除", + title: "确认清除缓存吗?", + text: "只删除 Webview 缓存,不处理用户数据", }); if (!res) { showSnackbar({ color: "grey", - text: "已取消清除用户缓存", + text: "已取消清除缓存", }); return; } - await fs.removeDir("userData", { + await fs.removeDir("EBWebview\\Default\\Cache", { dir: fs.BaseDirectory.AppLocalData, recursive: true, }); - showSnackbar({ text: "用户数据已删除!" }); - achievementsStore.init(); - await fs.createDir("userData", { dir: fs.BaseDirectory.AppLocalData }); + await fs.removeDir("EBWebview\\Default\\Code Cache", { + dir: fs.BaseDirectory.AppLocalData, + recursive: true, + }); + showSnackbar({ + text: "缓存已清除!即将重启应用...", + }); + await new Promise(() => { + setTimeout(async () => { + await relaunch(); + }, 1500); + }); } // 恢复默认设置