refactor(admin): 替换硬编码 gray/white 为设计 token(login + layout)

- login/page.tsx、admin-layout.tsx 全部 Tailwind gray-* / bg-white / bg-black/50 映射至语义 token
- 深色面板(bg-gray-900/800 激活态、头像、登录按钮)映射 bg-dark-bg / bg-dark-bg-secondary,保持两模式深色
- 深色面板上的文字用 text-dark-text-primary(固定亮色),规避 text-white 在暗黑模式反色为暗的陷阱
- 遮罩 bg-black/50 → bg-overlay/50(独立 token,不随反色)
- 验证: type-check 0 / lint 0 / 产物 CSS 已含全部映射类
This commit is contained in:
2026-08-31 21:38:44 +08:00
parent 70fdb97dd8
commit 860a7f454a
2 changed files with 31 additions and 31 deletions
+20 -20
View File
@@ -139,28 +139,28 @@ export function AdminLayout({ children }: { children: React.ReactNode }) {
};
return (
<div className="min-h-screen bg-gray-50">
<div className="min-h-screen bg-bg-secondary">
{/* Mobile overlay */}
{sidebarOpen && (
<div
className="fixed inset-0 bg-black/50 z-40 lg:hidden"
className="fixed inset-0 bg-overlay/50 z-40 lg:hidden"
onClick={() => setSidebarOpen(false)}
/>
)}
{/* Sidebar */}
<aside
className={`fixed top-0 left-0 z-50 h-full w-64 bg-white border-r border-gray-200 transform transition-transform duration-200 ease-in-out lg:translate-x-0 ${
className={`fixed top-0 left-0 z-50 h-full w-64 bg-bg-primary border-r border-border-primary transform transition-transform duration-200 ease-in-out lg:translate-x-0 ${
sidebarOpen ? 'translate-x-0' : '-translate-x-full'
}`}
>
<div className="flex items-center justify-between h-16 px-4 border-b border-gray-200">
<div className="flex items-center justify-between h-16 px-4 border-b border-border-primary">
<Link href="/admin" className="flex items-center gap-2">
<span className="text-lg font-bold text-gray-900">Novalon CMS</span>
<span className="text-lg font-bold text-text-primary">Novalon CMS</span>
</Link>
<button
onClick={() => setSidebarOpen(false)}
className="lg:hidden p-1 rounded hover:bg-gray-100"
className="lg:hidden p-1 rounded hover:bg-bg-hover"
>
<X className="w-5 h-5" />
</button>
@@ -172,8 +172,8 @@ export function AdminLayout({ children }: { children: React.ReactNode }) {
href="/admin"
className={`flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors ${
pathname === '/admin'
? 'bg-gray-900 text-white'
: 'text-gray-600 hover:bg-gray-100'
? 'bg-dark-bg text-dark-text-primary'
: 'text-text-tertiary hover:bg-bg-hover'
}`}
>
<LayoutDashboard className="w-4 h-4" />
@@ -189,8 +189,8 @@ export function AdminLayout({ children }: { children: React.ReactNode }) {
onClick={() => toggleMenu(group.label)}
className={`flex items-center justify-between w-full px-3 py-2.5 rounded-lg text-sm font-medium transition-colors ${
hasActiveChild
? 'bg-gray-100 text-gray-900'
: 'text-gray-600 hover:bg-gray-100'
? 'bg-bg-hover text-text-primary'
: 'text-text-tertiary hover:bg-bg-hover'
}`}
>
<span className="flex items-center gap-3">
@@ -212,8 +212,8 @@ export function AdminLayout({ children }: { children: React.ReactNode }) {
href={item.href}
className={`flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors ${
isActive(item.href)
? 'bg-gray-900 text-white'
: 'text-gray-500 hover:bg-gray-100'
? 'bg-dark-bg text-dark-text-primary'
: 'text-text-muted hover:bg-bg-hover'
}`}
>
<item.icon className="w-3.5 h-3.5" />
@@ -228,20 +228,20 @@ export function AdminLayout({ children }: { children: React.ReactNode }) {
</nav>
{/* User info */}
<div className="border-t border-gray-200 p-3">
<div className="border-t border-border-primary p-3">
<div className="flex items-center gap-3 px-3 py-2">
<div className="w-8 h-8 rounded-full bg-gray-900 text-white flex items-center justify-center text-sm font-medium">
<div className="w-8 h-8 rounded-full bg-dark-bg text-dark-text-primary flex items-center justify-center text-sm font-medium">
{user?.nickname?.charAt(0) || 'A'}
</div>
<div className="flex-1 min-w-0">
<p className="text-sm font-medium text-gray-900 truncate">
<p className="text-sm font-medium text-text-primary truncate">
{user?.nickname || user?.username}
</p>
<p className="text-xs text-gray-500">{user?.role === 'admin' ? '管理员' : '编辑'}</p>
<p className="text-xs text-text-muted">{user?.role === 'admin' ? '管理员' : '编辑'}</p>
</div>
<button
onClick={handleLogout}
className="p-1.5 rounded hover:bg-gray-100 text-gray-400 hover:text-red-500 transition-colors"
className="p-1.5 rounded hover:bg-bg-hover text-text-muted hover:text-red-500 transition-colors"
title="退出登录"
>
<LogOut className="w-4 h-4" />
@@ -253,10 +253,10 @@ export function AdminLayout({ children }: { children: React.ReactNode }) {
{/* Main content */}
<div className="lg:pl-64">
{/* Top bar */}
<header className="sticky top-0 z-30 h-16 bg-white border-b border-gray-200 flex items-center justify-between px-4 lg:px-6">
<header className="sticky top-0 z-30 h-16 bg-bg-primary border-b border-border-primary flex items-center justify-between px-4 lg:px-6">
<button
onClick={() => setSidebarOpen(true)}
className="lg:hidden p-2 rounded hover:bg-gray-100"
className="lg:hidden p-2 rounded hover:bg-bg-hover"
>
<Menu className="w-5 h-5" />
</button>
@@ -267,7 +267,7 @@ export function AdminLayout({ children }: { children: React.ReactNode }) {
<Link
href="/"
target="_blank"
className="text-sm text-gray-500 hover:text-gray-700 transition-colors"
className="text-sm text-text-muted hover:text-text-secondary transition-colors"
>
查看网站
</Link>