From 0bb86a4f8c56afc0a8adf1b1522856cf4422ab6f Mon Sep 17 00:00:00 2001 From: BTMuli Date: Wed, 8 Mar 2023 22:57:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(config):=20=E9=80=82=E5=BA=94=E6=96=B0?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84=E8=BF=9B=E8=A1=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Config.vue | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/pages/Config.vue b/src/pages/Config.vue index 7d3472b1..204a3e7d 100644 --- a/src/pages/Config.vue +++ b/src/pages/Config.vue @@ -2,11 +2,11 @@ 配置 - + 打开用户数据目录 - - 删除用户数据 + + 删除本地数据 恢复默认配置 @@ -20,6 +20,7 @@ import { defineComponent } from "vue"; import useAppStore from "../store/modules/app"; import { dialog, fs } from "@tauri-apps/api"; import { BaseDirectory } from "@tauri-apps/api/fs"; +import { TGAppDataList } from "../data"; export default defineComponent({ name: "Config", data() { @@ -30,16 +31,16 @@ export default defineComponent({ }, methods: { // 打开数据文件夹 - async openUserData() { + async openMergeData() { const appStore = useAppStore(); - const appDataPath = appStore.dataPath.user; + const mergeDataPath = appStore.dataPath.merge; await dialog.open({ - defaultPath: appDataPath, + defaultPath: mergeDataPath, filters: [], }); }, // 删除数据 - async deleteUserData() { + async deleteData() { const res = await dialog.confirm("确定要删除用户数据吗?"); if (res) { await fs.removeDir("userData", { @@ -53,6 +54,13 @@ export default defineComponent({ await dialog.message("用户数据已删除!"); await fs.createDir("userData", { dir: BaseDirectory.AppLocalData }); await fs.createDir("mergeData", { dir: BaseDirectory.AppLocalData }); + const appStore = useAppStore(); + TGAppDataList.MergeData.map(async item => { + await fs.writeFile( + `${appStore.dataPath.merge}\\${item.name}`, + JSON.stringify(item.data, null, 4) + ); + }); } }, // 恢复默认配置