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:
@@ -134,6 +134,28 @@ const currentProjectId = computed(() => {
|
|||||||
|
|
||||||
const timerStore = useTimerStore()
|
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(() => {
|
onMounted(() => {
|
||||||
timerStore.fetchActive()
|
timerStore.fetchActive()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user