diff --git a/app/server/public/index.html b/app/server/public/index.html index c3fb852..3784496 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -1987,20 +1987,22 @@ setTitle('账户'); setActions(''); setBody('
加载中…
'); + // 单个 /api/me 即可判认证开关:启用认证时中间件保证已登录,user 必有; + // 未启用时 createAuth 提前返回,该路由不存在 → 404。无需再拉 /api/system/status + let me; try { - const [st, me] = await Promise.all([ - req('GET', '/api/system/status'), - req('GET', '/api/me').catch(function () { return { user: null }; }), // 未启用认证时无此路由 - ]); - if (!ctx()) return; - if (!st.auth_enabled || !me || !me.user) { - setBody('
未启用登录认证,无账户设置。
'); - return; - } - setBody('
' + userCardHtml(me.user) + '
'); + me = await req('GET', '/api/me'); } catch (e) { - if (ctx()) setBody('
加载失败:' + esc(e.message) + '
'); + if (ctx()) setBody('
' + + (e.status === 404 ? '未启用登录认证,无账户设置。' : '加载失败:' + esc(e.message)) + '
'); + return; } + if (!ctx()) return; + if (!me || !me.user) { + setBody('
未启用登录认证,无账户设置。
'); + return; + } + setBody('
' + userCardHtml(me.user) + '
'); } async function changePassword() { try {