fix: mini timer renders via window label instead of hash routing
The mini timer window was blank because hash-based routing (createWebHashHistory) doesn't work with Tauri's WebviewUrl path. Now App.vue detects the mini timer by checking getCurrentWindow().label === 'mini-timer' and renders the MiniTimer component directly, bypassing the router entirely.
This commit is contained in:
38
src/App.vue
38
src/App.vue
@@ -1,12 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, watch } from 'vue'
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window'
|
||||
import TitleBar from './components/TitleBar.vue'
|
||||
import NavRail from './components/NavRail.vue'
|
||||
import MiniTimer from './views/MiniTimer.vue'
|
||||
import ToastNotification from './components/ToastNotification.vue'
|
||||
import { useSettingsStore } from './stores/settings'
|
||||
import { useTimerStore } from './stores/timer'
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
// Detect mini timer by Tauri window label — no routing needed
|
||||
const isMiniTimer = getCurrentWindow().label === 'mini-timer'
|
||||
|
||||
async function registerShortcuts() {
|
||||
try {
|
||||
@@ -74,18 +78,26 @@ watch(() => [settingsStore.settings.shortcut_toggle_timer, settingsStore.setting
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-full w-full flex flex-col bg-bg-base">
|
||||
<TitleBar />
|
||||
<div class="flex-1 flex overflow-hidden">
|
||||
<NavRail />
|
||||
<main class="flex-1 overflow-auto">
|
||||
<router-view v-slot="{ Component }">
|
||||
<Transition name="page" mode="out-in">
|
||||
<component :is="Component" :key="$route.path" />
|
||||
</Transition>
|
||||
</router-view>
|
||||
</main>
|
||||
</div>
|
||||
<!-- Mini timer: detected by window label, rendered directly (no routing) -->
|
||||
<div v-if="isMiniTimer" class="h-full w-full bg-bg-base">
|
||||
<MiniTimer />
|
||||
</div>
|
||||
<ToastNotification />
|
||||
|
||||
<!-- Normal app shell -->
|
||||
<template v-else>
|
||||
<div class="h-full w-full flex flex-col bg-bg-base">
|
||||
<TitleBar />
|
||||
<div class="flex-1 flex overflow-hidden">
|
||||
<NavRail />
|
||||
<main class="flex-1 overflow-auto">
|
||||
<router-view v-slot="{ Component }">
|
||||
<Transition name="page" mode="out-in" :duration="{ enter: 250, leave: 150 }">
|
||||
<component :is="Component" :key="$route.path" />
|
||||
</Transition>
|
||||
</router-view>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
<ToastNotification />
|
||||
</template>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user