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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,3 +1,3 @@
<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta name="theme-color" content="#f15a29"><link rel="manifest" href="/manifest.json"><title>dodo</title> <script type="module" crossorigin src="/assets/index-DqfzvhAi.js"></script> <!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta name="theme-color" content="#f15a29"><link rel="manifest" href="/manifest.json"><title>dodo</title> <script type="module" crossorigin src="/assets/index-BhF1FT2t.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CDrLYTXE.css"> <link rel="stylesheet" crossorigin href="/assets/index-CDrLYTXE.css">
</head><body><div id="app"></div></body></html> </head><body><div id="app"></div></body></html>
+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' type View = 'tasks' | 'today' | 'upcoming' | 'trash' | 'habits' | 'calendar' | 'settings'
const initialized = ref<boolean | null>(null) const initialized = ref<boolean | null>(null)
const authReady = ref(false)
const authenticated = ref(false) const authenticated = ref(false)
const username = ref('') const username = ref('')
const password = ref('') const password = ref('')
@@ -111,6 +112,7 @@ function toast(message: string) {
function fail(reason: unknown) { error.value = reason instanceof Error ? reason.message : '请求失败' } function fail(reason: unknown) { error.value = reason instanceof Error ? reason.message : '请求失败' }
async function bootstrap() { async function bootstrap() {
authReady.value = false
try { try {
const status = await api('/setup/status') const status = await api('/setup/status')
initialized.value = status.initialized initialized.value = status.initialized
@@ -125,7 +127,12 @@ async function bootstrap() {
expandedFolders.value = new Set(folders.value.map((folder) => folder.id)) expandedFolders.value = new Set(folders.value.map((folder) => folder.id))
await loadAll() await loadAll()
} }
} catch { authenticated.value = false; initialized.value ??= true } } catch {
authenticated.value = false
initialized.value ??= true
} finally {
authReady.value = true
}
} }
async function submitAuth() { async function submitAuth() {
error.value = '' error.value = ''
@@ -382,7 +389,7 @@ onMounted(bootstrap)
</script> </script>
<template> <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"> <div v-else-if="!authenticated" class="auth-shell">
<section class="auth-card"> <section class="auth-card">
<div class="brand">do<span>do</span></div><p>{{ initialized ? '欢迎回来,继续把生活理顺。' : '创建你的 dodo' }}</p> <div class="brand">do<span>do</span></div><p>{{ initialized ? '欢迎回来,继续把生活理顺。' : '创建你的 dodo' }}</p>