feat: 统一 Admin 后台设计语言

用中性灰底 + 单一强调色重做后台视觉,并集中到一套令牌:

- 新增 apps/admin/src/lib/theme.ts,通过 ConfigProvider 注入主题令牌
- 新增 apps/admin/src/styles/admin.css 与 AdminSection、MetricCard、StatusTag 组件
- 侧栏改白底浅色并补图标,顶栏改 56px 白底,内容区最大宽 1200px
- 全部页面接入状态标签,antd 原生彩色 Tag 与内联色值清零
- 登录与改密页、加载态骨架屏、错误提示条统一
- brand 页两个 Tab 统一为白卡片容器,消除双标题与宽度不一致

设计规范见 apps/admin/design.md。
This commit is contained in:
que01 committed 2026-10-14 10:54:05 +08:00
1 parent bb94d80e13
commit 2f26828f09
34 files changed
+2159 -922

No files matched your search

@@ -1,7 +1,9 @@
import { useEffect, useRef } from "react";
import { Alert, Button, Card, Collapse, Flex, Space, Tag, Tooltip, Typography, theme } from "antd";
import { LoadingOutlined } from "@ant-design/icons";
import { Button, Card, Collapse, Flex, Space, Tooltip, Typography } from "antd";
import type { MiniAppReleaseTask } from "@personal-brand/api-client";
import { ErrorNote } from "../../components/QueryState.js";
import { StatusTag } from "../../components/StatusTag.js";
import type { StatusTone } from "../../components/StatusTag.js";
type ReleaseStatus = MiniAppReleaseTask["status"];
@@ -13,18 +15,18 @@ function isStaleBuilding(task: MiniAppReleaseTask): boolean {
return !Number.isNaN(updatedAt) && Date.now() - updatedAt >= STALE_BUILDING_MS;
}
const statusView: Record<ReleaseStatus, { label: string; color: string; hint: string }> = {
built: { label: "待上传", color: "default", hint: "代码已构建,可上传到微信。" },
uploaded: { label: "已上传微信", color: "blue", hint: "请在微信后台上传体验版并提交审核。" },
const statusView: Record<ReleaseStatus, { label: string; tone: StatusTone; hint: string }> = {
built: { label: "待上传", tone: "neutral", hint: "代码已构建,可上传到微信。" },
uploaded: { label: "已上传微信", tone: "info", hint: "请在微信后台上传体验版并提交审核。" },
under_review: {
label: "审核中",
color: "processing",
tone: "warning",
hint: "等待微信审核结果,通过后回到本页标记。",
},
approved: { label: "审核通过", color: "cyan", hint: "审核已通过,确认无误后标记为已发布。" },
published: { label: "已发布", color: "green", hint: "该版本已发布,可继续编辑内容后再次上传。" },
rejected: { label: "已驳回", color: "volcano", hint: "微信驳回后需修改内容并重新构建上传。" },
failed: { label: "失败", color: "red", hint: "上次构建或上传失败,可直接重试。" },
approved: { label: "审核通过", tone: "success", hint: "审核已通过,确认无误后标记为已发布。" },
published: { label: "已发布", tone: "success", hint: "该版本已发布,可继续编辑内容后再次上传。" },
rejected: { label: "已驳回", tone: "error", hint: "微信驳回后需修改内容并重新构建上传。" },
failed: { label: "失败", tone: "error", hint: "上次构建或上传失败,可直接重试。" },
};
function formatTime(value: string): string {
@@ -50,7 +52,6 @@ export function MiniAppReleaseCard({
onUpload: () => void;
onStatusChange: (status: ReleaseStatus) => void;
}) {
const { token } = theme.useToken();
const logRef = useRef<HTMLPreElement>(null);
const logs = task.buildLogs ?? [];
const status = statusView[task.status];
@@ -104,72 +105,49 @@ export function MiniAppReleaseCard({
<Space direction="vertical" size={4}>
<Space wrap size={8} align="center">
<Typography.Text strong>品牌内容 v{task.version}</Typography.Text>
<Tag color={status.color}>{status.label}</Tag>
<StatusTag label={status.label} tone={status.tone} />
{building && (
<Tag icon={<LoadingOutlined />} color="orange">
{staleBuilding ? "构建已中断" : "构建中"}
</Tag>
<StatusTag tone="warning" label={staleBuilding ? "构建已中断" : "构建中"} />
)}
{task.weappUploadId && (
<Typography.Text type="secondary">微信版本 {task.weappUploadId}</Typography.Text>
)}
</Space>
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
<span className="admin-text-xs">
{staleBuilding ? "超过 15 分钟没有新的构建输出,可能已中断;可直接重试。" : status.hint}
</Typography.Text>
</span>
<Tooltip title={`创建于 ${formatTime(task.createdAt)}`}>
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
更新于 {formatTime(task.updatedAt)}
</Typography.Text>
<span className="admin-text-xs-quiet">更新于 {formatTime(task.updatedAt)}</span>
</Tooltip>
</Space>
{actions}
</Flex>
{task.error && <Alert type="error" showIcon message={task.error} style={{ marginTop: 12 }} />}
{task.error && (
<div className="admin-offset-top-md">
<ErrorNote error={new Error(task.error)} />
</div>
)}
{logs.length > 0 && (
<Collapse
ghost
size="small"
style={{ marginTop: 8 }}
className="admin-offset-top-sm"
{...(building || task.buildStatus === "failed" ? { defaultActiveKey: ["logs"] } : {})}
items={[
{
key: "logs",
label: (
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
构建日志({logs.length} 行)
</Typography.Text>
),
label: <span className="admin-text-xs">构建日志({logs.length} 行)</span>,
children: (
<pre
ref={logRef}
style={{
margin: 0,
padding: 12,
maxHeight: 220,
overflow: "auto",
fontSize: 12,
lineHeight: 1.7,
borderRadius: token.borderRadius,
border: `1px solid ${token.colorBorderSecondary}`,
background: token.colorFillQuaternary,
}}
>
<pre ref={logRef} className="admin-log">
{logs.map((log, index) => (
<div
key={`${log.at}-${index}`}
style={{
color:
log.stream === "stderr" ? token.colorError : token.colorTextSecondary,
whiteSpace: "pre-wrap",
wordBreak: "break-all",
}}
className="admin-log__line"
data-stream={log.stream}
>
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
{formatLogTime(log.at)}
</Typography.Text>
<span className="admin-log__time">{formatLogTime(log.at)}</span>
{" "}
{log.message}
</div>