用中性灰底 + 单一强调色重做后台视觉,并集中到一套令牌: - 新增 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。
97 lines
2.8 KiB
TypeScript
97 lines
2.8 KiB
TypeScript
import { Input, InputNumber, Select, Switch } from "antd";
|
|
import type { TemplateAdminField } from "@personal-brand/api-client";
|
|
import { ImageUrlField } from "./ImageUrlField.js";
|
|
|
|
export function TemplateFieldRenderer({
|
|
field,
|
|
id,
|
|
value,
|
|
onChange,
|
|
}: {
|
|
field: TemplateAdminField;
|
|
id?: string;
|
|
value?: unknown;
|
|
onChange?: (value: unknown) => void;
|
|
}) {
|
|
if (field.input === "textarea")
|
|
return (
|
|
<Input.TextArea
|
|
{...(id ? { id } : {})}
|
|
value={typeof value === "string" ? value : ""}
|
|
onChange={(event) => onChange?.(event.target.value)}
|
|
rows={3}
|
|
maxLength={field.maxLength}
|
|
showCount={!!field.maxLength}
|
|
placeholder={field.placeholder}
|
|
/>
|
|
);
|
|
if (field.input === "image")
|
|
return (
|
|
<ImageUrlField
|
|
{...(id ? { id } : {})}
|
|
{...(field.placeholder ? { placeholder: field.placeholder } : {})}
|
|
{...(typeof value === "string" ? { value } : {})}
|
|
{...(onChange ? { onChange: (next: string) => onChange(next) } : {})}
|
|
/>
|
|
);
|
|
if (field.input === "phone")
|
|
return (
|
|
<Input
|
|
{...(id ? { id } : {})}
|
|
type="tel"
|
|
placeholder={field.placeholder}
|
|
value={typeof value === "string" ? value : ""}
|
|
onChange={(event) => onChange?.(event.target.value)}
|
|
/>
|
|
);
|
|
if (field.input === "number")
|
|
return (
|
|
<InputNumber
|
|
{...(id ? { id } : {})}
|
|
value={typeof value === "number" ? value : null}
|
|
onChange={(input) => onChange?.(input ?? undefined)}
|
|
min={0}
|
|
className="admin-block"
|
|
placeholder={field.placeholder}
|
|
/>
|
|
);
|
|
if (field.input === "boolean")
|
|
return (
|
|
<Switch
|
|
{...(id ? { id } : {})}
|
|
checked={Boolean(value)}
|
|
onChange={(checked) => onChange?.(checked)}
|
|
/>
|
|
);
|
|
if (field.input === "select")
|
|
return (
|
|
<Select
|
|
{...(id ? { id } : {})}
|
|
options={(field.options ?? []).map((item) => ({ ...item }))}
|
|
value={typeof value === "string" || typeof value === "number" ? value : undefined}
|
|
onChange={(selected) => onChange?.(selected)}
|
|
{...(field.placeholder ? { placeholder: field.placeholder } : {})}
|
|
/>
|
|
);
|
|
if (field.input === "multi-select")
|
|
return (
|
|
<Select
|
|
{...(id ? { id } : {})}
|
|
mode="multiple"
|
|
options={(field.options ?? []).map((item) => ({ ...item }))}
|
|
value={Array.isArray(value) ? value.map(String) : []}
|
|
onChange={(selected) => onChange?.(selected)}
|
|
placeholder={field.placeholder}
|
|
/>
|
|
);
|
|
return (
|
|
<Input
|
|
{...(id ? { id } : {})}
|
|
value={typeof value === "string" ? value : ""}
|
|
onChange={(event) => onChange?.(event.target.value)}
|
|
maxLength={field.maxLength}
|
|
placeholder={field.placeholder}
|
|
/>
|
|
);
|
|
}
|