Skip to content

Commit c2229b0

Browse files
committed
feat: add more options in log viewer
1 parent 7546898 commit c2229b0

File tree

8 files changed

+72
-9
lines changed

8 files changed

+72
-9
lines changed

bun.lockb

423 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@tauri-apps/plugin-http": "~2",
2222
"@tauri-apps/plugin-log": "~2",
2323
"@tauri-apps/plugin-notification": "~2",
24+
"@tauri-apps/plugin-opener": "~2",
2425
"@tauri-apps/plugin-os": "~2",
2526
"@tauri-apps/plugin-process": "~2",
2627
"@tauri-apps/plugin-shell": "~2",

src-tauri/Cargo.lock

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ tauri-plugin-process = "2"
3636
tauri-plugin-shell = "2"
3737
tauri-plugin-upload = "2"
3838
tauri-plugin-drpc = "0.1.4"
39+
tauri-plugin-opener = "2"
3940

4041
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
4142
tauri-plugin-global-shortcut = "2"

src-tauri/capabilities/default.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@
253253
"notification:allow-request-permission",
254254
"notification:allow-show",
255255

256+
"opener:allow-open-url",
257+
"opener:allow-default-urls",
258+
"opener:allow-reveal-item-in-dir",
259+
{
260+
"identifier": "opener:allow-open-path",
261+
"allow": [{ "path": "$APPDATA" }, { "path": "$APPDATA/**/*" }]
262+
},
263+
256264
"os:allow-arch",
257265
"os:allow-exe-extension",
258266
"os:allow-family",

src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use tauri::Manager;
33
#[cfg_attr(mobile, tauri::mobile_entry_point)]
44
pub fn run() {
55
tauri::Builder::default()
6+
.plugin(tauri_plugin_opener::init())
67
.plugin(tauri_plugin_upload::init())
78
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
89
let _ = app

src/components/logging/LogControls.vue

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
import MaterialRipple from "@/components/misc/MaterialRipple.vue";
33
import { ref, shallowRef, useTemplateRef, watchEffect } from "vue";
44
import { useDebounceFn, useEventListener } from "@vueuse/core";
5+
import { revealItemInDir } from "@tauri-apps/plugin-opener";
6+
import { appDataDir, join } from "@tauri-apps/api/path";
57
68
const target = useTemplateRef("target");
79
const focused = ref<boolean>(false);
810
const found = shallowRef<Array<number>>([]);
911
const position = ref(1);
1012
11-
const { searchLogs, scrollToIndex } = defineProps<{
12-
"searchLogs" : (search: string) => Array<number>;
13-
"scrollToIndex": (index: number) => void;
13+
const { searchLogs, scrollToIndex, horizontalScroll, toggleHorizontalScroll } = defineProps<{
14+
"searchLogs" : (search: string) => Array<number>;
15+
"scrollToIndex" : (index: number) => void;
16+
"horizontalScroll" : boolean;
17+
"toggleHorizontalScroll": () => void;
1418
}>();
1519
1620
function focusSearch(): void {
@@ -57,6 +61,12 @@ function handleEnter(event: KeyboardEvent): void {
5761
);
5862
}
5963
64+
async function viewInExplorer(): Promise<void> {
65+
const latestLogAbsolutePath = await join(await appDataDir(), "logs", "latest.log");
66+
67+
await revealItemInDir(latestLogAbsolutePath);
68+
}
69+
6070
const handleInput = useDebounceFn((event: Event): void => {
6171
const target = event?.target as HTMLInputElement;
6272
@@ -85,12 +95,12 @@ watchEffect(() => {
8595
</script>
8696

8797
<template>
88-
<div class="h-8 w-full flex flex-nowrap gap-2">
98+
<div class="h-8 w-full flex flex-wrap gap-2 overflow-x-auto">
8999
<div
90100
@click="focusSearch"
91101
:class="[
92102
focused ? 'cursor-text' : 'cursor-pointer',
93-
'relative w-40 flex flex-nowrap items-center gap-2 rounded-md bg-neutral-800 pl-2',
103+
'shrink-0 relative w-40 flex flex-nowrap items-center gap-2 rounded-md bg-neutral-800 pl-2',
94104
]"
95105
>
96106
<div :class="[
@@ -112,7 +122,7 @@ watchEffect(() => {
112122
/>
113123
<MaterialRipple :disabled="focused" />
114124
</div>
115-
<div class="flex flex-nowrap bg-neutral-800 items-center h-full rounded-md text-sm text-neutral-400">
125+
<div class="shrink-0 flex flex-nowrap bg-neutral-800 items-center h-full rounded-md text-sm text-neutral-400">
116126
<button
117127
@click="incrementIndex"
118128
class="relative grid size-6 ml-1 place-items-center rounded-md transition-[color] hover:text-white"
@@ -139,12 +149,29 @@ watchEffect(() => {
139149
of {{ found.length }} matches
140150
</p>
141151
</div>
142-
<button class="relative grid px-2 w-fit flex flex-nowrap gap-2 items-center h-full place-items-center rounded-md bg-neutral-800">
152+
<button
153+
@click="viewInExplorer"
154+
class="shrink-0 relative grid px-2 w-fit flex flex-nowrap gap-2 items-center h-full place-items-center rounded-md bg-neutral-800"
155+
>
143156
<span :class="['i-lucide-external-link block size-4']"></span>
144157
<span class="block">
145158
View in Explorer
146159
</span>
147160
<MaterialRipple />
148161
</button>
162+
<button
163+
@click="toggleHorizontalScroll"
164+
:class="[
165+
horizontalScroll ? 'invert' : '',
166+
'shrink-0 relative grid px-2 w-fit flex flex-nowrap gap-2 bg-neutral-800',
167+
'items-center h-full place-items-center rounded-md transition-[filter]',
168+
]"
169+
>
170+
<span :class="['i-lucide-text-wrap block size-4']"></span>
171+
<span class="block">
172+
Line Breaks
173+
</span>
174+
<MaterialRipple />
175+
</button>
149176
</div>
150177
</template>

src/components/logging/LogViewer.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MaterialRipple from "@/components/misc/MaterialRipple.vue";
1313
const virtualList = useTemplateRef("virtualList");
1414
1515
const logs = shallowRef<Array<string>>(["__kaede-trigger-loading"]);
16-
const horizontalScroll = ref<boolean>(false);
16+
const horizontalScroll = ref<boolean>(true);
1717
const fileData = ref<{
1818
"size": string | undefined;
1919
"time": string | undefined;
@@ -120,7 +120,7 @@ onMounted(async () => {
120120
@contextmenu="showContextMenu"
121121
class="rounded-md pointer-events-auto z-40000 h-fit max-h-[calc(100vh-64px)] max-w-[calc(100vw-64px)] w-fit flex flex-col gap-2 bg-neutral-900 p-4 text-white drop-shadow-lg"
122122
>
123-
<div class="w-full flex flex-nowrap items-start justify-between gap-4 pb-2">
123+
<div class="w-full flex flex-nowrap items-start justify-between gap-4 pb-2 shrink-0">
124124
<div class="flex flex-col gap-2">
125125
<p class="select-none text-xl font-medium leading-none">
126126
Logs
@@ -134,6 +134,8 @@ onMounted(async () => {
134134
<LogControls
135135
:searchLogs="searchLogs"
136136
:scrollToIndex="(index: number) => virtualList?.scrollToIndex?.(index)"
137+
:horizontalScroll="horizontalScroll"
138+
:toggleHorizontalScroll="() => horizontalScroll = !horizontalScroll"
137139
/>
138140
</div>
139141
<button

0 commit comments

Comments
 (0)