mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-21 05:25:45 +08:00
🐛 修复日志目录异常
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
//! @file src/main.rs
|
//! @file src/main.rs
|
||||||
//! @desc 主模块,用于启动应用
|
//! @desc 主模块,用于启动应用
|
||||||
//! @since Beta v0.5.1
|
//! @since Beta v0.5.2
|
||||||
|
|
||||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
@@ -45,7 +45,7 @@ fn main() {
|
|||||||
.plugin(tauri_plugin_os::init())
|
.plugin(tauri_plugin_os::init())
|
||||||
.plugin(tauri_plugin_process::init())
|
.plugin(tauri_plugin_process::init())
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.plugin(plugins::build_sql_plugin())
|
.plugin(tauri_plugin_sql::Builder::default().build())
|
||||||
.plugin(plugins::build_log_plugin())
|
.plugin(plugins::build_log_plugin())
|
||||||
.setup(|_app| {
|
.setup(|_app| {
|
||||||
let _window = _app.get_webview_window("TeyvatGuide");
|
let _window = _app.get_webview_window("TeyvatGuide");
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
//! @file src/plugins.rs
|
//! @file src/plugins.rs
|
||||||
//! @desc 插件模块,用于注册插件
|
//! @desc 插件模块,用于注册插件
|
||||||
//! @since Beta v0.5.0
|
//! @since Beta v0.5.2
|
||||||
|
|
||||||
use super::utils;
|
use super::utils;
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use tauri::plugin::TauriPlugin;
|
use tauri::plugin::TauriPlugin;
|
||||||
use tauri::Runtime;
|
use tauri::Runtime;
|
||||||
use tauri_plugin_log::{Target, TargetKind, TimezoneStrategy};
|
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> {
|
pub fn build_log_plugin<R: Runtime>() -> TauriPlugin<R> {
|
||||||
|
|||||||
@@ -46,8 +46,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #append>
|
<template #append>
|
||||||
<v-icon @click="confirmCLD()" style="cursor: pointer" title="清理日志文件"
|
<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="打开日志目录"
|
<v-icon @click="openPath('log')" style="cursor: pointer" title="打开日志目录"
|
||||||
>mdi-folder-open
|
>mdi-folder-open
|
||||||
@@ -64,6 +64,7 @@
|
|||||||
import { path } from "@tauri-apps/api";
|
import { path } from "@tauri-apps/api";
|
||||||
import { open } from "@tauri-apps/plugin-dialog";
|
import { open } from "@tauri-apps/plugin-dialog";
|
||||||
import { readDir, remove } from "@tauri-apps/plugin-fs";
|
import { readDir, remove } from "@tauri-apps/plugin-fs";
|
||||||
|
import { onMounted } from "vue";
|
||||||
|
|
||||||
import TGSqlite from "../../plugins/Sqlite/index.js";
|
import TGSqlite from "../../plugins/Sqlite/index.js";
|
||||||
import { useAppStore } from "../../store/modules/app.js";
|
import { useAppStore } from "../../store/modules/app.js";
|
||||||
@@ -74,6 +75,27 @@ import showSnackbar from "../func/snackbar.js";
|
|||||||
|
|
||||||
const appStore = useAppStore();
|
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> {
|
async function confirmCUD(): Promise<void> {
|
||||||
const oriDir = appStore.userDir;
|
const oriDir = appStore.userDir;
|
||||||
const check = await showConfirm({ title: "确认修改用户数据路径吗?" });
|
const check = await showConfirm({ title: "确认修改用户数据路径吗?" });
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file store/modules/app.ts
|
* @file store/modules/app.ts
|
||||||
* @description App store module
|
* @description App store module
|
||||||
* @since Beta v0.5.0
|
* @since Beta v0.5.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { path } from "@tauri-apps/api";
|
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 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(
|
export const useAppStore = defineStore(
|
||||||
"app",
|
"app",
|
||||||
|
|||||||
Reference in New Issue
Block a user