diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index 4a64e5a..d65f6fc 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -356,11 +356,17 @@ body { .model-card-meta { font-size: 12px; color: #888; margin-top: 4px; } /* ---- 设置页行 ---- */ -.settings-row { - display: flex; align-items: center; justify-content: space-between; gap: 10px; - background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; - box-shadow: 0 1px 4px rgba(30,40,90,0.06); font-size: 14px; +/* 设置页顶部用户卡:头像在上,用户名居中,下方等宽双按钮 */ +.user-card { display: flex; flex-direction: column; align-items: center; padding: 20px 16px 16px; } +.user-avatar { + width: 64px; height: 64px; border-radius: 50%; border: none; + color: #fff; font-size: 26px; font-weight: 600; letter-spacing: 1px; + display: flex; align-items: center; justify-content: center; + box-shadow: 0 2px 6px rgba(30, 40, 90, 0.18); user-select: none; } +.user-name { margin-top: 10px; font-size: 16px; font-weight: 600; color: #223; word-break: break-all; text-align: center; } +.user-acts { display: flex; gap: 10px; width: 100%; max-width: 360px; margin-top: 14px; } +.user-acts .ghost-btn { flex: 1; } .ghost-btn.small { flex: none; padding: 6px 12px; font-size: 13px; border-radius: 8px; } /* ---- 技能页(阶段 3) ---- */ diff --git a/app/server/public/index.html b/app/server/public/index.html index 68ad38b..48fbb9c 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -96,10 +96,6 @@
-
- 当前用户: - -
加载中…
@@ -286,10 +282,10 @@ - - - - - + + + + + diff --git a/app/server/public/js/settings.js b/app/server/public/js/settings.js index c88328b..ae9b240 100644 --- a/app/server/public/js/settings.js +++ b/app/server/public/js/settings.js @@ -57,17 +57,35 @@ function kvPlain(label, v) { return '
' + esc(dispVal(v)) + '
'; } -// 账号卡(仅启用认证时显示):当前登录 + 修改密码(prompt 弹窗,免原密码,立即生效) -function accountCard(me) { - return '

账号

' + - kvPlain('当前登录', me) + - '' + - '
修改立即生效并写回 config.yml;其他已登录设备需重新登录时才用新密码。
'; +// 用户信息卡(仅启用认证时显示,页面顶部):Google 风双字母头像 + 用户名 + 操作按钮。 +// 头像字母/配色均前端本地生成,无外部依赖。 +const AVATAR_COLORS = ['#4285F4', '#EA4335', '#FBBC05', '#34A853', '#5C6BC0', '#00897B', '#8E24AA', '#F4511E']; + +// 取用户名前两个字符:首字母大写、次字母小写(kicer→Ki);单字符只显一个; +// 中文取前两字,charAt 大小写对汉字无副作用,无需特判 +function userInitials(name) { + const s = String(name || '').trim(); + if (!s) return '?'; + const two = s.slice(0, 2); + return two.charAt(0).toUpperCase() + (two.length > 1 ? two.charAt(1).toLowerCase() : ''); +} +function avatarColor(name) { + let h = 0; + for (const ch of String(name || '')) h = (h * 31 + ch.codePointAt(0)) >>> 0; + return AVATAR_COLORS[h % AVATAR_COLORS.length]; +} + +function userCard(me) { + return '
' + + '
' + esc(userInitials(me)) + '
' + + '
' + esc(me) + '
' + + '
' + + '' + + '' + + '
'; } async function changePassword() { - const btn = $('pwd-btn'); - if (btn) btn.disabled = true; try { const newP = await promptModal('修改密码', '新密码,至少 6 位', '', { type: 'password' }); if (newP == null) return; @@ -76,8 +94,6 @@ async function changePassword() { toast('密码已修改,立即生效'); } catch (e) { toast('修改失败:' + e.message); - } finally { - if (btn) btn.disabled = false; } } @@ -121,7 +137,6 @@ function formCard() { } async function loadSettings() { - refreshUser(); bindDirtyMark(); const el = $('cfg-sections'); if (!el) return; @@ -133,26 +148,12 @@ async function loadSettings() { req('GET', '/api/me').catch(function () { return { user: null }; }), // 未启用认证时无此路由 ]); effCfg = cg.effective || {}; - el.innerHTML = (st.auth_enabled && me && me.user ? accountCard(me.user) : '') + svcCard(st) + formCard(); + el.innerHTML = (st.auth_enabled && me && me.user ? userCard(me.user) : '') + svcCard(st) + formCard(); } catch (e) { el.innerHTML = '
加载失败:' + esc(e.message) + '
'; } } -// 显示登录用户(沿用 1.0 逻辑;未启用认证时静默跳过) -async function refreshUser() { - try { - const me = await req('GET', '/api/me'); - const who = $('whoami'); - if (who && me && me.user) { - who.textContent = me.user; - who.classList.remove('hidden'); - } - const out = $('logout-btn'); - if (out) out.classList.toggle('hidden', !(me && me.user)); - } catch (_) { /* 未启用认证 */ } -} - // 未保存改动标红:委托监听(#cfg-sections 容器常驻,innerHTML 重建不影响) let dirtyBound = false; function bindDirtyMark() {