feat(time-tracking) : show real-time timer in browser tab title

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 23:30:10 +01:00
parent c15a10b36f
commit 7ee1be63b3

View File

@@ -134,6 +134,28 @@ const currentProjectId = computed(() => {
const timerStore = useTimerStore()
const baseTitle = ref('Lesstime')
useHead({
titleTemplate: (title) => {
baseTitle.value = title || 'Lesstime'
return title || 'Lesstime'
},
})
watch(
[() => timerStore.elapsedFormatted, () => timerStore.isRunning, () => timerStore.activeEntry?.title],
([elapsed, running, label]) => {
if (import.meta.server) return
const base = baseTitle.value
if (running) {
document.title = label ? `${base} | ${elapsed} · ${label}` : `${base} | ${elapsed}`
} else {
document.title = base
}
},
)
onMounted(() => {
timerStore.fetchActive()
})