@setoelkahfi / svara / commits / b7110fb

feat: added button to open log file path

mellbacon committed Nov 1, 2023 at 00:58 UTC b7110fb287ca20a2fc9a018161a7efd465673cea
2 files changed +9 -1
src/config/config.ts
+7 -1
@@ -1,7 +1,7 @@
1 import { writable } from "svelte/store";
2 import Mousetrap from "mousetrap";
3 import { getKeybinds } from "./commands";
4 -import { path } from "@tauri-apps/api";
4 +import { fs, invoke, path } from "@tauri-apps/api";
5 import { loadTheme } from "./themehandler";
6 import { Store } from "tauri-plugin-store-api";
7 import { setEditorFontFamily, setEditorFontSize } from "../lib/Editor.svelte";
@@ -95,4 +95,10 @@ export async function loadDefaultSettings() {
95 loadTheme(value);
96 })
97 info("Settings initialized", {file: "config.ts", line: 97});
98 +}
99 +
100 +export async function openLogFiles() {
101 + const log_dir = await path.appConfigDir();
102 + let recent_log = (await fs.readDir(`${log_dir}logs`)).at(-1);
103 + await invoke("open_in_explorer", {path: `${log_dir}logs${path.sep}${recent_log.name}`});
104 }
\ No newline at end of file
src/lib/Header.svelte
+2
@@ -6,6 +6,7 @@
6 import { workspaceName } from "./File";
7 import { commands } from "../config/commands";
8 import { shell } from "@tauri-apps/api";
9 + import { openLogFiles } from "../config/config";
10
11 const items = [
12 {menuname: "File", children: [
@@ -54,6 +55,7 @@
55 {name: "Show Release Notes", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}},
56 {name: "Check for Updates", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}},
57 {name: "About", shortcut: "", action: () => {shell.open("https://github.com/mellobacon/Nucleus")}},
58 + {name: "Open Logs", shortcut: "", action: async () => {await openLogFiles()}},
59 ]},
60 ];
61 </script>