🐛 修复日志目录异常

This commit is contained in:
目棃
2024-07-31 18:53:47 +08:00
parent cab497f573
commit 49854367b1
4 changed files with 29 additions and 13 deletions

View File

@@ -46,8 +46,8 @@
</template>
<template #append>
<v-icon @click="confirmCLD()" style="cursor: pointer" title="清理日志文件"
>mdi-delete</v-icon
>
>mdi-delete
</v-icon>
&emsp;
<v-icon @click="openPath('log')" style="cursor: pointer" title="打开日志目录"
>mdi-folder-open
@@ -64,6 +64,7 @@
import { path } from "@tauri-apps/api";
import { open } from "@tauri-apps/plugin-dialog";
import { readDir, remove } from "@tauri-apps/plugin-fs";
import { onMounted } from "vue";
import TGSqlite from "../../plugins/Sqlite/index.js";
import { useAppStore } from "../../store/modules/app.js";
@@ -74,6 +75,27 @@ import showSnackbar from "../func/snackbar.js";
const appStore = useAppStore();
onMounted(async () => {
const logDir = await path.appLogDir();
const dbPath = `${await path.appConfigDir()}${path.sep()}TeyvatGuide.db`;
let message = "";
if (appStore.dbPath !== dbPath) {
appStore.dbPath = dbPath;
await TGSqlite.saveAppData("dbPath", dbPath);
message += "数据库路径 ";
}
if (appStore.logDir !== logDir) {
appStore.logDir = logDir;
message += "日志路径 ";
}
if (message !== "") {
showSnackbar({
text: `${message}已更新!`,
color: "success",
});
}
});
async function confirmCUD(): Promise<void> {
const oriDir = appStore.userDir;
const check = await showConfirm({ title: "确认修改用户数据路径吗?" });

View File

@@ -1,7 +1,7 @@
/**
* @file store/modules/app.ts
* @description App store module
* @since Beta v0.5.0
* @since Beta v0.5.2
*/
import { path } from "@tauri-apps/api";
@@ -16,7 +16,7 @@ const userDataDir = `${await path.appLocalDataDir()}${path.sep()}userData`;
// 用于存放数据库的路径
const dbDataPath = `${await path.appConfigDir()}${path.sep()}TeyvatGuide.db`;
// 用于存放日志的路径
const logDataDir = `${await path.appConfigDir()}${path.sep()}logs`;
const logDataDir = await path.appLogDir();
export const useAppStore = defineStore(
"app",