mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-29 06:09:45 +08:00
🐛 修复日志目录异常
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//! @file src/main.rs
|
||||
//! @desc 主模块,用于启动应用
|
||||
//! @since Beta v0.5.1
|
||||
//! @since Beta v0.5.2
|
||||
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
@@ -45,7 +45,7 @@ fn main() {
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_process::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(plugins::build_sql_plugin())
|
||||
.plugin(tauri_plugin_sql::Builder::default().build())
|
||||
.plugin(plugins::build_log_plugin())
|
||||
.setup(|_app| {
|
||||
let _window = _app.get_webview_window("TeyvatGuide");
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
//! @file src/plugins.rs
|
||||
//! @desc 插件模块,用于注册插件
|
||||
//! @since Beta v0.5.0
|
||||
//! @since Beta v0.5.2
|
||||
|
||||
use super::utils;
|
||||
use log::LevelFilter;
|
||||
use tauri::plugin::TauriPlugin;
|
||||
use tauri::Runtime;
|
||||
use tauri_plugin_log::{Target, TargetKind, TimezoneStrategy};
|
||||
use tauri_plugin_sql::PluginConfig;
|
||||
|
||||
// sqlite 插件
|
||||
pub fn build_sql_plugin<R: Runtime>() -> TauriPlugin<R, Option<PluginConfig>> {
|
||||
tauri_plugin_sql::Builder::default().build()
|
||||
}
|
||||
|
||||
// 日志插件
|
||||
pub fn build_log_plugin<R: Runtime>() -> TauriPlugin<R> {
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
</template>
|
||||
<template #append>
|
||||
<v-icon @click="confirmCLD()" style="cursor: pointer" title="清理日志文件"
|
||||
>mdi-delete</v-icon
|
||||
>
|
||||
>mdi-delete
|
||||
</v-icon>
|
||||
 
|
||||
<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: "确认修改用户数据路径吗?" });
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user