fix: avoid login flash during session restore
ci / docker (push) Successful in 3m21s

This commit is contained in:
2026-09-06 10:47:31 +08:00
parent 4c93d0e1f8
commit d21c6629ba
4 changed files with 14 additions and 7 deletions
+9 -2
View File
@@ -18,6 +18,7 @@ type Task = { id: string; list_id: string; parent_id: string | null; title: stri
type View = 'tasks' | 'today' | 'upcoming' | 'trash' | 'habits' | 'calendar' | 'settings'
const initialized = ref<boolean | null>(null)
const authReady = ref(false)
const authenticated = ref(false)
const username = ref('')
const password = ref('')
@@ -111,6 +112,7 @@ function toast(message: string) {
function fail(reason: unknown) { error.value = reason instanceof Error ? reason.message : '请求失败' }
async function bootstrap() {
authReady.value = false
try {
const status = await api('/setup/status')
initialized.value = status.initialized
@@ -125,7 +127,12 @@ async function bootstrap() {
expandedFolders.value = new Set(folders.value.map((folder) => folder.id))
await loadAll()
}
} catch { authenticated.value = false; initialized.value ??= true }
} catch {
authenticated.value = false
initialized.value ??= true
} finally {
authReady.value = true
}
}
async function submitAuth() {
error.value = ''
@@ -382,7 +389,7 @@ onMounted(bootstrap)
</script>
<template>
<div v-if="initialized === null" class="center"><span class="loader" />正在打开 dodo</div>
<div v-if="!authReady" class="center"><span class="loader" />正在打开 dodo</div>
<div v-else-if="!authenticated" class="auth-shell">
<section class="auth-card">
<div class="brand">do<span>do</span></div><p>{{ initialized ? '欢迎回来,继续把生活理顺。' : '创建你的 dodo' }}</p>