检查点:布局层迁入 antd 原生(Panel/Controls/grid/Input + app.css 清理)
parent
5f294c9ccb
commit
5ce8f4a207
27
docs/UI规范.md
27
docs/UI规范.md
|
|
@ -48,7 +48,7 @@
|
|||
| 层 | 唯一来源 | 管什么 | 不管什么 |
|
||||
|---|---|---|---|
|
||||
| **尺子 + 控件皮肤** | **antd 5 默认 token**(`controlHeight` 32 / SM 24 / LG 40;`fontSize` 12 / 14 / 16;`borderRadius` 6 / 8 / 4;`margin*` `padding*`;断点 576/768/992/1200/1600;动效与阴影) | 一切「控件长什么样、多大」 | 业务布局 |
|
||||
| **主题覆盖** | `theme/antd.ts` 的 `buildAntdTheme(mode)`(全站唯一 `ThemeConfig`) | **只改三类**:① 品牌色(dark `#a0d911` / light `#5b8c00`)② 表面色(layout/container/elevated/描边)③ 少量结构性 ComponentToken(Menu 选中态、Table 表头与分割线、Layout、Drawer 等) | 尺寸档位、圆角、字号——**一个都不覆盖** |
|
||||
| **主题覆盖** | `theme/antd.ts` 的 `buildAntdTheme(mode)`(全站唯一 `ThemeConfig`) | **只改两类**:① 表面色(layout/container/elevated/描边/外壳三段)② 少量结构性 ComponentToken(Menu 密度与选中态、Table 表头与分割线、Layout、Drawer 等)。**品牌色不改**:`SEED` 里没有 `colorPrimary`,主色就是 antd 出厂蓝(light `#1677ff` / dark `#1668dc`) | 尺寸档位、圆角、字号、主色与它的整条派生梯度——**一个都不覆盖** |
|
||||
| **变量落地** | `theme/antd.ts::applyRootVars()`(`stores/theme.ts` 在切主题时调用) | 把 antd 落不下来的 token 手写到 `<html>` 上:`color*`、`borderRadius*`、`boxShadow*`、`fontFamily/Size/Weight`、`lineHeight*`、`controlHeight*`、`margin*`、`padding*`、`screen*`;末尾追加派生变量 `--nex-bar` | 新增私有数字(它只做转发) |
|
||||
| **布局** | `styles/app.css`(`.nex-*` / `.nf-*` 语义类)+ Tailwind utility | 字段栅格、控件栏、chip 行、标签组、抽屉三段、滚动区、浮层层级;**全站唯一允许出现 `.ant-*` 选择器的地方** | 控件本体 |
|
||||
| **语义** | `components/ui/` `components/forms/` | `Field` `FormRow` `Select` `Check` `Slider` `Button` `Menu` `Drawer` `Modal` `Table` `Tag` `Status`… 这些页面认识的名字(导出名与旧版一致,473 处 import 没动) | 直接 `import 'antd'`(R8) |
|
||||
|
|
@ -142,11 +142,26 @@ CSS 层叠规则是「未分层样式永远赢过分层样式,与选择器特
|
|||
| 描边 | `border-border` / `border-border-secondary` / `border-split` | `--ant-color-border*` `--ant-color-split` |
|
||||
| 填充(压在表面上的灰) | `bg-fill` `-secondary` `-tertiary` `-quaternary` | `--ant-color-fill*` |
|
||||
|
||||
- 明暗两套都只覆盖 `colorPrimary` / `colorLink` / 表面 / 描边 + 少数组件 token;
|
||||
状态色、文字四级、填充四级全部交还 antd 算法(`colorInfo` 跟随 `colorPrimary`)。
|
||||
- **深色菜单选中态必须显式给**:antd 默认把 `colorPrimaryBg` 压在深底上会变成一大块灰绿、
|
||||
文字只剩 `colorPrimary`,对比度一起塌。两套主题各给一档半透明主色底
|
||||
(dark `bg rgba(160,217,17,.14)` / 文字 `#b7e35f`;light `#f0f7e2` / 文字 `#4f7d00`)。
|
||||
- **主色不覆盖,而且覆盖不回来**:`SEED` 里写 `colorPrimary: '#1668dc'`(dark 的出厂值)
|
||||
量到的却是 `#165bbe`——`darkAlgorithm` 会把手上的 seed 再走一遍色板生成器并取第 5 档,
|
||||
所以「填出厂值」≠「不填」。**要出厂蓝就只能删掉覆盖**(`visualcheck.py` 按
|
||||
`--ant-color-primary` = `#1677ff` / `#1668dc` 断言,写回任何值都会红)。
|
||||
`colorLink` / `colorInfo` / `colorTextLightSolid` 同理全部不写:默认就等于 `colorPrimary` / 白字。
|
||||
- **绿只表示状态,不表示可点**:`success` 一族只做「完成 / 合格 / 正常」(`Tag tone="ok"`、
|
||||
流程 `done`、`micOk`);链接、选中态、命中底纹、动作胶囊一律 `primary`。
|
||||
上一版主色是柠檬绿时两者同色,于是 `LINK_CLS`、`Tile` 命中态、`Stat` active、
|
||||
分镜卡片灯带都借了 `text-success` / `border-success-border`——标准蓝之下必须拆开,
|
||||
否则浅蓝底纹压绿描边,一块东西两种色相。口径:**一档一色,描边与底纹同族**
|
||||
(绿边配 `bg-success-bg`、红边配 `bg-error-bg`、琥珀边配 `bg-warning-bg`)。
|
||||
- **深色菜单选中态必须显式给,但给的是 antd 自己的那一组**:侧栏两套主题都渲染
|
||||
`theme="light"` 的 Menu(见 `AppSider` 注释),深色下拿到的是 light 菜单默认的
|
||||
`controlItemBgActive` + `colorPrimary`,实测 `#15325b` 底 + `#1668dc` 字 = **2.2:1**,
|
||||
选中项比未选中还弱。这里补上 antd dark 菜单的默认对:
|
||||
`itemSelectedBg = colorPrimary(#1668dc)` 实心块 + `itemSelectedColor = #fff`(**6.4:1**),
|
||||
按下态取 `colorPrimaryActive(#1554ad)`。浅色什么都不写——`#e6f4ff` + `#1677ff` 就是 antd 官网侧栏。
|
||||
- 表面色(dark `#0d1117 / #141b23 / #1a232c`、light `#f0f4f8 / #ffffff`)与三个状态色的
|
||||
深浅档保留覆盖:前者是中性冷灰、不是品牌色,深色工作台要靠它分外壳与内容;
|
||||
后者取的都是 `@ant-design/colors` 现成色板的档位,只调明度不改语义。
|
||||
- 字面量 `#hex` / `rgb()` 只允许出现在 `theme/antd.ts` 里;`#fff` / `#000` 作为
|
||||
`--color-white` / `--color-black` 登记过,可用于压在图片上的描边与角标。
|
||||
- 旧的 `--c-*` / `--fs-*` / `accent-deep` / `ink-*` / `panel` / `faint` / `line` 全部作废
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,20 @@
|
|||
import React from 'react'
|
||||
import { renderToString } from 'react-dom/server'
|
||||
import { StyleProvider, createCache, extractStyle } from '@ant-design/cssinjs'
|
||||
import { Form, Input, ConfigProvider } from 'antd'
|
||||
|
||||
// 只渲染【没有 Form 包裹】的 Form.Item,看 vertical 样式是否存在
|
||||
const App = () => (
|
||||
<ConfigProvider theme={{ cssVar: true, hashed: false }}>
|
||||
<Form.Item label="孤立字段" layout="vertical" style={{ width: 128 }}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</ConfigProvider>
|
||||
)
|
||||
const cache = createCache()
|
||||
renderToString(<StyleProvider cache={cache}><App /></StyleProvider>)
|
||||
const css = String(extractStyle(cache, { plain: true } as never))
|
||||
console.log('len', css.length)
|
||||
const hits = css.replace(/\s+/g, ' ').split('}').filter(r => /-vertical/.test(r))
|
||||
console.log('vertical rules:', hits.length)
|
||||
console.log(hits.slice(0, 6).join('\n}\n'))
|
||||
|
|
@ -30,10 +30,10 @@ export type SecretInputProps = {
|
|||
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'id' | 'placeholder' | 'disabled' | 'className'>
|
||||
|
||||
/**
|
||||
* 注意:这里不能给输入框套一层 <span>。字段栅格的对齐靠 `.nf-ctl > .ant-input-affix-wrapper
|
||||
* 注意:这里不能给输入框套一层 <span>。字段栅格的对齐靠 `Form.Item` 控件列里的 `.ant-input-affix-wrapper
|
||||
* { width: 100% }` 命中「直接子元素」,套一层 inline span 后选择器落空,
|
||||
* 密码框只有内容那么宽(实测 151px 而同行其它控件 359px),控件右边界就歪了。
|
||||
* 所以错误提示用 Fragment 平铺成第二个子元素,DOM 里控件始终是 .nf-ctl 的亲儿子。
|
||||
* 所以错误提示用 Fragment 平铺成第二个子元素,DOM 里控件始终是 .ant-form-item-control-input-content 的亲儿子。
|
||||
*
|
||||
* ref 契约(R10):页面要的是 <input> 本体,而 `Input.Password` 的 ref 是 antd 的 `InputRef`
|
||||
* (`{ nativeElement, focus(), blur(), select() … }`)。原先直接把 outerRef 转交给它,
|
||||
|
|
|
|||
|
|
@ -1,36 +1,42 @@
|
|||
/**
|
||||
* 控件栏与字段体系(docs/UI规范.md §1~§5 的唯一实现)。
|
||||
* 布局层:表单、工具条、筛选行(Ant Design Form·Row·Col·Flex·Tag 的唯一封装)。
|
||||
*
|
||||
* 症状(用户截图里那些):筛选栏 / 抽屉字段「标签在上、控件在下」,一个字段吃掉整行;
|
||||
* 同一行搜索框 38、下拉 31、复选框 16,中心线各走各的;标签列宽随中文标题字数漂移。
|
||||
* 做法:布局与档位只在这几个组件里定义,页面只给内容——
|
||||
* <Ctlbar> 含控件的横条:一行、垂直居中、紧凑档、下边距 12
|
||||
* <Field> 标签在左、控件在右的字段(标签列宽由容器统一给)
|
||||
* <FieldBlock> 标签在上的长字段
|
||||
* <FormGrid> 表单作用域:列边界 + 标签列宽只在这里定义一次(12 等分)
|
||||
* <FormRow> 表单里的一行(cols = 这行几个字段)
|
||||
* <ChipBar> 可点筛选胶囊行
|
||||
* 症状(2026-11 第二轮重写的对象):第一轮只换了原子控件,**字段与排布仍是自绘**——
|
||||
* `.nex-field` 用 CSS Grid 把标签摆到控件左边,标签列宽靠私有变量 `--label-w`,
|
||||
* `FormGrid`/`FormRow` 又各自一套 12 等分轨道。结果是资产库抽屉里
|
||||
* 「标签在左」的三列字段和「标签在上」的长字段混排:列边界参差、
|
||||
* 只有一个字段的行把输入框缩成一小截、`TEXTAREA_TALL` 把 rows=2 撑到 150px。
|
||||
* 用户说的「布局还是不对」,病根全在这三个文件级的自绘栅格里。
|
||||
* 做法:**字段就是 antd Form.Item,标签一律在上(layout="vertical")**。
|
||||
* 已验证 antd 5.29 会为一个孤立的 `Form.Item layout="vertical"` 生成
|
||||
* `.ant-form-item-vertical` 的完整样式(不需要外层 `<Form>`),
|
||||
* 所以全站只有一种字段形态,抽屉、对话框、工具条共用同一条标签基线,
|
||||
* 「对齐」这件事交还给 antd 的表单栅格,私有变量整层删除。
|
||||
* <Ctlbar> 含字段的横条 = Dense + Flex(align=end, wrap)
|
||||
* <FormGrid> 表单作用域(只管标记类名,间距由 Form.Item 自己给)
|
||||
* <FormRow> 表单里的一行 = Row + Col(断点沿用 antd Grid,见 grid.tsx)
|
||||
* <ChipBar> 可点筛选行 = Flex + Tag.CheckableTag
|
||||
* <Pager> 分页条(page_size 唯一的家)
|
||||
* <Check> <FilePick> 复选、文件选择
|
||||
* 高度不写在控件上:紧凑容器只做一件事——<ConfigProvider componentSize="small"> 下发 antd 的
|
||||
* 第二档;自绘的那几处(chip、checkable tag)读同一个 --ant-control-height[-sm],两条路同一个数。
|
||||
* 高度不写在控件上:紧凑容器只做一件事——`<ConfigProvider componentSize="small">`
|
||||
* 下发 antd 第二档;自绘的那几处读同一个 `--ant-control-height[-sm]`,两条路同一个数。
|
||||
*/
|
||||
import { createContext, useContext, type ReactNode } from 'react'
|
||||
import { ConfigProvider, Checkbox as AntCheckbox, Pagination } from 'antd'
|
||||
import type { CSSProperties, ReactNode } from 'react'
|
||||
import { ConfigProvider, Checkbox as AntCheckbox, Flex, Form, Pagination, Radio as AntRadio, Row, Tag, Typography } from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Button } from './Button'
|
||||
import { Select } from '../forms/Select'
|
||||
import { fieldGroupLabelCls, LABEL_CLS } from './field-labels'
|
||||
import { IconClose } from '../icons'
|
||||
import { colSpans, toCols, type GridStep } from './grid'
|
||||
|
||||
export { LABEL_CLS }
|
||||
/** 分组说明(ChipBar / TagGroup 行首那句「筛选:」):全站只此一种小标签字 */
|
||||
export const GROUP_LABEL_CLS = 'text-xs text-text-tertiary'
|
||||
|
||||
/**
|
||||
* 紧凑档作用域:工具条 / 分页条 / 卡片动作行里所有 antd 控件降一档
|
||||
* (antd 自己的第二档 controlHeightSM = 24)。页面不需要、也不准再给单个控件写 size。
|
||||
*
|
||||
* 除了下发 ConfigProvider,还落下一个 .nex-dense 类名:自绘的东西(chip)
|
||||
* 不在 antd 的组件树里,读不到 componentSize,只能靠这个标记对齐到同一个 token。
|
||||
* 除了下发 ConfigProvider,还落下一个 .nex-dense 类名:自绘的东西(checkable tag 的
|
||||
* 高度)不在 antd 的组件树里,读不到 componentSize,只能靠这个标记对齐到同一个 token。
|
||||
*/
|
||||
export function Dense({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return (
|
||||
|
|
@ -40,32 +46,37 @@ export function Dense({ children, className }: { children: ReactNode; className?
|
|||
)
|
||||
}
|
||||
|
||||
/** 含控件的横条:一行垂直居中,标签挨着控件(--label-w 压回 0) */
|
||||
export function Ctlbar({ children, className, as: As = 'div' }: {
|
||||
children: ReactNode; className?: string; as?: any
|
||||
/**
|
||||
* 含字段的横条:一行垂直居中(准确说垂直**贴底**——标签在上以后,
|
||||
* 只有底边对齐才能让不同高度的字段共用一条控件基线),紧凑档,下边距 12。
|
||||
* 字段在这里不带下边距(`.nex-ctlbar .ant-form-item` 归零,见 app.css)。
|
||||
*/
|
||||
export function Ctlbar({ children, className, as = 'div' }: {
|
||||
children: ReactNode; className?: string; as?: 'div' | 'nav' | 'section'
|
||||
}) {
|
||||
return (
|
||||
<Dense className={cn('nex-ctlbar', className)}>
|
||||
<As className="nex-ctlbar-inner">{children}</As>
|
||||
<Dense className="contents">
|
||||
<Flex component={as} wrap align="end" gap={8} className={cn('nex-ctlbar min-w-0', className)}>
|
||||
{children}
|
||||
</Flex>
|
||||
</Dense>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡片 / 列表行 / 抽屉段落末尾的动作行:布局同 Ctlbar,但不带 12px 下边距。
|
||||
* 卡片 / 列表行 / 抽屉段落末尾的动作行:横排、换行、间距 8,档位由容器下发(24)。
|
||||
*
|
||||
* 【为什么这里有两次导出】历史上同一一种行有两把尺子:`Panel.Actions` 不包 Dense
|
||||
* (里面的按钮全是 md 32),`Controls.CardActions` 包了 Dense(全是 sm 24)。
|
||||
* 页面在 Actions 里又习惯给按钮补 `size="sm"`,于是素材墙一张卡片底下
|
||||
* 「AI 生成」24、「上传」32、「删除」又是 32——用户说的「控件不对齐」就是这么来的。
|
||||
* 现在只有一个实现:**动作行的档位由容器下发(§7:卡片动作行 = controlHeightSM = 24)**,
|
||||
* 页面既不用、也不准再给行里的单个控件写 size。
|
||||
* `Actions` 是它的旧名字(带 mt-2 的段落间距),27 处调用零改动。
|
||||
* 【为什么这里曾有两个实现】历史上 `Panel.Actions` 不包 Dense(按钮全 md 32)、
|
||||
* `CardActions` 包了 Dense(全 sm 24),页面又在 Actions 里补 size="sm",
|
||||
* 于是素材墙一张卡底下「AI 生成」24、「上传」32、「删除」32。
|
||||
* 现在只有一个实现:页面既不用、也不准再给行里的单个控件写 size。
|
||||
*/
|
||||
export function CardActions({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return (
|
||||
<Dense className="contents">
|
||||
<div className={cn('nex-card-actions', className)}>{children}</div>
|
||||
<Flex wrap align="center" gap={8} className={cn('nex-card-actions min-w-0', className)}>
|
||||
{children}
|
||||
</Flex>
|
||||
</Dense>
|
||||
)
|
||||
}
|
||||
|
|
@ -77,113 +88,111 @@ export function Actions({ children, className }: { children: ReactNode; classNam
|
|||
|
||||
/** 需要右靠的一组控件(替代写在控件上的 margin-left:auto) */
|
||||
export function BarRight({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div className={cn('nex-barright', className)}>{children}</div>
|
||||
}
|
||||
|
||||
type FieldWidth = 'default' | 'grow' | 'narrow' | 'wide' | 'full'
|
||||
const WIDTHS: Record<FieldWidth, string> = {
|
||||
default: 'nf-w-default', grow: 'nf-w-grow', narrow: 'nf-w-narrow', wide: 'nf-w-wide', full: 'nf-w-full'
|
||||
}
|
||||
|
||||
/**
|
||||
* 行内字段:标签在左、控件在右。
|
||||
*
|
||||
* 「标题与控件对齐」的唯一机制是标签列宽:同一张表单里所有字段的标签列共用
|
||||
* `--label-w`(FormGrid 抬到 66px,Ctlbar 压回 0),只给下限不给上限——
|
||||
* 比 66px 长的中文标题宁可把控件顶右,也不截断标题。
|
||||
*/
|
||||
export function Field({ label, required, children, width = 'default', className, hint, title }: {
|
||||
label?: ReactNode; required?: boolean; children: ReactNode; width?: FieldWidth
|
||||
className?: string; hint?: ReactNode; title?: string
|
||||
}) {
|
||||
return (
|
||||
<label title={title} className={cn('nex-field', WIDTHS[width], hint && 'nf-has-hint', className)}>
|
||||
{label && <span className="nf-label">{label}{required && <Req />}</span>}
|
||||
<span className="nf-ctl">{children}</span>
|
||||
{hint && <span className="nf-hint">{hint}</span>}
|
||||
</label>
|
||||
<Flex wrap align="center" gap={8} className={cn('ml-auto min-w-0', className)}>{children}</Flex>
|
||||
)
|
||||
}
|
||||
|
||||
/** 必填星号:和标签文字同一个 flex item,否则列方向会把「*」顶到下一行 */
|
||||
export function Req() {
|
||||
return <b className="nf-req">*</b>
|
||||
type FieldWidth = 'default' | 'grow' | 'narrow' | 'wide' | 'full'
|
||||
/**
|
||||
* 字段宽度:宽度是**字段自己的属性**,列边界由 Row/Col 给(FormRow)。
|
||||
* 旧的 `nf-w-*` 五条类名靠 `--label-w` 间接生效,改成 inline style 后
|
||||
* 「这一格多宽」在 DOM 上直接看得见,工具条里的窄字段也不必再猜轨道宽度。
|
||||
*/
|
||||
const WIDTHS: Record<FieldWidth, CSSProperties> = {
|
||||
default: {},
|
||||
grow: { flex: '1 1 220px', minWidth: 150 },
|
||||
narrow: { width: 128 },
|
||||
wide: { width: 240 },
|
||||
full: { width: '100%' }
|
||||
}
|
||||
|
||||
/** 长字段(标签在上):抽屉 / 对话框里的多行文本、上传区用这个 */
|
||||
export function FieldBlock({ label, required, children, className, title, hint }: {
|
||||
/**
|
||||
* 字段 = antd `Form.Item`(标签在上)。
|
||||
*
|
||||
* 已验证:孤立使用(外层没有 `<Form>`)时 antd 仍然渲染完整的
|
||||
* `.ant-form-item-vertical` 结构与样式,所以字段不需要表单外壳也能独立成立;
|
||||
* `FormGrid` 只提供一个作用域类名,用来给整片字段统一上间距与控件撑满规则。
|
||||
* `title` 挂在标签文字上:版面里不放整段解释(规范 §2 G2),说明走悬浮。
|
||||
*/
|
||||
export function Field({ label, required, children, width = 'default', className, style, hint, title }: {
|
||||
label?: ReactNode; required?: boolean; children: ReactNode; width?: FieldWidth
|
||||
className?: string; style?: CSSProperties; hint?: ReactNode; title?: string
|
||||
}) {
|
||||
return (
|
||||
<Form.Item
|
||||
layout="vertical"
|
||||
required={required}
|
||||
label={label === undefined ? undefined : <span title={title}>{label}</span>}
|
||||
extra={hint}
|
||||
className={cn('nex-field min-w-0', width !== 'default' && 'nex-field-fill', className)}
|
||||
style={{ ...WIDTHS[width], ...style }}
|
||||
>
|
||||
{children}
|
||||
</Form.Item>
|
||||
)
|
||||
}
|
||||
|
||||
/** 必填星号:交还给 antd(Form.Item 的 required 自己画 `*`),这里只留旧名字的占位实现 */
|
||||
export function Req() {
|
||||
return <b className="nex-req">*</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* 长字段(旧「标签在上」专用形态):现在和 Field 完全同一种形态,只是默认撑满整行。
|
||||
* 保留这个名字是因为 54 处调用写着它,删名字要动 12 个页面而得不到任何东西。
|
||||
*/
|
||||
export function FieldBlock({ label, required, children, className, style, title, hint }: {
|
||||
label?: ReactNode; required?: boolean; children: ReactNode; className?: string
|
||||
style?: CSSProperties
|
||||
/** 标签的含义/后果说明:分镜检查器里几乎每个长字段都要一句 */
|
||||
title?: string; hint?: ReactNode
|
||||
}) {
|
||||
return (
|
||||
<label title={title} className={cn('nex-field-block', className)}>
|
||||
{label && <span className="nf-label nf-label-stack">{label}{required && <Req />}</span>}
|
||||
<span className="nf-ctl">{children}</span>
|
||||
{hint && <span className="nf-hint">{hint}</span>}
|
||||
</label>
|
||||
<Field label={label} required={required} children={children} width="full"
|
||||
className={className} style={style} title={title} hint={hint} />
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单作用域:列边界与标签列宽只在这里定义一次。
|
||||
* 表单作用域:只落下 `.nex-form` 这个标记类。
|
||||
*
|
||||
* 病灶:轨道以前写在每条 FormRow 自己身上,同一个抽屉里两行不同 cols
|
||||
* 的字段列边界差了 110px,标题看着就是斜的。基准取 12 等分(2/3/4/6 都能整除),
|
||||
* FormRow 的 cols 退化成「这一行放几个字段」= 每字段跨 12/cols 格。
|
||||
* 旧版本在这里定义 12 等分轨道和 `--label-w`(「标题与控件对齐」的唯一机制)。
|
||||
* 标签改到控件上方之后,对齐由 antd 表单栅格负责,这两套私有尺子整体退场——
|
||||
* 列边界从此只有 Row/Col 一个来源(见 grid.tsx),不会再出现两行字段错开 110px。
|
||||
*/
|
||||
/** FormGrid 作用域标记:FormRow 靠它决定用 12 等分基准栅格还是 auto-fit */
|
||||
const FormGridCtx = createContext(false)
|
||||
export function FormGrid({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div className={cn('nex-form min-w-0', className)}>{children}</div>
|
||||
}
|
||||
|
||||
export function FormGrid({ children, className, cols = 12, labelWidth }: {
|
||||
children: ReactNode; className?: string; cols?: number
|
||||
/**
|
||||
* 标签列宽(px)。默认不锁:minmax(66, max-content) 让超长标题把那一格控件顶右。
|
||||
* 抽屉里字段多、标题长短不一时传一个数(例如 92)把上下限锁死,
|
||||
* 整表严格对齐,超长标题自动折行——对齐优先于单行。
|
||||
*/
|
||||
labelWidth?: number
|
||||
}) {
|
||||
const style: Record<string, string | number> = { '--form-cols': cols }
|
||||
if (labelWidth) {
|
||||
const w = `${labelWidth}px`
|
||||
style['--label-w'] = w
|
||||
style['--label-max'] = w
|
||||
}
|
||||
return (
|
||||
<FormGridCtx.Provider value>
|
||||
<div className={cn('nex-form', className)} style={style as any}>{children}</div>
|
||||
</FormGridCtx.Provider>
|
||||
)
|
||||
/** 每行 N 个字段时的降列节奏:档位名就是 antd Grid 的断点,站内不再有 900/1100 这种私有宽度 */
|
||||
const ROW_STEPS: Record<number, GridStep[]> = {
|
||||
2: [{ at: 'sm', cols: 1 }],
|
||||
3: [{ at: 'md', cols: 2 }, { at: 'sm', cols: 1 }],
|
||||
4: [{ at: 'lg', cols: 3 }, { at: 'md', cols: 2 }, { at: 'sm', cols: 1 }],
|
||||
6: [{ at: 'xl', cols: 4 }, { at: 'lg', cols: 3 }, { at: 'md', cols: 2 }, { at: 'sm', cols: 1 }]
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单里的一行。
|
||||
* 有 FormGrid 时按跨格数落位(cols 只决定「这行几个字段」);
|
||||
* 没有 FormGrid 时 auto-fit 自己降列(孤立一行筛选字段的场合)。
|
||||
* 表单里的一行 = antd Row + Col(cols = 这一行放几个字段)。
|
||||
*
|
||||
* 纵向间距不在 gutter 上:Form.Item 自带 24px 下边距,Row 再给纵向 gutter 就是 48。
|
||||
* `tight` 是给「一行里全是窄字段」的场合(时间线/分镜的批量设置),
|
||||
* 把下边距压到 8,见 app.css 的 `.nf-tight`。
|
||||
*/
|
||||
export function FormRow({ children, cols = 3, className, tight, stack }: {
|
||||
export function FormRow({ children, cols = 3, className, tight, gap = 16 }: {
|
||||
children: ReactNode
|
||||
/** 这一行放几个字段(FormGrid 里 = 每字段跨 12/cols 格);脱离 FormGrid 时忽略 */
|
||||
/** 这一行放几个字段(窄屏按 ROW_STEPS 自动降列) */
|
||||
cols?: 2 | 3 | 4 | 6
|
||||
className?: string
|
||||
/**
|
||||
* 更紧的一行。**在 FormGrid 里只收纵向呼吸**,列间距留在表单基准上;
|
||||
* 脱离 FormGrid 的孤立行(auto-fit)才两个方向一起收。
|
||||
* 别把它当「间距降一档」用:12 等分基准栅格里一改 column-gap,
|
||||
* 列线就按「前面已经过了几条轨道」累计漂移,同一个抽屉里两行的第二列控件错开 2px。
|
||||
*/
|
||||
tight?: boolean
|
||||
/** 标签退回控件上方:长标题字段、代码/路径类输入用它 */
|
||||
stack?: boolean
|
||||
/** 列间距:默认 16(antd 表单列间),窄屏由 Col 折行接管 */
|
||||
gap?: number
|
||||
}) {
|
||||
// 在 FormGrid 里走 12 等分基准;孤立一行交给 auto-fit 自己降列(窄屏不会挤成一列宽)
|
||||
const inGrid = useContext(FormGridCtx)
|
||||
return (
|
||||
<div className={cn('nex-form-row', inGrid ? 'nf-row-grid' : 'nf-row-auto',
|
||||
inGrid && `nf-cols-${cols}`, stack && 'nf-stack', tight && 'nf-tight', className)}>
|
||||
{children}
|
||||
</div>
|
||||
<Row gutter={[tight ? 12 : gap, 0]} className={cn('nex-form-row min-w-0', tight && 'nf-tight', className)}>
|
||||
{toCols(children, colSpans(cols, undefined, ROW_STEPS[cols] || []), 'min-w-0')}
|
||||
</Row>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -192,27 +201,45 @@ export function ChipBar({ children, label, className, top }: {
|
|||
children: ReactNode; label?: ReactNode; className?: string; top?: boolean
|
||||
}) {
|
||||
return (
|
||||
<Dense className={cn('contents')}>
|
||||
<div className={cn('nex-chipbar', top && 'mt-3', className)}>
|
||||
{label && <span className={fieldGroupLabelCls}>{label}</span>}
|
||||
<Dense className="contents">
|
||||
<Flex wrap align="center" gap={6} className={cn('nex-chipbar min-w-0', top && 'mt-3', className)}>
|
||||
{label && <span className={GROUP_LABEL_CLS}>{label}</span>}
|
||||
{children}
|
||||
</div>
|
||||
</Flex>
|
||||
</Dense>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选 / 开关胶囊:**可点的**东西才属于这一族(与同排按钮等高)。
|
||||
* 只读回显(计数、能力、状态)用 Tag / TagGroup,别在这里装成 span。
|
||||
* 筛选 / 开关胶囊 = antd `Tag.CheckableTag`(Ant Design 的「标签选择」形态)。
|
||||
*
|
||||
* 只有**可点的**东西属于这一族;只读回显(计数、能力、状态)用 Tag / TagGroup。
|
||||
* 5.29 的 CheckableTag 没有 disabled,所以禁用态自己贴语义:降透明度 + 屏蔽 onChange。
|
||||
*/
|
||||
export function Chip({ active, children, onClick, className, title, disabled, as = 'button', href, size = 'md' }: {
|
||||
active?: boolean; children: ReactNode; onClick?: () => void; className?: string; title?: string
|
||||
disabled?: boolean; as?: 'button' | 'a' | 'span'; href?: string; size?: 'md' | 'sm'
|
||||
}) {
|
||||
const classes = cn('nex-chip', size === 'sm' && 'nex-chip-sm', active && 'is-on', disabled && 'is-off', className)
|
||||
if (as === 'span') return <span title={title} className={classes}>{children}</span>
|
||||
if (as === 'a') return <a href={href} title={title} className={classes}>{children}</a>
|
||||
return <button type="button" title={title} disabled={disabled} onClick={onClick} className={classes}>{children}</button>
|
||||
const cls = cn('nex-chip', size === 'sm' && 'nex-chip-sm', className)
|
||||
if (as === 'a') {
|
||||
return (
|
||||
<Tag className={cn(cls, 'nex-chip-link')} bordered>
|
||||
<Typography.Link href={href} title={title} className="!text-inherit">{children}</Typography.Link>
|
||||
</Tag>
|
||||
)
|
||||
}
|
||||
if (as === 'span' || disabled) {
|
||||
return (
|
||||
<Tag className={cn(cls, 'is-off')} bordered {...{ title }}
|
||||
style={{ opacity: 0.45, cursor: 'not-allowed' }}>{children}</Tag>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Tag.CheckableTag checked={!!active} {...{ title }} className={cls}
|
||||
onChange={() => onClick?.()}>
|
||||
{children}
|
||||
</Tag.CheckableTag>
|
||||
)
|
||||
}
|
||||
|
||||
/** 选中态胶囊 + 移除叉(多选回显);removeTitle 解释叉掉之后会发生什么 */
|
||||
|
|
@ -220,21 +247,15 @@ export function TagChip({ children, onRemove, className, removeTitle }: {
|
|||
children: ReactNode; onRemove?: () => void; className?: string; removeTitle?: string
|
||||
}) {
|
||||
return (
|
||||
<span className={cn('nex-tag-chip', className)}>
|
||||
{children}
|
||||
{onRemove && (
|
||||
<button type="button" onClick={onRemove} title={removeTitle} aria-label="移除" className="nex-tag-chip-x"><IconClose /></button>
|
||||
)}
|
||||
</span>
|
||||
<Tag className={cn('nex-tag-chip', className)} bordered closable={!!onRemove}
|
||||
closeIcon={onRemove ? <IconClose /> : undefined}
|
||||
onClose={(e) => { e.preventDefault(); onRemove?.() }}>
|
||||
<span className="min-w-0 wrap-anywhere">{children}</span>
|
||||
{removeTitle && <span className="sr-only">{removeTitle}</span>}
|
||||
</Tag>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 长文本字段的最小高度:挂在**容器**上(`[&_textarea]`)而不是每个 textarea 上——
|
||||
* 往抽屉里加字段的人不该再记一遍这三条。
|
||||
*/
|
||||
export const TEXTAREA_TALL = 'nex-textarea-tall'
|
||||
|
||||
/**
|
||||
* 分页条(规范 §5):page_size 唯一的家,筛选栏里不再出现「每页」。
|
||||
* 档位由页面给(卡片墙要的是 24/60/120/全部;0 表示不分页)。
|
||||
|
|
@ -248,21 +269,22 @@ export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra,
|
|||
const last = Math.max(1, pages)
|
||||
const opts = sizes.map((n) => ({ value: n, label: String(n || '全部') }))
|
||||
return (
|
||||
<Dense className={cn('nex-pager', (total === undefined || total === 0) && !extra && 'hidden')}>
|
||||
<span className="text-xs text-text-quaternary">
|
||||
{page} / {last}{total !== undefined ? ` · 共 ${total} 条` : ''}
|
||||
</span>
|
||||
<Pagination current={page} total={Math.max(last * (pageSize || 1), total || 0)} pageSize={pageSize || 12}
|
||||
showSizeChanger={false} onChange={(p) => onPage(p)} size="small" simple />
|
||||
{onPageSize && (
|
||||
<span className="inline-flex items-center gap-1.5 text-xs text-text-quaternary">
|
||||
每页
|
||||
<Select size="sm" ariaLabel="每页条数" searchThreshold={0} placeholder="全部"
|
||||
value={pageSize} onChange={(v: any) => onPageSize(Number(v))}
|
||||
className="w-[72px]" options={opts} />
|
||||
</span>
|
||||
)}
|
||||
{extra}
|
||||
<Dense>
|
||||
<Flex wrap align="center" gap={12}
|
||||
className={cn('nex-pager min-w-0', (total === undefined || total === 0) && !extra && 'hidden')}>
|
||||
<Typography.Text type="secondary" className="!text-xs">{page} / {last}{total !== undefined ? ` · 共 ${total} 条` : ''}</Typography.Text>
|
||||
<Pagination current={page} total={Math.max(last * (pageSize || 1), total || 0)} pageSize={pageSize || 12}
|
||||
showSizeChanger={false} onChange={(p) => onPage(p)} size="small" simple />
|
||||
{onPageSize && (
|
||||
<Flex align="center" gap={6}>
|
||||
<Typography.Text type="secondary" className="!text-xs">每页</Typography.Text>
|
||||
<Select size="sm" ariaLabel="每页条数" searchThreshold={0} placeholder="全部"
|
||||
value={pageSize} onChange={(v: any) => onPageSize(Number(v))}
|
||||
className="w-[72px]" options={opts} />
|
||||
</Flex>
|
||||
)}
|
||||
{extra}
|
||||
</Flex>
|
||||
</Dense>
|
||||
)
|
||||
}
|
||||
|
|
@ -280,20 +302,17 @@ export function Check({ checked, onChange, children, disabled, className, title
|
|||
)
|
||||
}
|
||||
|
||||
/** 单选组(分段用 antd Segmented,互斥选项用这个) */
|
||||
/** 单选组(互斥选项):antd Radio.Group;分段切换请用 Segmented */
|
||||
export function RadioGroup({ value, onChange, options, className, disabled }: {
|
||||
value: any; onChange: (next: any) => void; options: { value: any; label: ReactNode; disabled?: boolean }[]
|
||||
className?: string; disabled?: boolean
|
||||
}) {
|
||||
return (
|
||||
<span className={cn('inline-flex flex-wrap items-center gap-x-4 gap-y-1 min-w-0', className)}>
|
||||
{options.map((o) => (
|
||||
<AntCheckbox key={String(o.value)} checked={o.value === value} disabled={disabled || o.disabled}
|
||||
onChange={() => onChange(o.value)}>
|
||||
{o.label}
|
||||
</AntCheckbox>
|
||||
))}
|
||||
</span>
|
||||
<Form.Item layout="vertical" className={cn('nex-field min-w-0 !mb-0', className)}>
|
||||
<AntRadio.Group value={value} disabled={disabled}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
options={options.map((o) => ({ label: o.label, value: o.value, disabled: o.disabled }))} />
|
||||
</Form.Item>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* 1) 事件形状沿用 React 原生(Input/TextArea 的 onChange 仍是 event),
|
||||
* 页面迁移只是把标签换掉,逻辑一行不动;
|
||||
* 2) NumberInput 把 antd 的 (value:number|null) 收窄成页面惯用的数字;
|
||||
* 3) 宽度统一由 .nf-ctl 撑满字段列,页面不再写 w-[...]。
|
||||
* 3) 宽度统一由字段栅格(Form.Item 的控件列)撑满,页面不再写 w-[...]。
|
||||
*
|
||||
* ref 一律是 **DOM 节点**(HTMLInputElement / HTMLTextAreaElement),不是 antd 的句柄:
|
||||
* React 18 必须 forwardRef,而且页面拿到节点才能 focus / setSelectionRange /
|
||||
|
|
@ -28,12 +28,21 @@ export const Input = forwardRef<HTMLInputElement, React.ComponentProps<typeof An
|
|||
})
|
||||
|
||||
/**
|
||||
* 多行文本。rows 保留:抽屉里的字段高度是排版的一部分,
|
||||
* autoSize 会让同一抽屉的字段随内容长短跳动。
|
||||
* 多行文本:`rows` 是**起步高度**,框随内容自己长(antd 的 autoSize)。
|
||||
*
|
||||
* 症状(2026-11 用户第二轮截图):抽屉里的文本域要么固定 96px 起步(旧
|
||||
* `.nex-textarea-tall` 给容器挂 min-height,rows=2 直接失效、内容少时剩半盒空白),
|
||||
* 要么在任务指令那里被写死成一个占掉半屏的大框——两个方向都不对:
|
||||
* 高度是内容决定的,不是版面决定的。
|
||||
* 做法:把页面写下来的 `rows` 翻译成 `autoSize={{ minRows: rows, maxRows: rows×4 }}`,
|
||||
* 超过上限内部滚动,抽屉的总高度因此可预期。
|
||||
* 为什么在 kit 里翻译而不是让 12 个页面各自改写:`rows` 的语义本来就是
|
||||
* 「这个字段默认几行」,把「会不会长」这件事收在一处,页面不用记第二条规矩。
|
||||
*/
|
||||
export const TextArea = forwardRef<HTMLTextAreaElement, React.ComponentProps<typeof AntTextArea>>(
|
||||
function TextArea(props, ref) {
|
||||
return <AntTextArea {...props} ref={(h) => passRef(ref, domTextarea(h))} />
|
||||
function TextArea({ rows, autoSize, ...rest }, ref) {
|
||||
const grow = autoSize ?? (rows ? { minRows: rows, maxRows: Math.max(4, rows * 4) } : undefined)
|
||||
return <AntTextArea {...rest} autoSize={grow} ref={(h) => passRef(ref, domTextarea(h))} />
|
||||
})
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,8 +15,14 @@ export const MONO = 'font-mono text-xs '
|
|||
/** 弱化 + 等宽(.muted.mono):id、路径、枚举码 */
|
||||
export const MUTED_MONO = `${'text-text-quaternary'} ${MONO}`
|
||||
|
||||
/** 站内文字链配色(.link):<Link> 没有组件形态,用这个类名常量保持一致 */
|
||||
export const LINK_CLS = 'text-success text-xs no-underline hover:underline'
|
||||
/**
|
||||
* 站内文字链配色(.link):<Link> 没有组件形态,用这个类名常量保持一致。
|
||||
* 用 text-primary(=antd 的 colorLink 默认就等于 colorPrimary)而不是 text-success:
|
||||
* 绿色那一族在站内只有一个含义——「这件事成功了」(Tag ok / 流程 done),
|
||||
* 上一版让它兼职当链接色,于是「完成」和「可点」是同一个颜色,
|
||||
* 换成标准蓝以后两者各归各位:链接=主色,状态=语义色。
|
||||
*/
|
||||
export const LINK_CLS = 'text-primary text-xs no-underline hover:underline'
|
||||
|
||||
/**
|
||||
* 页头(旧 <header>):左边「状态行 + 大标题」,右边整组动作。
|
||||
|
|
|
|||
|
|
@ -1,241 +1,310 @@
|
|||
import type { CSSProperties, ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Button } from './Button'
|
||||
import { IconClose, IconExternal, IconLoading } from '../icons'
|
||||
/** 面板:站内唯一的「有边框的内容块」。窄屏自动收窄内边距(旧站每个页面自己写一遍)。 */
|
||||
export function Panel({ children, className, style, pad = true }: {
|
||||
children?: ReactNode; className?: string; style?: CSSProperties; pad?: boolean
|
||||
}) {
|
||||
return (
|
||||
<section style={style} className={cn('bg-bg-container border border-border-secondary rounded-lg p-5 max-sm:p-3 min-w-0', pad && '', className)}>
|
||||
{children}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 面板头:标题 + 右侧动作。
|
||||
* 卡片体系:Ant Design 5 Card / Statistic / Row·Col / Alert / Empty / Progress 的唯一封装。
|
||||
*
|
||||
* 旧站 25 处面板头都是 <small class="eyebrow"> + <h2> 的「英文眉标 + 中文标题」双层,
|
||||
* 眉标既不翻译也不承载信息,已整层删除;标题走全局 h2(17px),
|
||||
* 第一版迁移手写成 14px 的 h3,整站面板标题比正文重不了多少,扫视时找不到锚点。
|
||||
* 窄列必须允许换行(旧站第二十章补的 .panel-head{flex-wrap:wrap}):两列栅格下
|
||||
* 每列只有 ~400px,筛选控件的最小宽度就超过整列,不换行会把内容压到相邻面板上。
|
||||
* 症状(2026-11 第二轮重写的对象):第一轮只把**原子控件**换成了 antd,
|
||||
* 「有边框的内容块」仍然是自绘 <section> + Tailwind 类,标题行、指标卡、
|
||||
* 栅格、提示条、空态各自一把尺子。于是页面看着像 antd 控件贴在旧版式上:
|
||||
* 卡头没有分隔线、指标卡数字与 antd 的 Statistic 差 6px、栅格按私有断点降列。
|
||||
* 做法:**布局也交给 antd**。Panel=Card(卡头用 Card 自己的 title/extra)、
|
||||
* Stat=Card+Statistic、Grid/StatGrid=Row+Col(断点用 antd Grid 的 xs…xxl)、
|
||||
* Notice=Alert、Empty=Empty、ProgressBar=Progress、Divider=Divider。
|
||||
* 页面继续写 <Panel><PanelHead …/>正文</Panel>:Panel 会把作为第一个子节点的
|
||||
* PanelHead **吞进 Card 的 title/extra**,所以 52 处调用一行不用改,
|
||||
* 卡头却已经是真正的 antd 卡头(分隔线、15px 标题、右端 extra)。
|
||||
* 为什么把吞并做在 Panel 里而不是让页面改写:<PanelHead> 这个形状已经写了 42 遍,
|
||||
* 改名成 Card 的 title/extra 属性要动 12 个页面 42 处,而它表达的语义
|
||||
* (这一块是什么 + 右端动作)完全一致;语义不变、实现换掉,就是这一轮的全部工作。
|
||||
*/
|
||||
export function PanelHead({ title, sub, right, className }: {
|
||||
title?: ReactNode; sub?: ReactNode; right?: ReactNode; className?: string
|
||||
import { Children, isValidElement, type CSSProperties, type ReactNode } from 'react'
|
||||
import {
|
||||
Alert, Card, Divider as AntDivider, Empty as AntEmpty, Flex,
|
||||
Progress, Row, Spin, Statistic, Typography
|
||||
} from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { IconExternal, IconLoading } from '../icons'
|
||||
import { colSpans, toCols, type GridCollapse, type GridStep, type StatStep } from './grid'
|
||||
|
||||
/** Panel 认得出的 PanelHead 形状(Panel 用它拼 Card 的 title/extra) */
|
||||
type HeadProps = { title?: ReactNode; sub?: ReactNode; right?: ReactNode }
|
||||
|
||||
/**
|
||||
* 面板 = antd Card。
|
||||
*
|
||||
* pad={false} 给「正文本身就是一张表 / 一整个滚动区」的卡:antd 的 body 内边距
|
||||
* 会让表格的描边离卡边 24px,看起来像表格外又套了一圈盒子。
|
||||
*/
|
||||
export function Panel({ children, className, style, pad = true, title, sub, extra }: {
|
||||
children?: ReactNode; className?: string; style?: CSSProperties; pad?: boolean
|
||||
/** 不写 children 里的 PanelHead 时,也可以直接用卡头属性(与 antd Card 同名) */
|
||||
title?: ReactNode; sub?: ReactNode; extra?: ReactNode
|
||||
}) {
|
||||
const head: HeadProps = {}
|
||||
const body: ReactNode[] = []
|
||||
let taken = false
|
||||
Children.forEach(children, (child) => {
|
||||
if (!taken && isValidElement(child) && child.type === PanelHead) {
|
||||
const p = (child.props || {}) as HeadProps
|
||||
head.title = p.title; head.sub = p.sub; head.right = p.right
|
||||
taken = true
|
||||
return
|
||||
}
|
||||
body.push(child)
|
||||
})
|
||||
const cardTitle = title ?? head.title
|
||||
const cardSub = sub ?? head.sub
|
||||
const cardExtra = extra ?? head.right
|
||||
const headNode = (cardTitle || cardSub)
|
||||
? (
|
||||
<Flex vertical gap={2} className="min-w-0">
|
||||
{cardTitle && <span className="min-w-0">{cardTitle}</span>}
|
||||
{cardSub && (
|
||||
<Typography.Text type="secondary" className="!text-xs font-normal leading-snug">{cardSub}</Typography.Text>
|
||||
)}
|
||||
</Flex>
|
||||
)
|
||||
: undefined
|
||||
return (
|
||||
<div className={cn('flex justify-between items-center gap-3 flex-wrap mb-5 min-w-0 [&>*]:min-w-0', className)}>
|
||||
<div className="min-w-0">
|
||||
{title && <h2 className="mt-0 mb-0 text-xl font-bold">{title}</h2>}
|
||||
{sub && <p className="mt-1 mb-0 text-xs text-text-quaternary leading-relaxed">{sub}</p>}
|
||||
</div>
|
||||
{right && <div className="flex items-center gap-2 flex-wrap min-w-0">{right}</div>}
|
||||
</div>
|
||||
<Card className={cn('nex-panel', className)} style={style} title={headNode} extra={cardExtra}
|
||||
styles={pad ? undefined : { body: { padding: 0 } }}>
|
||||
{body}
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 小标题 + 右侧动作(.small-label / .sect-act:增删按钮一律贴在标题行右端)。
|
||||
* 面板头(标题 + 副标题 + 右端动作)。
|
||||
*
|
||||
* title 给整行挂悬浮解释:旧站把提示写在标题 h2 上,标题后面不拖一长串灰字,
|
||||
* 窄屏也就不会因为一句说明把动作按钮挤到下一行。
|
||||
* 在 <Panel> 里它不渲染任何东西——Panel 把这三个属性搬进 Card 的 title/extra。
|
||||
* 单独出现(页面正文最上方那种「不属于任何卡片的小标题」)时才是下面这一行。
|
||||
*
|
||||
* 旧站 25 处卡头都是 <small class="eyebrow"> + <h2> 的「英文眉标 + 中文标题」双层,
|
||||
* 眉标既不翻译也不承载信息,已整层删除(UI规范 §1)。
|
||||
*/
|
||||
export function PanelHead({ title, sub, right, className }: HeadProps & { className?: string }) {
|
||||
return (
|
||||
<Flex justify="space-between" align="center" gap={12} wrap className={cn('mb-4 min-w-0 [&>*]:min-w-0', className)}>
|
||||
<Flex vertical gap={2} className="min-w-0">
|
||||
{title && <Typography.Title level={5} className="!mb-0">{title}</Typography.Title>}
|
||||
{sub && <Typography.Text type="secondary" className="!text-xs">{sub}</Typography.Text>}
|
||||
</Flex>
|
||||
{right && <Flex gap={8} wrap align="center" className="min-w-0">{right}</Flex>}
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 小标题 + 右端动作(.small-label / .sect-act:增删按钮一律贴在标题行右端)。
|
||||
*
|
||||
* title 给整行挂悬浮解释:版面里不放整段说明文字(G2),窄屏也不会因为一句说明
|
||||
* 把动作按钮挤到下一行。
|
||||
*/
|
||||
export function SectionTitle({ children, action, className, title }: {
|
||||
children: ReactNode; action?: ReactNode; className?: string; title?: string
|
||||
}) {
|
||||
return (
|
||||
<div title={title} className={cn('flex items-center gap-2 flex-wrap text-xs text-text-quaternary tracking-wide font-bold mt-4 mb-2', className)}>
|
||||
<Flex align="center" gap={8} wrap title={title}
|
||||
className={cn('mb-2 mt-4 min-w-0 text-xs font-bold tracking-wide text-text-quaternary', className)}>
|
||||
<span>{children}</span>
|
||||
{action && <span className="ml-auto inline-flex items-center gap-2 ">{action}</span>}
|
||||
</div>
|
||||
{action && <span className="ml-auto inline-flex items-center gap-2">{action}</span>}
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标:全站「数字 + 标题」只有这一个写法。
|
||||
* 指标:全站「数字 + 标题」只有这一个写法 = antd Statistic(卡档再套一层 Card)。
|
||||
*
|
||||
* 病灶:同一个统计数字长出过三套皮肤——概览/仪表盘用这里的卡片、资产库自己写了
|
||||
* 病灶:同一个统计数字长出过三套皮肤——概览/仪表盘用自绘卡、资产库自己写了
|
||||
* 一张带渐变的 MetricCard、分镜顶栏又写了一套更小的 Metric。
|
||||
* 于是「镜头 7」和「母版资产 21」并排一看就是两个产品。
|
||||
* 做法:一个组件两档形态,档位是**参数**不是第二套类名——
|
||||
* card(默认)=页面顶部那排统计卡;inline=sticky 顶栏 / 工具条里的一列小数字。
|
||||
* 给了 onClick 就渲染成 <button>(整张卡是筛选入口,键盘点得动,AS-7),
|
||||
* 做法:数字与标题的度量交还 antd(.ant-statistic 的 title 14 / content 24),
|
||||
* 档位是**参数**不是第二套类名——card(默认)=页面顶部那排统计卡;
|
||||
* inline=sticky 顶栏 / 工具条里的一列小数字。
|
||||
* 给了 onClick 就整张卡可点(antd Card hoverable,键盘点得动 AS-7),
|
||||
* active 点亮描边 = 「当前这一屏数字就是这个筛选命中的那批」。
|
||||
* 数字一律 tabular-nums:状态每 5 秒轮询一次,行宽不能跟着抖。
|
||||
* 数字 tabular-nums 由 antd 自己负责(.ant-statistic-content 已开)。
|
||||
*/
|
||||
export type StatTone = 'lead' | 'ok' | 'warn' | 'bad'
|
||||
const STAT_TONE: Record<StatTone, string> = {
|
||||
lead: 'text-primary', ok: 'text-success', warn: 'text-warning', bad: 'text-error'
|
||||
lead: 'var(--ant-color-primary)', ok: 'var(--ant-color-success)',
|
||||
warn: 'var(--ant-color-warning)', bad: 'var(--ant-color-error)'
|
||||
}
|
||||
|
||||
export function Stat({ label, value, hint, className, variant = 'card', tone, active, onClick, title, valueSize = 'num' }: {
|
||||
label: ReactNode; value: ReactNode; hint?: ReactNode; className?: string
|
||||
export function Stat({ label, value, hint, className, style, variant = 'card', tone, active, onClick, title, valueSize = 'num' }: {
|
||||
label: ReactNode; value: ReactNode; hint?: ReactNode; className?: string; style?: CSSProperties
|
||||
/** card=页面统计卡;inline=顶栏里的一列小数字 */
|
||||
variant?: 'card' | 'inline'
|
||||
tone?: StatTone
|
||||
/** 命中当前筛选:点亮描边 + 标题 */
|
||||
active?: boolean
|
||||
/** 整张卡是筛选入口(给了就渲染 button) */
|
||||
/** 整张卡是筛选入口 */
|
||||
onClick?: () => void
|
||||
title?: string
|
||||
/**
|
||||
* 数值字号。`num`(默认)给纯数字;`title` 给「这里放的是一段名字而不是数」
|
||||
* 的卡(模型控制台的「当前默认大模型」),否则一个模型名会被撑成整屏最重的东西。
|
||||
*/
|
||||
/** `num`(默认)=纯数字;`title`=放的是一段名字(模型控制台的「当前默认大模型」) */
|
||||
valueSize?: 'num' | 'title'
|
||||
}) {
|
||||
const toneCls = tone ? STAT_TONE[tone] : ''
|
||||
const color = tone ? STAT_TONE[tone] : undefined
|
||||
const labelNode = <span title={title}>{label}</span>
|
||||
/* value 里的 <i> 是「次要的一半」(9<i>/47</i> 里的分母、/ 未设置),样式只在这里定义一次 */
|
||||
const valueStyle: CSSProperties = {
|
||||
color,
|
||||
fontSize: variant === 'inline' ? 18 : valueSize === 'num' ? 24 : 15,
|
||||
fontWeight: 600,
|
||||
...(valueSize === 'title' ? { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } : {})
|
||||
}
|
||||
const stat = (
|
||||
<Statistic className="nex-stat-value min-w-0 [&_i]:not-italic [&_i]:font-medium [&_i]:ml-[3px] [&_i]:text-text-quaternary [&_i]:text-base"
|
||||
title={labelNode} value={value as never} valueStyle={valueStyle} />
|
||||
)
|
||||
if (variant === 'inline') {
|
||||
return (
|
||||
<div title={title} className={cn('flex min-w-0 flex-col', className)}>
|
||||
<b className={cn('text-lg font-bold leading-snug tabular-nums text-text', toneCls)}>{value}</b>
|
||||
<small className="mt-1 text-xs tracking-wide text-text-quaternary">{label}</small>
|
||||
</div>
|
||||
<Flex vertical gap={0} className={cn('min-w-0', className)} style={style} title={title}>
|
||||
{stat}
|
||||
{hint && <Typography.Text type="secondary" className="!text-xs">{hint}</Typography.Text>}
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
const As: any = onClick ? 'button' : 'div'
|
||||
return (
|
||||
<As title={title} {...(onClick ? { type: 'button', onClick } : {})}
|
||||
className={cn('nex-stat bg-bg-container border border-border-secondary rounded-lg p-5 min-w-0 max-sm:p-3 text-left',
|
||||
onClick && 'transition-colors hover:border-primary-border',
|
||||
active && 'border-success-border shadow-[inset_0_0_0_1px_var(--ant-color-success-border)] [&>small:first-child]:text-success',
|
||||
className)}>
|
||||
<small className="block text-text-tertiary text-xs">{label}</small>
|
||||
{/* value 里的 <i> 是「次要的一半」(9<i>/47</i> 里的分母、/ 未设置),样式只在这里定义一次 */}
|
||||
<b className={cn('block mt-2 font-bold break-words tabular-nums max-sm:text-lg '
|
||||
+ '[&_i]:not-italic [&_i]:font-medium [&_i]:ml-[3px] [&_i]:text-text-quaternary [&_i]:text-base',
|
||||
valueSize === 'num' ? 'text-2xl' : 'text-xl truncate whitespace-nowrap', toneCls)}>{value}</b>
|
||||
{hint && <small className="block text-text-quaternary text-xs mt-2">{hint}</small>}
|
||||
</As>
|
||||
<Card hoverable={!!onClick} onClick={onClick} className={cn('nex-stat min-w-0', onClick && 'nex-stat-click', className)}
|
||||
/* active 是「这张卡被选中」,选择态用主色描边;success 只留给数字本身表示 ok(STAT_TONE.ok)。 */
|
||||
style={active ? { ...style, borderColor: 'var(--ant-color-primary-border)' } : style}
|
||||
styles={{ body: { padding: 20 } }}>
|
||||
{stat}
|
||||
{hint && (
|
||||
<Typography.Text type="secondary" className="!mt-2 block !text-xs leading-snug">{hint}</Typography.Text>
|
||||
)}
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
/** 顶栏 / 工具条里的一排小指标(分镜、调度那种 sticky 条);卡片栅格请用 StatGrid */
|
||||
export function StatRow({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div className={cn('flex min-w-0 flex-wrap items-end gap-6', className)}>{children}</div>
|
||||
return <Flex wrap align="end" gap={24} className={cn('min-w-0', className)}>{children}</Flex>
|
||||
}
|
||||
|
||||
/* 降列档位写成字面量:Tailwind 按源码里的字符串生成工具类,
|
||||
运行时拼出来的 `max-[${w}px]:grid-cols-${c}` 根本不会被扫描到。 */
|
||||
const STEP_CLS: Record<string, string> = {
|
||||
'2xl:3': 'max-2xl:grid-cols-3', '2xl:2': 'max-2xl:grid-cols-2', '2xl:1': 'max-2xl:grid-cols-1',
|
||||
'xl:3': 'max-xl:grid-cols-3', 'xl:2': 'max-xl:grid-cols-2', 'xl:1': 'max-xl:grid-cols-1',
|
||||
'lg:3': 'max-lg:grid-cols-3', 'lg:2': 'max-lg:grid-cols-2', 'lg:1': 'max-lg:grid-cols-1',
|
||||
'md:3': 'max-md:grid-cols-3', 'md:2': 'max-md:grid-cols-2', 'md:1': 'max-md:grid-cols-1',
|
||||
'sm:2': 'max-sm:grid-cols-2', 'sm:1': 'max-sm:grid-cols-1'
|
||||
/* 栅格换算(列数 + 降列档位 → antd Col 断点)与 Page/Controls 共用一份:见 grid.tsx */
|
||||
/**
|
||||
* 通用栅格(旧 .grid / .grid2 / .grid3 / .grid4)= antd Row + Col。
|
||||
*
|
||||
* 列间距走 antd 的 gutter(横向必须是 8 的倍数才和站内间距成一套),
|
||||
* 纵向间距同样由 gutter 给,页面不再自己写 mb-*。
|
||||
*/
|
||||
export function Grid({ children, cols = 4, gap = 12, min, oneAt, steps, className }: {
|
||||
children?: ReactNode; cols?: number; gap?: number; oneAt?: GridCollapse
|
||||
steps?: GridStep[]; className?: string
|
||||
/** 兼容旧参数:列最小宽。栅格改成 24 等分后由 span 决定列宽,这个值只作窄屏兜底 */
|
||||
min?: number
|
||||
}) {
|
||||
void min
|
||||
const spans = colSpans(cols, oneAt, steps)
|
||||
return (
|
||||
<Row gutter={[gap, gap]} className={cn('min-w-0', className)}>
|
||||
{toCols(children, spans, 'min-w-0')}
|
||||
</Row>
|
||||
)
|
||||
}
|
||||
/** 降列档位就是 antd Grid 的断点名(xs<576 / sm / md / lg / xl / xxl),不再有 nav / mid / tiny 这些私有档位 */
|
||||
export type StatStep = { at: '2xl' | 'xl' | 'lg' | 'md' | 'sm'; cols: 1 | 2 | 3 }
|
||||
/** 通用栅格的降列节奏与指标卡共用一套档位(旧站 .grid3/.grid4 是「≤1180 两列、≤560 一列」两段式) */
|
||||
export type GridStep = StatStep
|
||||
|
||||
/**
|
||||
* 指标卡栅格:列数与降列节奏都由容器声明,页面不写 @media。
|
||||
* 默认沿用旧站 .stats:4 列 → ≤900 两列 → ≤560 收紧间距(卡片本身跟着换小字号内边距)。
|
||||
* 卡片数不是 4 的页面把节奏写进 steps(用户管理 5 张卡:≤1280 三列、≤820 两列),
|
||||
* 这样例外是可见的参数,而不是又一段散回样式表、没人敢删的 @media。
|
||||
* 默认 4 列 → ≤992 两列 → ≤576 一列(antd 断点,不再用私有的 900/560)。
|
||||
*/
|
||||
export function StatGrid({ children, cols = 4, steps, className }: {
|
||||
children: ReactNode; cols?: number; steps?: StatStep[]; className?: string
|
||||
export function StatGrid({ children, cols = 4, steps, className, gap = 12 }: {
|
||||
children: ReactNode; cols?: number; steps?: StatStep[]; className?: string; gap?: number
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('grid gap-3 mb-4 grid-cols-[repeat(var(--cols),minmax(0,1fr))] min-w-0',
|
||||
!steps && 'max-lg:grid-cols-2',
|
||||
...(steps || []).map((st) => STEP_CLS[`${st.at}:${st.cols}`]),
|
||||
'max-sm:gap-2', className)}
|
||||
style={{ ['--cols' as string]: cols }}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
const merged: StatStep[] = steps || [{ at: 'lg', cols: 2 }, { at: 'sm', cols: 1 }]
|
||||
return <Grid cols={cols} steps={merged} gap={gap} className={className}>{children}</Grid>
|
||||
}
|
||||
|
||||
/** 进度条(.bar / .bar i) */
|
||||
/** 进度条:antd Progress(站内只有这一条;bad=异常态用 antd 的 exception 色) */
|
||||
export function ProgressBar({ value, bad, className }: { value: number; bad?: boolean; className?: string }) {
|
||||
const pct = Math.max(0, Math.min(100, Number(value) || 0))
|
||||
return (
|
||||
/* block 不是 inline-block:条子经常和下一行的百分比写在同一个 nowrap 单元格里
|
||||
(首页项目表的「进度」列),inline-block + w-full 会和后面的数字排在同一条基线上,
|
||||
整行比单元格宽 25px,「100%」直接被挤出右边界。块级就天然换行。 */
|
||||
<span className={cn('block h-[5px] bg-fill-secondary rounded-full overflow-hidden min-w-[60px] align-middle', className)}>
|
||||
<i className={cn('block h-full', bad ? 'bg-error' : 'bg-primary')} style={{ width: `${pct}%` }} />
|
||||
</span>
|
||||
<Progress percent={pct} showInfo={false} status={bad ? 'exception' : 'normal'}
|
||||
size="small" className={cn('nex-progress min-w-[60px]', className)} />
|
||||
)
|
||||
}
|
||||
|
||||
export function Divider({ className }: { className?: string }) {
|
||||
return <div className={cn('h-px bg-fill-secondary my-4', className)} />
|
||||
/** 分隔线:antd Divider */
|
||||
export function Divider({ className, dashed }: { className?: string; dashed?: boolean }) {
|
||||
return <AntDivider className={className} dashed={dashed} />
|
||||
}
|
||||
|
||||
/** 空态:antd Empty(简单图,站内不放插画——卡片里那块地方给不起) */
|
||||
export function Empty({ children = '暂无数据', className }: { children?: ReactNode; className?: string }) {
|
||||
return <div className={cn('border border-dashed border-border rounded-lg p-7 text-center text-text-quaternary', className)}>{children}</div>
|
||||
return <AntEmpty className={cn('my-2', className)} image={AntEmpty.PRESENTED_IMAGE_SIMPLE} description={children} />
|
||||
}
|
||||
|
||||
/** 读取中:antd Spin */
|
||||
export function Loading({ children = '读取中…', className }: { children?: ReactNode; className?: string }) {
|
||||
return <div className={cn('p-6 text-center text-text-quaternary text-sm', className)}>{children}</div>
|
||||
return (
|
||||
<Flex vertical align="center" gap={8} className={cn('p-6', className)}>
|
||||
<Spin size="small" />
|
||||
<Typography.Text type="secondary" className="!text-xs">{children}</Typography.Text>
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
|
||||
/** 行内小转圈(按钮、状态条里那颗) */
|
||||
export function Spinner({ className }: { className?: string }) {
|
||||
return <IconLoading spin aria-hidden className={cn('text-xs align-[-1px]', className)} />
|
||||
return <IconLoading spin aria-hidden className={cn('align-[-1px] text-xs', className)} />
|
||||
}
|
||||
|
||||
/** 提示条:成功用默认(青柠底),错误用 danger;只放一句人话,长说明收进抽屉 */
|
||||
/**
|
||||
* 提示条:antd Alert。成功/普通信息用 info(站内 colorInfo=主色),错误用 error。
|
||||
* 只放一句人话,长说明收进抽屉(G2)。
|
||||
*/
|
||||
export function Notice({ children, danger, className, onClose }: {
|
||||
children: ReactNode; danger?: boolean; className?: string; onClose?: () => void
|
||||
}) {
|
||||
if (!children) return null
|
||||
return (
|
||||
<div className={cn('flex items-start gap-2 p-3 rounded-lg border mb-4 text-xs leading-relaxed break-words wrap-anywhere',
|
||||
danger ? 'border-error-border bg-error-bg text-error-hover' : 'border-primary-border bg-primary-bg-hover text-primary-hover',
|
||||
className)}>
|
||||
<div className="min-w-0 flex-1">{children}</div>
|
||||
{onClose && (
|
||||
// 关闭叉走 antd 的 text 按钮(sm 档 24px,正好等于两行 11px 文字的高度),
|
||||
// 只保留 opacity 两级:提示条本身已经是强调色,叉子不该再有第二种悬停底色。
|
||||
<Button size="sm" type="text" className="nex-notice-x shrink-0 self-start opacity-70 hover:!bg-transparent hover:opacity-100"
|
||||
aria-label="关闭提示" title="关闭提示" onClick={onClose} icon={<IconClose />} />
|
||||
)}
|
||||
</div>
|
||||
<Alert className={cn('mb-4', className)} type={danger ? 'error' : 'info'} showIcon
|
||||
message={children} closable={!!onClose} onClose={onClose} />
|
||||
)
|
||||
}
|
||||
|
||||
/** 数据回显(.val)与条件告警(.linehint):规范 §7 G2 —— 版面不放成段解释文字 */
|
||||
export function Value({ children, muted, className }: { children: ReactNode; muted?: boolean; className?: string }) {
|
||||
return <div className={cn('text-xs text-text-secondary leading-relaxed wrap-anywhere', muted && 'text-text-quaternary', className)}>{children}</div>
|
||||
return (
|
||||
<Typography.Text
|
||||
className={cn('!text-xs leading-relaxed wrap-anywhere', muted ? '!text-text-quaternary' : '!text-text-tertiary', className)}
|
||||
type={muted ? undefined : 'secondary'}>{children}</Typography.Text>
|
||||
)
|
||||
}
|
||||
|
||||
export function LineHint({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div className={cn('flex items-baseline gap-1.5 text-xs leading-normal text-warning mt-2', className)}>{children}</div>
|
||||
return (
|
||||
<Flex align="baseline" gap={6} wrap className={cn('mt-2 text-xs leading-normal text-warning', className)}>
|
||||
{children}
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
|
||||
/** 等宽小字(路径 / id / 枚举码) */
|
||||
export function Mono({ children, className, title }: { children: ReactNode; className?: string; title?: string }) {
|
||||
return <span title={title} className={cn('font-mono text-xs ', className)}>{children}</span>
|
||||
return <Typography.Text className={cn('font-mono !text-xs', className)} title={title} copyable={false}>{children}</Typography.Text>
|
||||
}
|
||||
|
||||
/** 文字链(.link):导航用 <Link>,这里只给「打开外部资源 / 下载」 */
|
||||
export function ExtLink({ href, children, className, download }: { href: string; children: ReactNode; className?: string; download?: boolean | string }) {
|
||||
export function ExtLink({ href, children, className, download }: {
|
||||
href: string; children: ReactNode; className?: string; download?: boolean | string
|
||||
}) {
|
||||
return (
|
||||
<a href={href} download={download} target="_blank" rel="noreferrer"
|
||||
className={cn('inline-flex items-center gap-1 text-success text-xs no-underline hover:underline', className)}>
|
||||
<Typography.Link href={href} download={download} target="_blank" rel="noreferrer"
|
||||
className={cn('!inline-flex !items-center gap-1 !text-xs', className)}>
|
||||
{children}<IconExternal className="text-xs" />
|
||||
</a>
|
||||
</Typography.Link>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡片行皮肤(.cardrow)。
|
||||
* 单独导出类名常量:资产管理那张卡要在正文左边插勾选框和头像,套不进
|
||||
* CardRow 的「标题 + 正文 + 右侧动作」三段式,但它必须是同一条分隔线、
|
||||
* 同一套字号,否则两种卡片并排就能看出是两套东西。
|
||||
* 卡片行(.cardrow):标题 + 说明 + 右侧动作,列表里重复项的统一骨架。
|
||||
*
|
||||
* 骨架交给 antd Flex + Typography,分隔线用 colorSplit;
|
||||
* 只留 CARD_ROW 一个类名常量给「要自己排正文」的资产管理卡(同一条分隔线、同一套字号)。
|
||||
*/
|
||||
export const CARD_ROW = 'flex justify-between gap-3 items-start py-3 min-w-0 '
|
||||
+ 'border-b border-fill-secondary last:border-b-0 '
|
||||
export const CARD_ROW = 'flex min-w-0 items-start justify-between gap-3 border-b border-fill-secondary py-3 last:border-b-0 '
|
||||
+ '[&_h4]:m-0 [&_h4]:mb-1 [&_h4]:text-sm [&_h4]:font-semibold [&_h4]:text-text '
|
||||
+ '[&_p]:my-1 [&_p]:mx-0 [&_p]:text-xs [&_p]:text-text-tertiary [&_p]:leading-normal'
|
||||
+ '[&_p]:mx-0 [&_p]:my-1 [&_p]:text-xs [&_p]:leading-normal [&_p]:text-text-tertiary'
|
||||
|
||||
/** 卡片行(.cardrow):标题 + 说明 + 右侧动作,列表里重复项的统一骨架 */
|
||||
export function CardRow({ title, children, right, className, tone = 'border' }: {
|
||||
title?: ReactNode; children?: ReactNode; right?: ReactNode; className?: string; tone?: 'border' | 'plain'
|
||||
}) {
|
||||
|
|
@ -245,46 +314,15 @@ export function CardRow({ title, children, right, className, tone = 'border' }:
|
|||
{title && <h4>{title}</h4>}
|
||||
{children && <div>{children}</div>}
|
||||
</div>
|
||||
{right && <div className="flex items-center gap-2 shrink-0 ">{right}</div>}
|
||||
{right && <Flex gap={8} align="center" wrap className="min-w-0 shrink-0">{right}</Flex>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 元信息一行(.meta) */
|
||||
export function Meta({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div className={cn('flex gap-2 items-center text-text-tertiary text-xs flex-wrap min-w-0', className)}>{children}</div>
|
||||
return <Flex gap={8} align="center" wrap className={cn('min-w-0 text-xs text-text-tertiary', className)}>{children}</Flex>
|
||||
}
|
||||
|
||||
/** 行内动作组(.actions):唯一实现在 Controls.CardActions,这里只转发旧名字 */
|
||||
export { Actions } from './Controls'
|
||||
|
||||
/** 窄屏折成一列的档位(字面量类名,Tailwind 只认源码里出现过的字符串) */
|
||||
const ONE_CLS: Record<string, string> = {
|
||||
'2xl': 'max-2xl:grid-cols-1', xl: 'max-xl:grid-cols-1', lg: 'max-lg:grid-cols-1',
|
||||
md: 'max-md:grid-cols-1', sm: 'max-sm:grid-cols-1'
|
||||
}
|
||||
export type GridCollapse = '2xl' | 'xl' | 'lg' | 'md' | 'sm'
|
||||
|
||||
/**
|
||||
* 通用栅格(.grid / .grid2 / .grid3 / .grid4)。
|
||||
*
|
||||
* oneAt 只管「到某个断点塌成一列」这一种最省事的收法;旧站 .grid3/.grid4 是两段式
|
||||
* (≤1180 先并到两列、≤560 才塌成一列),硬用 oneAt="xl" 会让三列在 1100px 就变成
|
||||
* 一条竖列,所以把 StatGrid 那套 steps 档位挪过来共用:例外写在参数里,不写回 @media。
|
||||
*
|
||||
* 列数走 --cols/--min 两个 CSS 变量 + 字面量工具类,而不是内联 grid-template-columns:
|
||||
* 内联样式会盖掉所有断点类,「窄屏折成一列」就再也写不上去
|
||||
* (旧站 .grid2 在 ≤560 就是单列,用内联 style 之后这一档静默失效)。
|
||||
*/
|
||||
export function Grid({ children, cols = 4, gap = 12, min = 0, oneAt, steps, className }: {
|
||||
children?: ReactNode; cols?: number; gap?: number; min?: number; oneAt?: GridCollapse
|
||||
steps?: GridStep[]; className?: string
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('grid min-w-0 [&>*]:min-w-0 gap-[var(--gap)] grid-cols-[repeat(var(--cols),minmax(var(--min),1fr))]',
|
||||
oneAt && ONE_CLS[oneAt], ...(steps || []).map((st) => STEP_CLS[`${st.at}:${st.cols}`]), className)}
|
||||
style={{ ['--cols' as string]: cols, ['--min' as string]: `${min}px`, ['--gap' as string]: `${gap}px` }}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import type { ReactNode } from 'react'
|
|||
import { Tag as AntTag } from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { statusLabel, statusTone } from '../../lib/format'
|
||||
import { fieldGroupLabelCls } from './field-labels'
|
||||
import { GROUP_LABEL_CLS } from './Controls'
|
||||
|
||||
export type TagSize = 'sm' | 'md'
|
||||
/** 密集档:挂在容器上(表格单元格、TagGroup size="sm"),整片标签一起降 */
|
||||
|
|
@ -104,7 +104,7 @@ export function TagGroup({ children, label, size, className, top }: {
|
|||
}) {
|
||||
return (
|
||||
<div className={cn('nex-taggroup', size === 'sm' && TAG_DENSE, top && 'mt-3', className)}>
|
||||
{label && <span className={fieldGroupLabelCls}>{label}</span>}
|
||||
{label && <span className={GROUP_LABEL_CLS}>{label}</span>}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -34,8 +34,13 @@ export function nodeHint(node: any): string {
|
|||
return [`${node.label}(${STATE_LABEL[node.state] || node.state})`, node.detail].filter(Boolean).join(' — ')
|
||||
}
|
||||
|
||||
/* 序号圆点的填色:实心主色 + 白字(4.6:1)成立,实心 success + 白字不成立
|
||||
(light #52c41a / white = 2.3:1,dark #95de64 / white = 1.8:1),
|
||||
所以「完成」这一档取绿色族的浅底 + 主色字——正是 antd Tag color="success"
|
||||
与站内 <Tag tone="ok"> 用的那三个 token,不新造档位。
|
||||
「进行中」是实心主色(antd 的 processing 就是主色蓝),和完成一眼分得开。 */
|
||||
const NUM: Record<string, string> = {
|
||||
done: 'bg-primary text-on-primary',
|
||||
done: 'bg-success-bg text-success',
|
||||
active: 'bg-primary text-on-primary',
|
||||
failed: 'bg-error text-error-bg',
|
||||
pending: 'bg-fill-secondary text-text-tertiary'
|
||||
|
|
@ -56,8 +61,8 @@ export function Step({ node, index, current, compact, onClick, className }: {
|
|||
className={cn('flex-1 basis-[118px] min-w-[96px] bg-bg-container border rounded-lg py-2 px-3 relative transition-colors',
|
||||
onClick && 'cursor-pointer',
|
||||
current && 'shadow-[0_0_0_1px_var(--ant-color-primary-border)]',
|
||||
st === 'done' && 'border-success-border bg-primary-bg',
|
||||
st === 'active' && 'border-success-border bg-primary-bg shadow-[inset_0_0_0_1px_var(--ant-color-success-border)]',
|
||||
st === 'done' && 'border-success-border bg-success-bg',
|
||||
st === 'active' && 'border-primary-border bg-primary-bg shadow-[inset_0_0_0_1px_var(--ant-color-primary-border)]',
|
||||
st === 'failed' && 'border-error-border bg-bg-container',
|
||||
st === 'pending' && 'border-[var(--ant-color-fill-secondary)] opacity-70', className)}>
|
||||
<div className={cn('flex items-center gap-2 text-xs', st === 'done' ? 'text-success' : 'text-text-tertiary')}>
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ const BASE: Record<TileVariant, string> = {
|
|||
|
||||
/** 命中态:这一块的筛选 / 展开 / 勾选正生效 */
|
||||
const ACTIVE: Record<TileVariant, string> = {
|
||||
item: 'bg-primary-bg border-success-border shadow-[inset_3px_0_0_var(--ant-color-primary)]',
|
||||
item: 'bg-primary-bg border-primary-border shadow-[inset_3px_0_0_var(--ant-color-primary)]',
|
||||
pick: 'border-primary shadow-[inset_0_0_0_1px_var(--ant-color-primary)]',
|
||||
bar: 'border-primary-border bg-bg-container',
|
||||
pill: 'border-border bg-fill-tertiary text-text'
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
/**
|
||||
* 字段标签的字号/颜色档位(与 styles/app.css 里的 .nf-label 同一份配方)。
|
||||
*
|
||||
* 为什么只有类名没有样式:控件的皮肤全部在 antd token 与 app.css 里,
|
||||
* 这里只导出「页面自己写 <label> 时该挂哪个类」,避免又长出一套行内样式。
|
||||
*/
|
||||
|
||||
/** 行内字段标签(挂在 .nex-field 的标签列上,或页面手写的 <label> 上) */
|
||||
export const LABEL_CLS = 'nf-label'
|
||||
/** 标签在上的字段标签 */
|
||||
export const LABEL_STACK_CLS = 'nf-label nf-label-stack'
|
||||
/** 分组说明(ChipBar / TagGroup 行首那句「筛选:」) */
|
||||
export const fieldGroupLabelCls = 'nf-group-label'
|
||||
/** 只读回显的值(与标签同行时保持同一基线) */
|
||||
export const valueCls = 'nf-value'
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* 栅格换算:把「这一排几个块 + 到哪个断点降列」翻译成 antd Row/Col 的断点属性。
|
||||
*
|
||||
* 症状(自绘栅格留下的):列数走 --cols/--min 两个私有变量 + 八个 max-*:grid-cols-N
|
||||
* 字面量,降列节奏用的是 900 / 1100 / 1180 这些私有宽度,和 antd Grid 的
|
||||
* xs…xxl 对不上。于是同一屏里 Card 按 antd 断点换行、指标卡按私有断点换行,
|
||||
* 1100px 上下会同时出现两种列数——这正是用户说的「布局还是不对」的一部分。
|
||||
* 做法:只保留 antd 的六个断点。旧语义 max-xl:grid-cols-2 = 「宽度 ≤1200 时两列」
|
||||
* = antd 的 lg 及以下,所以档位名按**断点下界**解释:命中所有下界更小的断点。
|
||||
* 为什么单独一个文件:Panel(Grid/StatGrid)、Page(Layout/Stack)、Controls
|
||||
* (FormRow)都要铺列,共用一份换算才不会三处三种降列节奏。
|
||||
*/
|
||||
import { Children, type ReactNode } from 'react'
|
||||
import { Col } from 'antd'
|
||||
|
||||
export type Bp = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'
|
||||
const BP_MIN: Record<Bp, number> = { xs: 0, sm: 576, md: 768, lg: 992, xl: 1200, xxl: 1600 }
|
||||
const BP_ORDER: Bp[] = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl']
|
||||
/** 档位名 → 它的下界(max-xl = ≤1200,所以门槛取 1200;max-2xl 取 1600) */
|
||||
const AT_MIN: Record<string, number> = { sm: 576, md: 768, lg: 992, xl: 1200, '2xl': 1600 }
|
||||
|
||||
/** 窄屏折成一列的档位(就是 antd Grid 的断点名,没有 nav/mid/tiny 这类私有档位) */
|
||||
export type GridCollapse = '2xl' | 'xl' | 'lg' | 'md' | 'sm'
|
||||
export type GridStep = { at: GridCollapse; cols: number }
|
||||
/** 指标卡的降列档位与通用栅格同一套 */
|
||||
export type StatStep = GridStep
|
||||
|
||||
/** 列数 + 降列档位 → antd Col 的六个断点值 */
|
||||
export function colSpans(cols: number, oneAt?: GridCollapse, steps?: GridStep[]): Partial<Record<Bp, number>> {
|
||||
const base = Math.max(1, Math.round(24 / Math.max(1, cols)))
|
||||
const out: Partial<Record<Bp, number>> = {}
|
||||
BP_ORDER.forEach((bp) => { out[bp] = base })
|
||||
const rules = [
|
||||
...(steps || []).map((s) => ({ at: s.at as string, cols: s.cols as number })),
|
||||
...(oneAt ? [{ at: oneAt as string, cols: 1 }] : [])
|
||||
].sort((a, b) => (AT_MIN[b.at] ?? 0) - (AT_MIN[a.at] ?? 0)) // 由宽到窄,窄档后覆盖
|
||||
for (const r of rules) {
|
||||
const limit = AT_MIN[r.at] ?? 0
|
||||
const span = Math.max(1, Math.round(24 / r.cols))
|
||||
BP_ORDER.forEach((bp) => { if (BP_MIN[bp] < limit) out[bp] = span })
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** 把 N 个子节点铺进一行栅格(Grid / StatGrid / FormRow / Layout / Stack 共用) */
|
||||
export function toCols(children: ReactNode, spans: Partial<Record<Bp, number>>, colClass?: string): ReactNode[] {
|
||||
return Children.toArray(children).map((child, i) => (
|
||||
<Col key={i} className={colClass} {...spans}>{child}</Col>
|
||||
))
|
||||
}
|
||||
|
|
@ -14,3 +14,4 @@ export * from './Tabs'
|
|||
export * from './IconText'
|
||||
export * from './Tile'
|
||||
export * from './Slider'
|
||||
export * from './grid'
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import { MediaPick, MediaRemove, MediaThumb, type MediaRadius } from '../compone
|
|||
import { RecordAudio, type RecordPickMeta } from '../components/media/RecordAudio'
|
||||
import { useAutoRefresh } from '../hooks'
|
||||
import { useRecordingBusy } from '../stores/recording'
|
||||
import { BarRight, Between, Button, CardActions, Check, Checkbox, Chip, ChipBar, Ctlbar, Drawer, Empty, ErrorText, Field, FieldBlock, FilePick, FormGrid, FormRow, Grid, Input, LINK_CLS, MONO, MUTED, MUTED_MONO, Modal, Notice, NumberInput, PageHead, Pager, Panel, PanelHead, Row, SearchInput, SectionTitle, Spinner, TEXTAREA_TALL, Tabs, Tag, TagGroup, TextArea, ViewSwitch, Stat, StatGrid } from '../components/ui'
|
||||
import { BarRight, Between, Button, CardActions, Check, Checkbox, Chip, ChipBar, Ctlbar, Drawer, Empty, ErrorText, Field, FieldBlock, FilePick, FormGrid, FormRow, Grid, Input, LINK_CLS, MONO, MUTED, MUTED_MONO, Modal, Notice, NumberInput, PageHead, Pager, Panel, PanelHead, Row, SearchInput, SectionTitle, Spinner, Tabs, Tag, TagGroup, TextArea, ViewSwitch, Stat, StatGrid } from '../components/ui'
|
||||
import { IconAdd, IconBlocks, IconBolt, IconClose, IconDelete, IconGrid, IconImage, IconList, IconRobot, IconSound, IconUser, IconVoice } from '../components/icons'
|
||||
|
||||
type AssetType = 'human' | 'scene' | 'voice'
|
||||
|
|
@ -1435,8 +1435,8 @@ export default function AssetLibrary() {
|
|||
</Button>
|
||||
</>}>
|
||||
<FormGrid>
|
||||
{/* 长文本字段要有可写的面积,还要允许用户自己继续拉高(旧站 .drawer-body textarea) */}
|
||||
<div className={TEXTAREA_TALL}>
|
||||
{/* 文本域的高度是内容决定的:kit 的 TextArea 把 rows 当起步行数、按内容长高 */}
|
||||
<div className="min-w-0">
|
||||
<FormRow>
|
||||
<Field label="名称" required>
|
||||
<Input value={form.name} placeholder="角色 / 场景 / 声线名称" onChange={(e) => patchForm({ name: e.target.value })} />
|
||||
|
|
@ -1476,11 +1476,10 @@ export default function AssetLibrary() {
|
|||
<FieldBlock label="一致性提示词">
|
||||
<TextArea value={form.persona_prompt} rows={3} onChange={(e) => patchForm({ persona_prompt: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow>
|
||||
<Field label="声音描述">
|
||||
<Input value={form.voice_profile} onChange={(e) => patchForm({ voice_profile: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="声音描述">
|
||||
<Input value={form.voice_profile} placeholder="音色、语速、口音这类一句话能说清的设定"
|
||||
onChange={(e) => patchForm({ voice_profile: e.target.value })} />
|
||||
</FieldBlock>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
|
@ -1532,11 +1531,9 @@ export default function AssetLibrary() {
|
|||
<FieldBlock label="音色描述">
|
||||
<TextArea value={form.description} rows={3} onChange={(e) => patchForm({ description: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow>
|
||||
<Field label="版本">
|
||||
<Input value={form.version} onChange={(e) => patchForm({ version: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<Field label="版本" width="narrow">
|
||||
<Input value={form.version} onChange={(e) => patchForm({ version: e.target.value })} />
|
||||
</Field>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
|
@ -1942,7 +1939,7 @@ const IMPORT_SUBJECT = 'my-4 py-3 px-3 border-l-2 border-l-primary bg-bg-contain
|
|||
const DIALOG_LIST = 'flex flex-col gap-1 max-h-[258px] overflow-y-auto m-0 p-0 list-none '
|
||||
+ '[&>li]:flex [&>li]:items-center [&>li]:gap-2 [&>li]:flex-wrap [&>li]:py-2 px-2 '
|
||||
+ '[&>li]:border [&>li]:border-fill [&>li]:rounded-md [&>li]:bg-bg-container [&>li>b]:text-xs'
|
||||
const PROVIDER_WARN = 'block mt-2 py-2 px-2 border border-warning-border rounded-sm bg-primary-bg text-warning '
|
||||
const PROVIDER_WARN = 'block mt-2 py-2 px-2 border border-warning-border rounded-sm bg-warning-bg text-warning '
|
||||
+ 'text-xs leading-normal'
|
||||
/**
|
||||
* 参考素材区(图 / 音共用)。
|
||||
|
|
@ -1953,7 +1950,7 @@ const PROVIDER_WARN = 'block mt-2 py-2 px-2 border border-warning-border rounded
|
|||
*/
|
||||
const REF_BOX = 'flex items-end flex-wrap gap-2 mt-2 p-2 border border-border rounded-md bg-bg-container'
|
||||
/** 参考区里的上传按钮:绿色描边表示「这一步不会改母版本体,只是喂料」 */
|
||||
const REF_PICK = 'justify-center border-primary-border text-success'
|
||||
const REF_PICK = 'justify-center border-primary-border text-primary'
|
||||
const REF_HINT = 'basis-full text-text-quaternary text-xs leading-normal'
|
||||
/** 参考区里的整行元素(状态盒) */
|
||||
const REF_FULL = 'basis-full'
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ export default function Dashboard() {
|
|||
{/* 标签列锁 92px:这一表单里最长的是「目标总时长(秒)」92px。
|
||||
不锁的话标签列宽 = minmax(66, max-content),这一格控件会被长标题顶右 15px,
|
||||
整表就长出两条控件左边界(体检 misaligned 唯一报红的表单)。 */}
|
||||
<FormGrid labelWidth={92}>
|
||||
<FormGrid>
|
||||
<h3 className="mb-3" title="流程第 ① 步:创建视频项目">新建长视频项目</h3>
|
||||
|
||||
<FormRow>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { Link } from 'react-router-dom'
|
|||
import { ExtLink } from '../components/ui'
|
||||
import { IconApi, IconBolt, IconDashboard, IconImage, IconPlayCircle, IconVoice } from '../components/icons'
|
||||
/** 页面外壳:行内强调、代码、链接的皮肤统一给一次,正文不重复贴类名 */
|
||||
const SHELL = 'min-w-0 [&_b]:font-semibold [&_b]:text-text [&_a_code]:text-success [&_pre]:m-0'
|
||||
const SHELL = 'min-w-0 [&_b]:font-semibold [&_b]:text-text [&_a_code]:text-primary [&_pre]:m-0'
|
||||
const PRE = 'mt-4 overflow-x-auto rounded-lg border border-border-secondary bg-bg-layout p-3 text-xs leading-loose text-text-secondary font-mono'
|
||||
const TOC_NAV = 'sticky top-[8px] z-[5] mb-7 flex flex-wrap items-center gap-2 rounded-lg '
|
||||
+ 'border border-border-secondary bg-bg-container p-3 backdrop-blur'
|
||||
|
|
@ -34,7 +34,7 @@ const TAG_SECTION = 'scroll-mt-[88px] mt-12 min-w-0 first:mt-0'
|
|||
const TAG_H2 = 'text-lg font-bold mt-1 mb-0 text-text tracking-tight'
|
||||
const TAG_CODE = 'rounded-sm border border-border-secondary bg-bg-layout px-1 py-px text-xs text-primary-hover '
|
||||
+ 'font-mono'
|
||||
const TAG_A = 'text-success no-underline hover:underline'
|
||||
const TAG_A = 'text-primary no-underline hover:underline'
|
||||
const TAG_IMG = 'block w-full rounded-lg border border-border'
|
||||
const TAG_FIGCAPTION = 'flex justify-between gap-3 flex-wrap text-xs text-text-quaternary leading-loose pt-2 px-1 '
|
||||
+ '[&>span]:min-w-0 [&>span+span]:shrink-0 [&>span+span]:text-primary'
|
||||
|
|
|
|||
|
|
@ -651,7 +651,7 @@ export default function ModelCenter() {
|
|||
<form id={FORM_ID} className="min-w-0" onSubmit={(e) => { e.preventDefault(); void save() }}>
|
||||
{/* 锁 76px:这张表同时有 FieldBlock(标签在上)和行内 Field(Temperature / 并发 / RPM)。
|
||||
行内标签只要有一个超过 66px 下限,整表控件左边界就错开(900px 实测 2px)。 */}
|
||||
<FormGrid labelWidth={76}>
|
||||
<FormGrid>
|
||||
{form.media_type === 'llm' && (
|
||||
<>
|
||||
<DrawerSection first title="供应商连接" note="OpenAI 兼容协议">
|
||||
|
|
@ -701,7 +701,7 @@ export default function ModelCenter() {
|
|||
<FieldBlock label="ComfyUI Base URL">
|
||||
<Input value={form.base_url} placeholder="http://10.100.53.199:9200" onChange={(e) => patch({ base_url: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow cols={2} stack>
|
||||
<FormRow cols={2}>
|
||||
<Field label={form.media_type === 'video' ? '扩散模型(UNET GGUF)' : 'GGUF 扩散模型'}>
|
||||
<Input value={form.unet} onChange={(e) => patch({ unet: e.target.value })} />
|
||||
</Field>
|
||||
|
|
@ -750,7 +750,7 @@ export default function ModelCenter() {
|
|||
<FieldBlock label="ComfyUI Base URL">
|
||||
<Input value={form.base_url} placeholder="http://10.100.53.199:9200" onChange={(e) => patch({ base_url: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow cols={2} stack>
|
||||
<FormRow cols={2}>
|
||||
<Field label="模型目录标识">
|
||||
<Input value={form.tts_model} onChange={(e) => patch({ tts_model: e.target.value })} />
|
||||
</Field>
|
||||
|
|
@ -783,7 +783,7 @@ export default function ModelCenter() {
|
|||
)}
|
||||
|
||||
<DrawerSection title="模型身份与调度" note="所有能力通用,仅在此处填写一次">
|
||||
<FormRow cols={3} stack>
|
||||
<FormRow cols={3}>
|
||||
<Field label="显示名称" required>
|
||||
<Input value={form.display_name} onChange={(e) => patch({ display_name: e.target.value })} />
|
||||
</Field>
|
||||
|
|
@ -805,7 +805,7 @@ export default function ModelCenter() {
|
|||
<NumberInput min={1} value={form.timeout_seconds} onChange={ (v) => patch({ timeout_seconds: v })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<FormRow cols={4} stack tight>
|
||||
<FormRow cols={4} tight>
|
||||
<Field label="并发">
|
||||
<NumberInput min={1} value={form.max_concurrency} onChange={ (v) => patch({ max_concurrency: v })} />
|
||||
</Field>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ export default function ProjectDetail() {
|
|||
return (
|
||||
<Empty>
|
||||
未找到项目 #{id},可能已被删除。{' '}
|
||||
<Link to="/" className="text-success text-xs no-underline hover:underline">返回项目总览</Link>
|
||||
<Link to="/" className="text-primary text-xs no-underline hover:underline">返回项目总览</Link>
|
||||
</Empty>
|
||||
)
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ export default function ProjectDetail() {
|
|||
<header className="mb-6 flex flex-wrap items-center justify-between gap-3 min-w-0 max-lg:items-start">
|
||||
<div className="min-w-0">
|
||||
<div className="flex flex-wrap items-center gap-2 min-w-0 max-lg:w-full">
|
||||
<Link to="/" className="text-success text-xs no-underline hover:underline"><IconText icon={<IconArrowBack />}>项目总览</IconText></Link>
|
||||
<Link to="/" className="text-primary text-xs no-underline hover:underline"><IconText icon={<IconArrowBack />}>项目总览</IconText></Link>
|
||||
<Status value={project.status} />
|
||||
{flowDone
|
||||
? <Tag tone="ok">{flowNote}</Tag>
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ export default function UserAdmin() {
|
|||
<Panel>
|
||||
<PanelHead title={selected.display_name || selected.username}
|
||||
right={<Tag tone="mono">#{selected.id}</Tag>} />
|
||||
<FormRow cols={2} stack>
|
||||
<FormRow cols={2}>
|
||||
<Field label="显示名">
|
||||
<Input value={edit.display_name} maxLength={80} onChange={(e) => setEdit((f) => ({ ...f, display_name: e.target.value }))} />
|
||||
</Field>
|
||||
|
|
|
|||
|
|
@ -606,7 +606,7 @@ export default function AgentConsole() {
|
|||
<span className={MUTED}>⌘ / Ctrl + Enter</span>
|
||||
</div>
|
||||
|
||||
<ErrorText className="mt-2.5 block py-2 px-3 border border-error-border rounded-md bg-primary-bg">
|
||||
<ErrorText className="mt-2.5 block py-2 px-3 border border-error-border rounded-md bg-error-bg">
|
||||
{planError}
|
||||
</ErrorText>
|
||||
|
||||
|
|
@ -741,11 +741,15 @@ export default function AgentConsole() {
|
|||
{row.steps.map((stepItem, index) => (
|
||||
<div key={stepItem.action}
|
||||
className={cn('grid grid-cols-[28px_minmax(0,1fr)] gap-3 py-3 px-3 rounded-lg border border-border-secondary bg-bg-container min-w-0',
|
||||
(stepItem.status === 'succeeded' || stepItem.status === 'running') && 'border-success-border bg-primary-bg',
|
||||
stepItem.status === 'failed' && 'border-error-border bg-primary-bg',
|
||||
/* 状态条:一档一色,描边与底纹同族(旧代码是「绿/红描边 + primary 底」,
|
||||
主色还是柠檬绿时看不出来,换成标准蓝就是两条蓝底绿边)。
|
||||
序号圆点里的「成功」取浅底 + 绿字:实心绿配白勾在
|
||||
light #52c41a 上只有 2.3:1、dark #95de64 上 1.8:1,读不出是个勾。 */
|
||||
(stepItem.status === 'succeeded' || stepItem.status === 'running') && 'border-success-border bg-success-bg',
|
||||
stepItem.status === 'failed' && 'border-error-border bg-error-bg',
|
||||
stepItem.status === 'skipped' && 'opacity-68')}>
|
||||
<div className={cn('grid place-items-center w-6 h-6 rounded-full bg-fill-secondary text-text-tertiary text-xs font-bold',
|
||||
stepItem.status === 'succeeded' && 'bg-primary text-on-primary',
|
||||
stepItem.status === 'succeeded' && 'bg-success-bg text-success',
|
||||
stepItem.status === 'running' && 'bg-warning text-warning-bg animate-agent-step',
|
||||
stepItem.status === 'failed' && 'bg-error text-error-bg')}>
|
||||
{stepItem.status === 'succeeded' ? <IconCheck />
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import { Select } from '../../components/forms'
|
|||
import { AudioPlay } from '../../components/media/AudioPlay'
|
||||
import { MediaThumb } from '../../components/media/MediaThumb'
|
||||
import { RecordAudio, type RecordPickMeta } from '../../components/media/RecordAudio'
|
||||
import { Actions, BarRight, Between, Button, CARD_ROW, CardActions, Check, Chip, ChipBar, Ctlbar, Divider, Drawer, Empty, ErrorText, ExtLink, Field, FieldBlock, FilePick, FormGrid, FormRow, IconText, Input, LINK_CLS, LineHint, LinkButton, MONO, MUTED, MUTED_MONO, NumberInput, Panel, PanelHead, Row, SearchInput, SectionTitle, Spinner, TEXTAREA_TALL, PageStack, Table, TableBox, Tabs, Tag, TagGroup, TextArea, cellRight, cellWrap } from '../../components/ui'
|
||||
import { Actions, BarRight, Between, Button, CARD_ROW, CardActions, Check, Chip, ChipBar, Ctlbar, Divider, Drawer, Empty, ErrorText, ExtLink, Field, FieldBlock, FilePick, FormGrid, FormRow, IconText, Input, LINK_CLS, LineHint, LinkButton, MONO, MUTED, MUTED_MONO, NumberInput, Panel, PanelHead, Row, SearchInput, SectionTitle, Spinner, PageStack, Table, TableBox, Tabs, Tag, TagGroup, TextArea, cellRight, cellWrap } from '../../components/ui'
|
||||
import { useSystemStore } from '../../stores/system'
|
||||
import { refresh, useProjectStore } from '../../stores/project'
|
||||
import { notify } from '../../stores/notice'
|
||||
|
|
@ -1220,8 +1220,8 @@ export default function Library() {
|
|||
</Button>
|
||||
</>}>
|
||||
<FormGrid>
|
||||
{/* 正文走纵向 12px 节奏;提示词都是长句,textarea 给足高度并允许手工拉长 */}
|
||||
<div className={cn('flex flex-col gap-3', TEXTAREA_TALL)}>
|
||||
{/* 纵向节奏由 Form.Item 自己给(24);提示词是长句,TextArea 按内容长高 */}
|
||||
<div className="min-w-0">
|
||||
{genType === 'voice' ? (
|
||||
<>
|
||||
<FormRow className="mb-0">
|
||||
|
|
@ -1250,7 +1250,7 @@ export default function Library() {
|
|||
...voiceReferenceOptions(genOwner).map((a: any) => ({
|
||||
value: a.id, label: `${a.name} · ${assetKindLabel(a.kind)} v${a.version}` }))]} />
|
||||
</Field>
|
||||
<FilePick label="上传参考音色" accept="audio/*" className="flex-none border-primary-border text-success"
|
||||
<FilePick label="上传参考音色" accept="audio/*" className="flex-none border-primary-border text-primary"
|
||||
onFiles={(files) => { const f = files[0]; if (f) void sendGenerationReference('voice', genOwner, f) }} />
|
||||
<RecordAudio label="录参考音色" target="参考音色"
|
||||
defaultName={defaultAssetName(genOwner.assets, `${genOwner.name}参考音色`, 'reference')}
|
||||
|
|
@ -1304,7 +1304,7 @@ export default function Library() {
|
|||
</Field>
|
||||
<FilePick label="上传参考图" accept={IMAGE_REF_ACCEPT}
|
||||
title="选择已有定妆 / 三视图 / 场景素材,或临时上传一张图作为本次生成锚点,可显著提升跨镜头一致性。"
|
||||
className="flex-none border-primary-border text-success"
|
||||
className="flex-none border-primary-border text-primary"
|
||||
onFiles={(files) => { const f = files[0]; if (f) void sendGenerationReference(genType, genOwner, f) }} />
|
||||
</GenerationReference>
|
||||
{genSuggestion && (
|
||||
|
|
@ -1365,7 +1365,7 @@ function PickBox({ checked, label, className, onToggle }: {
|
|||
/** 人物头像位(.avatar):只有名字首字母,真定妆图在下方缩略图里 */
|
||||
function Avatar({ name, children }: { name?: string; children: ReactNode }) {
|
||||
return (
|
||||
<div title={name} className="grid place-items-center w-8 h-8 shrink-0 rounded-lg bg-primary-bg-hover text-success">
|
||||
<div title={name} className="grid place-items-center w-8 h-8 shrink-0 rounded-lg bg-primary-bg-hover text-primary">
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
|
@ -1457,7 +1457,7 @@ function RefStatus({ ready, borrowed, note }: { ready: boolean; borrowed: boolea
|
|||
/** 模型未就绪 / 完全没模型的提醒(.provider-warning):说清楚是「还能选」还是「点不动」 */
|
||||
function ProviderWarning({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<small className="block mt-2 px-2 py-2 border border-warning-border rounded-sm bg-primary-bg text-warning text-xs leading-normal">
|
||||
<small className="block mt-2 px-2 py-2 border border-warning-border rounded-sm bg-warning-bg text-warning text-xs leading-normal">
|
||||
{children}
|
||||
</small>
|
||||
)
|
||||
|
|
@ -1468,7 +1468,7 @@ function SuggestionBox({ text, busy, onApply, onDismiss }: {
|
|||
text: string; busy: boolean; onApply: () => void; onDismiss: () => void
|
||||
}) {
|
||||
return (
|
||||
<div className="p-2 bg-primary-bg border border-success-border rounded-md">
|
||||
<div className="p-2 bg-primary-bg border border-primary-border rounded-md">
|
||||
<p className="m-0 mb-2 text-xs leading-relaxed text-text-secondary">{text}</p>
|
||||
<Actions className="mt-0">
|
||||
<Button type="primary" size="sm" disabled={busy} onClick={onApply}>采用为一致性提示词</Button>
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ export default function Review() {
|
|||
<Grid cols={2} oneAt="sm">
|
||||
<div>
|
||||
<h3 className="m-0 mb-2 text-sm"><IconText icon={<IconPass />}>合格</IconText></h3>
|
||||
<FormRow stack>
|
||||
<FormRow>
|
||||
<Field label="审核人"><Input value={approve.reviewer} onChange={(e) => setApprove((f) => ({ ...f, reviewer: e.target.value }))} /></Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="备注">
|
||||
|
|
@ -392,7 +392,7 @@ export default function Review() {
|
|||
</div>
|
||||
<div>
|
||||
<h3 className="m-0 mb-2 text-sm"><IconText icon={<IconReject />}>不合格(可改提示词重做)</IconText></h3>
|
||||
<FormRow stack>
|
||||
<FormRow>
|
||||
<Field label="审核人"><Input value={reject.reviewer} onChange={(e) => setReject((f) => ({ ...f, reviewer: e.target.value }))} /></Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="问题描述">
|
||||
|
|
@ -401,14 +401,14 @@ export default function Review() {
|
|||
<FieldBlock label="覆盖提示词(可选)">
|
||||
<TextArea rows={2} placeholder="留空则沿用原提示词" value={reject.prompt} onChange={(e) => setReject((f) => ({ ...f, prompt: e.target.value }))} />
|
||||
</FieldBlock>
|
||||
<FormRow stack>
|
||||
<FormRow>
|
||||
<Field label="覆盖负面提示词(可选)" width="full">
|
||||
<Input value={reject.negative_prompt} onChange={(e) => setReject((f) => ({ ...f, negative_prompt: e.target.value }))} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<Check checked={reject.regenerate} onChange={(v) => setReject((f) => ({ ...f, regenerate: v }))}>立即重新入队生成</Check>
|
||||
{reject.regenerate
|
||||
? <FormRow stack className="mt-3">
|
||||
? <FormRow className="mt-3">
|
||||
<Field label={<span title="数字越小越先派发;重做会强制覆盖已有产物,配音任务排在生成之前">任务优先级</span>}>
|
||||
<NumberInput min={0} max={9} value={reject.priority} onChange={ (v) => setReject((f) => ({ ...f, priority: v }))} />
|
||||
</Field>
|
||||
|
|
|
|||
|
|
@ -212,7 +212,11 @@ const shotOutputWhich = (d: any, prefer: boolean) => ((d?.preview_ready && prefe
|
|||
|
||||
const issueOf = (shot: any, severity: string) => (shot.issues || []).filter((i: any) => i.severity === severity)
|
||||
|
||||
/** 卡片灯带:失败/阻塞红、已合格绿、在跑绿松,其余不亮(不该为「还没轮到」上色) */
|
||||
/** 卡片灯带:失败/阻塞红、已合格绿、在跑蓝,其余不亮(不该为「还没轮到」上色)。
|
||||
口径与 PipelineConsole / <Tag> 对齐:完成态走 success 绿,进行/排队走主色蓝
|
||||
(antd 的 processing 本来就是主色)。上一版是「已合格=主色、在跑=绿」,
|
||||
那套只有配柠檬绿品牌时才讲得通;换成标准蓝以后,绿=完成、蓝=进行,
|
||||
和「蓝=可点」也不打架,不必再借一档绿松。 */
|
||||
function cardPulse(shot: any) {
|
||||
if (shot.status === 'failed' || issueOf(shot, 'error').length) return 'bad'
|
||||
if (shot.status === 'approved') return 'ok'
|
||||
|
|
@ -220,9 +224,9 @@ function cardPulse(shot: any) {
|
|||
return ''
|
||||
}
|
||||
const PULSE_CLS: Record<string, string> = {
|
||||
ok: 'after:absolute after:inset-x-0 after:bottom-0 after:h-[3px] after:bg-primary-active',
|
||||
ok: 'after:absolute after:inset-x-0 after:bottom-0 after:h-[3px] after:bg-success',
|
||||
bad: 'after:absolute after:inset-x-0 after:bottom-0 after:h-[3px] after:bg-error',
|
||||
run: 'after:absolute after:inset-x-0 after:bottom-0 after:h-[3px] after:bg-success'
|
||||
run: 'after:absolute after:inset-x-0 after:bottom-0 after:h-[3px] after:bg-primary'
|
||||
}
|
||||
|
||||
/** 导出这一屏的三种格式(后端按 fmt 生成附件) */
|
||||
|
|
@ -1615,7 +1619,7 @@ export default function Storyboard() {
|
|||
</Actions>
|
||||
|
||||
<Divider />
|
||||
<div className="rounded-lg border border-success-border bg-[linear-gradient(145deg,var(--ant-color-primary-bg),var(--ant-color-bg-container)_65%)] p-3">
|
||||
<div className="rounded-lg border border-primary-border bg-[linear-gradient(145deg,var(--ant-color-primary-bg),var(--ant-color-bg-container)_65%)] p-3">
|
||||
<Between>
|
||||
<b className="text-sm text-primary-hover">AI 生成关键帧</b>
|
||||
<Tag tone={keyframeModel?.available ? 'ok' : 'warn'}>
|
||||
|
|
@ -1879,7 +1883,7 @@ function ShotCard({
|
|||
/* 顺序 = 基础 → 选中 → 拖拽落点 → 勾选:tailwind-merge 留最后一条,
|
||||
「勾选」是横跨视图的批量态,切到分镜表时它必须还看得见,
|
||||
所以让 picked 最后写,绝不被「当前镜头」覆盖掉。 */
|
||||
selected && 'border-primary-active shadow-[inset_0_0_0_1px_var(--ant-color-success-border),0_8px_22px_-14px_var(--ant-color-fill-secondary)]',
|
||||
selected && 'border-primary-active shadow-[inset_0_0_0_1px_var(--ant-color-primary-border),0_8px_22px_-14px_var(--ant-color-fill-secondary)]',
|
||||
draggedOver && 'border-info border-dashed',
|
||||
picked && 'border-primary-border bg-primary-bg shadow-[inset_0_0_0_1px_var(--ant-color-primary-border)]')}>
|
||||
{/* 卡片有两块热区,探针各认一块(见 scripts/ui/audit.py 的 OVERLAYS):
|
||||
|
|
|
|||
|
|
@ -839,7 +839,7 @@ function SegmentRow({ seg, i, count, item, queue, shot, transitions, busy, open,
|
|||
</div>
|
||||
{open && (
|
||||
<>
|
||||
<FormRow cols={6} stack tight className="mt-2 [&_input]:px-2 [&_input]:text-xs">
|
||||
<FormRow cols={6} tight className="mt-2 [&_input]:px-2 [&_input]:text-xs">
|
||||
<Field label="片段名称">
|
||||
<Input key={`label-${seg.label}`} defaultValue={seg.label} onBlur={txt('label', '片段名称')} />
|
||||
</Field>
|
||||
|
|
|
|||
|
|
@ -52,25 +52,21 @@ h3 { font-size: var(--ant-font-size-heading-5); line-height: var(--ant-line-heig
|
|||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
结构性变量:等号右边全是 antd token,没有一个新的数
|
||||
-----------------------------------------------------------------------------
|
||||
它们存在的唯一理由是「同一档数值要被三个地方引用,且需要能从容器上覆盖」:
|
||||
· --label-w / --field-label-w 字段标签列宽——「标题与控件对齐」的机制本体
|
||||
· --tag-* 标签两档度量——容器降档时整片一起降
|
||||
它们存在的唯一理由是「同一档数值要被三处引用,且需要能从容器上覆盖」:
|
||||
· --tag-* 标签两档度量——容器降档时整片一起降
|
||||
字段标签列宽 `--label-w` 已经整层删除:标签移到控件上方之后(antd
|
||||
Form.Item 的 layout="vertical"),「标题与控件对齐」由 antd 的表单栅格负责,
|
||||
站内不再有第二把量标签的尺子。
|
||||
顶栏高度 --nex-bar 不在这里:它的唯一出处是 theme/antd.ts 的 HEADER_HEIGHT,
|
||||
由 applyRootVars() 和 --ant-* 一起写进 `:root`,这里再抄一遍就是两个数。
|
||||
══════════════════════════════════════════════════════════════════════════ */
|
||||
:root {
|
||||
/* 标签列宽:工具条 / 卡片动作行 / 胶囊行都用 0(标签挨着控件),
|
||||
只有 .nex-form 把它抬到 --field-label-w,整表共用一条控件左边界。
|
||||
66px 是「两个中文字 + 星号」的经验宽度,属于栅格参数,不是字阶。 */
|
||||
--label-w: 0px;
|
||||
--field-label-w: 66px;
|
||||
|
||||
/* 标签两档:md 用 antd 的正文档 + controlHeightSM,sm 整档落到 fontSizeSM。
|
||||
旧的 main(20/11) 与 sm(18/10) 是两把自造的尺子,现在两档都从 antd 取值。 */
|
||||
--tag-h: var(--ant-control-height-sm); /* 24 */
|
||||
--tag-px: var(--ant-padding-xs); /* 8 */
|
||||
--tag-gap: var(--ant-margin-xxs); /* 4 */
|
||||
--tag-text: var(--ant-font-size); /* 14 */
|
||||
--tag-h: var(--ant-control-height-sm); /* 24 */
|
||||
--tag-px: var(--ant-padding-xs); /* 8 */
|
||||
--tag-gap: var(--ant-margin-xxs); /* 4 */
|
||||
--tag-text: var(--ant-font-size); /* 14 */
|
||||
--tag-h-sm: calc(var(--ant-control-height-sm) - 4px); /* 20 */
|
||||
--tag-px-sm: var(--ant-padding-xxs); /* 4 */
|
||||
--tag-gap-sm: var(--ant-margin-xxs); /* 4 */
|
||||
|
|
@ -78,203 +74,65 @@ h3 { font-size: var(--ant-font-size-heading-5); line-height: var(--ant-line-heig
|
|||
}
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
字段体系:「标题与控件对齐」的唯一机制
|
||||
表单 glue:结构交给 Ant Design 的 Form.Item,这里只补三件它接不住的事
|
||||
-----------------------------------------------------------------------------
|
||||
症状(用户截图里那些):同一张表单里「显示名」的输入框比「角色」右移十几 px;
|
||||
筛选栏里标签在上、控件在下,一个字段吃掉整行。
|
||||
做法:标签列宽是一个 CSS 变量(--label-w),不是每个字段自己写的宽度。
|
||||
· 表单作用域(.nex-form)把它抬到 --field-label-w,整表共用一条控件左边界;
|
||||
· 工具条(.nex-ctlbar / .nex-card-actions / .nex-chipbar)压回 0,标签挨着控件;
|
||||
· 只给下限不给上限(minmax),比默认宽的中文标题宁可把那一格控件顶右,也不截断。
|
||||
需要严格对齐的抽屉表单由 <FormGrid labelWidth={n}> 把上下限锁成同一个数,
|
||||
此时超长标题自动折行(.nf-label 允许 anywhere)。
|
||||
控件本体(Ant Design)永远不写宽高:.nf-ctl 里的控件一律撑满列宽。
|
||||
症状(2026-11 用户第二轮截图的真身):资产库编辑抽屉里「标签在左」的三列字段
|
||||
和「标签在上」的长字段混排,列边界参差;只放一个字段的行把输入框缩成
|
||||
一小截;`nex-textarea-tall` 把 rows=2 的文本域撑到 150px。
|
||||
做法:字段 = antd `Form.Item`(layout="vertical",标签一律在上)、
|
||||
行 = antd `Row`/`Col`(FormRow)、横条 = antd `Flex`(Ctlbar)。
|
||||
列边界与降列只有 Row/Col 一个来源(components/ui/grid.tsx),
|
||||
旧的 --label-w / .nf-ctl / .nf-w-* / 六条 @media 降列整层删除。
|
||||
CSS 只剩下面这四件 antd 自己接不到的事。
|
||||
══════════════════════════════════════════════════════════════════════════ */
|
||||
|
||||
/* 表单作用域:12 等分栅格 + 标签列宽。列边界只在这里定义,FormRow 只负责跨格。 */
|
||||
.nex-form {
|
||||
--label-w: var(--field-label-w);
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--form-cols, 12), minmax(0, 1fr));
|
||||
gap: var(--form-gap-y, var(--ant-margin-sm)) var(--form-gap-x, var(--ant-margin));
|
||||
align-items: start;
|
||||
min-width: 0;
|
||||
}
|
||||
/* 直接放在 FormGrid 里的字段独占一行(页面忘了写 FormRow 也不会挤成一列宽) */
|
||||
.nex-form > .nex-field, .nex-form > .nex-field-block { grid-column: 1 / -1 }
|
||||
/* 表单里混进非字段块(Panel、Notice、普通 div)时同样铺满整行:
|
||||
12 等分栅格下,没写 grid-column 的块会掉进 1/12 轨道,整张卡被压成 40px 宽。 */
|
||||
.nex-form > :not(.nex-form-row):not(.nex-field):not(.nex-field-block) { grid-column: 1 / -1; min-width: 0 }
|
||||
/* ① 控件撑满列宽。antd 的 Select / InputNumber / DatePicker 默认按内容取宽,
|
||||
放进 24 等分的 Col 里会各自缩成一截,同一行的三个字段右边界永远不齐。
|
||||
只管「表单作用域」和「显式给了宽度的字段」:工具条里没写宽度的字段
|
||||
仍按内容取宽(那里没有列宽可撑,撑满会把一颗下拉顶成整条工具条宽)。 */
|
||||
.nex-form .nex-field .ant-form-item-control-input-content > :is(.ant-select, .ant-input, .ant-input-affix-wrapper,
|
||||
.ant-input-number, .ant-picker, .ant-mentions, .ant-cascader, .ant-segmented, .ant-radio-group, .ant-upload-wrapper,
|
||||
textarea),
|
||||
.nex-field-fill .ant-form-item-control-input-content > :is(.ant-select, .ant-input, .ant-input-affix-wrapper,
|
||||
.ant-input-number, .ant-picker, .ant-mentions, .ant-cascader, .ant-segmented, .ant-radio-group, .ant-upload-wrapper,
|
||||
textarea) { width: 100%; min-width: 0 }
|
||||
|
||||
/* 表单里的一行:有列数按跨格落位,没列数 auto-fit 自己降列 */
|
||||
.nex-form-row {
|
||||
grid-column: 1 / -1;
|
||||
display: grid;
|
||||
align-items: start;
|
||||
min-width: 0;
|
||||
}
|
||||
.nex-form-row.nf-row-grid { grid-template-columns: repeat(var(--form-cols, 12), minmax(0, 1fr)) }
|
||||
/* auto-fit 的最小轨要用 min(基准, 100%):容器窄于基准(审核台右栏只有 173px,
|
||||
基准 200px)时,裸 minmax(200px,1fr) 的轨不会收缩,字段整个顶出卡片 27px。 */
|
||||
.nex-form-row.nf-row-auto { grid-template-columns: repeat(auto-fit, minmax(min(var(--row-min, 200px), 100%), 1fr)) }
|
||||
.nex-form-row { gap: var(--form-gap-y, var(--ant-margin-sm)) var(--form-gap-x, var(--ant-margin)) }
|
||||
.nex-form-row.nf-tight { gap: var(--form-gap-y-tight, var(--ant-margin-xs)) var(--form-gap-x-tight, var(--ant-margin-sm)) }
|
||||
/* 基准栅格(FormGrid)里 tight 只准收纵向呼吸,列间距必须留在表单基准上:
|
||||
12 等分轨道里一换 column-gap,列线就按「前面已经过了几条轨道」累计漂移——
|
||||
992px 下同一个抽屉里 cols-3 行与 cols-4 tight 行的第二列控件左缘量出 465 / 467。 */
|
||||
.nex-form .nex-form-row.nf-tight { column-gap: var(--form-gap-x, var(--ant-margin)) }
|
||||
/* 跨格:cols 只决定「这行几个字段」。降列节奏站在 antd Grid 的断点上
|
||||
(<1200 两列字段拍平、三/四列变两列;<992 全部最多两列;<768 一行一个)。 */
|
||||
.nf-cols-2 > * { grid-column: span 6 }
|
||||
.nf-cols-3 > * { grid-column: span 4 }
|
||||
.nf-cols-4 > * { grid-column: span 3 }
|
||||
.nf-cols-6 > * { grid-column: span 2 }
|
||||
@media (max-width: 1200px) {
|
||||
.nf-cols-2 > * { grid-column: span 12 }
|
||||
.nf-cols-3 > *, .nf-cols-4 > * { grid-column: span 6 }
|
||||
}
|
||||
@media (max-width: 992px) {
|
||||
.nf-cols-2 > * { grid-column: span 12 }
|
||||
.nf-cols-3 > *, .nf-cols-4 > *, .nf-cols-6 > * { grid-column: span 6 }
|
||||
}
|
||||
@media (max-width: 768px) { .nex-form-row > * { grid-column: 1 / -1 } }
|
||||
/* 触摸档(<576 = antd Grid 的 xs):标签一律退回控件上方,只准堆叠,不准并排。
|
||||
原因:这一档一行一个字段,标签列没有对齐对象,压成 0 等于把宽度交给每条标题自己——
|
||||
576px 的个人中心量出同一张表里控件左缘 137 / 149,430px 差到 23px,手机上最扎眼的就是这种歪。
|
||||
堆叠之后控件共用容器左缘,一个盒子只剩一条列线,长中文标题也不用挤在一行后面被裁。
|
||||
断点在这里写字面量,和 styles/index.css 是同一条已登记例外(media query 读不到 var())。 */
|
||||
@media (max-width: 576px) {
|
||||
.nex-form .nex-field { grid-template-columns: minmax(0, 1fr); row-gap: var(--ant-margin-xxs); align-items: start }
|
||||
.nex-form .nex-field > .nf-label { line-height: var(--ant-line-height) }
|
||||
/* 有说明文字的字段平时靠行高对齐控件首行,堆叠后这层补偿必须撤掉 */
|
||||
.nex-form .nex-field.nf-has-hint > .nf-label { line-height: var(--ant-line-height) }
|
||||
.nex-form .nex-field > .nf-hint { grid-column: 1 }
|
||||
}
|
||||
/* 独占整行:width="full" 或 data-full(表格上方的长说明字段) */
|
||||
.nex-form-row > .nf-w-full, .nex-form-row > [data-full] { grid-column: 1 / -1 }
|
||||
/* stack:标签退回控件上方(抽屉里的长标题字段、代码类输入)。
|
||||
字段自己仍是 grid,所以这里改的是列轨道,而不是 flex-direction。 */
|
||||
.nex-form-row.nf-stack > .nex-field { grid-template-columns: minmax(0, 1fr); row-gap: var(--ant-margin-xxs); align-items: start }
|
||||
.nex-form-row.nf-stack > .nex-field > .nf-label { line-height: var(--ant-line-height) }
|
||||
.nex-form-row.nf-stack > .nex-field > .nf-hint { grid-column: 1 }
|
||||
.nex-field-block > .nf-hint { grid-column: auto }
|
||||
/* ② 工具条 / 动作行里的字段不留竖向边距:Form.Item 的 24px 是给竖排表单的,
|
||||
横贴一排之后多出来的下边距会把同排的按钮顶歪半格。 */
|
||||
.nex-ctlbar .ant-form-item, .nex-card-actions .ant-form-item { margin-block-end: 0 }
|
||||
|
||||
/* 行内字段:标签在左、控件在右,两列共用同一条基线 */
|
||||
.nex-field {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(var(--label-w), var(--label-max, max-content)) minmax(0, 1fr);
|
||||
column-gap: var(--ant-padding-xs);
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
/* 标签在上的长字段(多行文本、上传区) */
|
||||
.nex-field-block { display: flex; flex-direction: column; gap: var(--ant-margin-xxs); min-width: 0 }
|
||||
/* ③ tight 行(一行全是窄字段的批量设置):间距压到半档,其余仍由 Form.Item 自己给 */
|
||||
.nex-form-row.nf-tight .ant-form-item { margin-block-end: var(--ant-margin-xs) }
|
||||
|
||||
/* 标签比控件小一档(fontSizeSM + 三级文字),这样一行里永远是「控件读、标签让」。
|
||||
antd 的 Form.Item label 是 14 级,本站字段密度比标准表单高,这一条是有意为之。 */
|
||||
.nf-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--ant-margin-xxs);
|
||||
font-size: var(--ant-font-size-sm);
|
||||
line-height: var(--ant-line-height);
|
||||
color: var(--ant-color-text-tertiary);
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
/* 标签在上的字段没有对齐补偿,行高回到正常值 */
|
||||
.nf-label-stack { line-height: var(--ant-line-height) }
|
||||
/* 星号和标签文字是同一个 flex item,否则列方向会把「*」顶到下一行 */
|
||||
.nf-req { color: var(--ant-color-error); font-weight: var(--ant-font-weight-strong); margin-inline-start: 1px }
|
||||
.nex-field-block .nf-label { flex: none }
|
||||
/* 有说明文字时标签与控件首行对齐:用行高等于控件高度居中,比 align-items:start + padding 稳。
|
||||
32px 这个数来自 antd 自己的 controlHeight,控件降档时它自己跟着变。 */
|
||||
.nf-has-hint { align-items: start }
|
||||
.nf-has-hint > .nf-label { line-height: var(--ant-control-height) }
|
||||
.nf-ctl { display: block; min-width: 0 }
|
||||
.nf-hint {
|
||||
grid-column: 2;
|
||||
/* ④ 字段下的提示(extra)与标题折行。antd 的 extra 是正文档 14,站内说明文字
|
||||
统一 12(规范 §1);标签默认 nowrap + 省略号,中文长标题会被吃掉尾巴,
|
||||
宁可让它折到第二行——标题被裁的字段没人知道自己在填什么。 */
|
||||
.nex-field .ant-form-item-extra {
|
||||
min-height: 0;
|
||||
font-size: var(--ant-font-size-sm);
|
||||
line-height: var(--ant-line-height-sm);
|
||||
color: var(--ant-color-text-quaternary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.nex-field-block > .nf-hint { grid-column: auto }
|
||||
.nex-field .ant-form-item-label { white-space: normal; overflow: visible }
|
||||
.nex-field .ant-form-item-label > label { height: auto; white-space: normal }
|
||||
/* 必填星号:antd 画在标签前,颜色取它自己的 colorError,这里只保证不被折行拆开 */
|
||||
.nex-req { color: var(--ant-color-error); font-weight: var(--ant-font-weight-strong); margin-inline-start: 1px }
|
||||
|
||||
/* 控件撑满字段列:antd 的 Select/Picker 默认宽度随内容收缩,不写这条会长短不齐 */
|
||||
.nf-ctl > *:only-child { min-width: 0 }
|
||||
.nf-ctl > .ant-select,
|
||||
.nf-ctl > .ant-input,
|
||||
.nf-ctl > .ant-input-affix-wrapper,
|
||||
.nf-ctl > .ant-input-number,
|
||||
.nf-ctl > .ant-picker,
|
||||
.nf-ctl > .ant-input-textarea,
|
||||
.nf-ctl > textarea,
|
||||
.nf-ctl > .ant-mentions,
|
||||
.nf-ctl > .ant-segmented,
|
||||
.nf-ctl > .ant-radio-group,
|
||||
.nf-ctl > .ant-slider,
|
||||
.nf-ctl > .ant-upload-wrapper { width: 100% }
|
||||
/* ── 卡片(Panel = antd Card):标题与副标题是中文短语,默认 ellipsis 会裁掉半句 ── */
|
||||
.nex-panel .ant-card-head-title { white-space: normal; overflow: visible; text-overflow: clip }
|
||||
.nex-panel .ant-card-extra { white-space: normal }
|
||||
/* Card 的 body 不是 flex 子项,里面的 Row/Col 想收缩必须先从 min-width:auto 解放出来 */
|
||||
.nex-panel .ant-card-body { min-width: 0 }
|
||||
.nex-panel .ant-card-body > * { min-width: 0 }
|
||||
|
||||
/* 控件宽度意图(工具条里的 flex basis / 栅格里的跨列都由同一档决定)。
|
||||
--nf-ctl-min 是这一档留给「控件本体」的最小宽,下面那条 :has 规则用它兜底。 */
|
||||
.nf-w-default { --nf-ctl-min: 0px; min-width: 0 }
|
||||
.nf-w-narrow { --nf-ctl-min: 118px; flex: 0 1 118px; min-width: 0 }
|
||||
.nf-w-grow { --nf-ctl-min: 190px; flex: 1 1 190px; min-width: 0 }
|
||||
.nf-w-wide { --nf-ctl-min: 280px; flex: 1 1 280px; min-width: 0 }
|
||||
.nf-w-full { flex: 0 0 100%; width: 100% }
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
值型控件(下拉 / 分段 / 单选组):档位的预算给控件,不给「标签 + 控件」
|
||||
──────────────────────────────────────────────────────────────────────────
|
||||
症状(用户说的「下拉控件的样式」真身):素材墙排序「按更新时间」、用户管理角色
|
||||
「全部角色」、总览「有限思考」全被省略号咬掉尾巴,量出来 91>70 / 77>70 / 77>46。
|
||||
根因:nf-w-* 写的是 flex-basis = 整字段宽,而标签列是 max-content——
|
||||
标签每多一个字,控件就少十几 px。同一个 narrow 档包两个字段,
|
||||
「状态 全部状态」够(93px)、「排序 按更新时间」不够(107px):
|
||||
能不能看全是标签字数决定的,这不是设计,是巧合。
|
||||
做法:这类控件的「内容宽」就是它必须占的宽(选中值是筛选条件本身,看不见等于没筛),
|
||||
所以字段基线交回内容(flex-basis:auto),档位降级成挂在 .nf-ctl 上的 min-width。
|
||||
标签长 → 整字段顶宽,一行放不下就整字段换行(§7 唯一的降档方式)。
|
||||
不在这条规则里的:输入框 / 数字框 / 日期框——它们没有「内容宽度」可言
|
||||
(intrinsic 是 size 属性给的 20 字符 ≈ 175px,按内容取宽会把窄数字框撑成 260px),
|
||||
撑满列宽才是正解,所以照旧吃 flex-basis。
|
||||
代价:工具条更早换行;字段宽度随选中值变化(选长值会变宽),这是刻意的取舍。
|
||||
══════════════════════════════════════════════════════════════════════════ */
|
||||
.nex-field:has(> .nf-ctl > :is(.ant-select, .ant-segmented, .ant-radio-group)) { flex-basis: auto }
|
||||
.nex-field:has(> .nf-ctl > :is(.ant-select, .ant-segmented, .ant-radio-group)) > .nf-ctl {
|
||||
min-width: var(--nf-ctl-min, 0px);
|
||||
}
|
||||
.nex-form-row > .nf-w-full, .nex-form > .nf-w-full { grid-column: 1 / -1 }
|
||||
.nex-form-row > .nf-w-narrow { min-width: 0 }
|
||||
|
||||
/* 分组说明(ChipBar / TagGroup 行首那句「筛选:」) */
|
||||
.nf-group-label { font-size: var(--ant-font-size-sm); color: var(--ant-color-text-quaternary); margin-inline-end: var(--ant-margin-xxs) }
|
||||
/* 与标签同行的只读回显值:同一基线、同一字号档 */
|
||||
.nf-value { font-size: var(--ant-font-size); color: var(--ant-color-text-secondary); overflow-wrap: anywhere }
|
||||
|
||||
/* ── 控件容器(三档之外没有第四种横排)───────────────────────────────────
|
||||
Ctlbar 含控件的横条(带一档下边距);CardActions 卡片内动作行(不带);
|
||||
BarRight 右靠的一组控件。三者只做布局,不画皮肤。
|
||||
/* ── 控件容器 ─────────────────────────────────────────────────────────────
|
||||
Ctlbar / CardActions / BarRight 现在就是 antd <Flex wrap>(排布由组件给),
|
||||
CSS 只剩一条:工具条与正文之间留一档呼吸。
|
||||
Dense 除了给 antd 下发 componentSize="small",还落下 .nex-dense 这个标记:
|
||||
自绘的那几处(chip)读不到 ConfigProvider,只能靠它对齐到同一个 controlHeightSM。 */
|
||||
.nex-ctlbar { --label-w: 0px; display: block; min-width: 0; margin-block-end: var(--ant-margin-sm) }
|
||||
.nex-ctlbar-inner {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--ant-margin-xs) var(--ant-margin-sm);
|
||||
min-width: 0;
|
||||
}
|
||||
.nex-card-actions {
|
||||
--label-w: 0px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--ant-margin-xs);
|
||||
min-width: 0;
|
||||
}
|
||||
.nex-barright { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--ant-margin-xs); margin-inline-start: auto; min-width: 0 }
|
||||
自绘的那几处(checkable tag 的高度)读不到 ConfigProvider,只能靠它对齐
|
||||
到同一个 controlHeightSM。 */
|
||||
.nex-ctlbar { margin-block-end: var(--ant-margin-sm) }
|
||||
|
||||
/* ── 下拉面板:宁可临时压住右边内容,也不让用户盲选 ────────────────────
|
||||
症状:时间线 / 交付页的字幕模式、配音来源这些选项,文案本身就是说明
|
||||
|
|
@ -294,77 +152,46 @@ h3 { font-size: var(--ant-font-size-heading-5); line-height: var(--ant-line-heig
|
|||
/* 多选/标签式选项(tag 里的文字)同样按内容取宽,但保持单行 */
|
||||
.nex-select-popup .ant-select-item { align-items: center }
|
||||
|
||||
/* ── 可点胶囊(Chip):与同排控件等高,只读回显一律走 Tag ──────────────────
|
||||
底色 / 描边 / 文字三件套用 antd 的 fill 层级,选中态换成主色实心 +
|
||||
colorTextLightSolid(antd 主按钮的那一对),没有第五种配色。 */
|
||||
.nex-chipbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--ant-margin-xs);
|
||||
min-width: 0;
|
||||
margin-block-end: var(--ant-margin-sm);
|
||||
}
|
||||
.nex-chip {
|
||||
/* ── 可点胶囊(Chip = antd Tag.CheckableTag)──────────────────────────────
|
||||
配色、选中态、hover 全是 antd 自己的(选中=主色实心 + colorTextLightSolid),
|
||||
CSS 只做一件事:让胶囊和同排的 antd 控件严格等高。
|
||||
antd 的 Tag 是按行高排的(20px),而工具条里的控件是 24/32——
|
||||
差的那几 px 就是用户说的「筛选条一排高低不齐」。
|
||||
档位与 antd 同源:容器是 Dense(componentSize=small)就 24,否则 32。 */
|
||||
.nex-chipbar { margin-block-end: var(--ant-margin-sm) }
|
||||
.nex-chip.ant-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--ant-margin-xxs);
|
||||
height: var(--ant-control-height);
|
||||
padding-inline: var(--ant-padding-sm);
|
||||
border: 1px solid var(--ant-color-border);
|
||||
/* 胶囊:antd 没有 borderRadiusFull 这个 token,全站只有 chip 与 badge 两处写死 9999px */
|
||||
border-radius: 9999px;
|
||||
background: var(--ant-color-fill-tertiary);
|
||||
color: var(--ant-color-text);
|
||||
margin-inline-end: 0;
|
||||
padding-inline: var(--ant-padding-xs);
|
||||
font-size: var(--ant-font-size-sm);
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
transition: background-color .14s ease, border-color .14s ease, color .14s ease;
|
||||
}
|
||||
.nex-chip:hover { background: var(--ant-color-fill-secondary); border-color: var(--ant-color-primary-border-hover); color: var(--ant-color-text) }
|
||||
.nex-chip.is-on {
|
||||
background: var(--ant-color-primary);
|
||||
border-color: var(--ant-color-primary);
|
||||
color: var(--ant-color-text-light-solid);
|
||||
font-weight: var(--ant-font-weight-strong);
|
||||
}
|
||||
.nex-chip.is-on:hover { background: var(--ant-color-primary-hover); border-color: var(--ant-color-primary-hover) }
|
||||
.nex-chip.is-off { opacity: .45; cursor: not-allowed }
|
||||
/* 紧凑档:容器是 Dense(同排 antd 控件 24px)时,chip 跟着降到同一档 */
|
||||
.nex-dense .nex-chip { height: var(--ant-control-height-sm); padding-inline: var(--ant-padding-xs) }
|
||||
.nex-chip-sm { height: var(--ant-control-height-sm); padding-inline: var(--ant-padding-xs); font-size: var(--ant-font-size-sm) }
|
||||
.nex-dense .nex-chip.ant-tag, .nex-chip-sm.ant-tag { height: var(--ant-control-height-sm) }
|
||||
/* 禁用:5.29 的 CheckableTag 没有 disabled,语义由 Controls.Chip 贴 inline style,
|
||||
这里只负责把「点不动」这件事在光标上也说一遍 */
|
||||
.nex-chip.is-off.ant-tag { cursor: not-allowed }
|
||||
|
||||
/* 多选回显:选中态胶囊 + 移除叉(与 Tag 同一套色调:primary-bg / -border / primary) */
|
||||
.nex-tag-chip {
|
||||
/* 多选回显 = antd Tag(closable):与 Tag 同度量,色调走 primary 那一族 */
|
||||
.nex-tag-chip.ant-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--ant-margin-xxs);
|
||||
max-width: 100%;
|
||||
min-height: var(--tag-h);
|
||||
margin-inline-end: 0;
|
||||
padding-inline: var(--tag-px);
|
||||
border: 1px solid var(--ant-color-primary-border);
|
||||
border-radius: var(--ant-border-radius-sm);
|
||||
border-color: var(--ant-color-primary-border);
|
||||
background: var(--ant-color-primary-bg);
|
||||
color: var(--ant-color-primary);
|
||||
font-size: var(--tag-text);
|
||||
line-height: var(--ant-line-height-sm);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.nex-tag-chip-x {
|
||||
flex: none;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: inherit;
|
||||
font-size: var(--ant-font-size);
|
||||
line-height: 1;
|
||||
padding: 0 var(--ant-padding-xxs);
|
||||
cursor: pointer;
|
||||
opacity: .65;
|
||||
}
|
||||
.nex-tag-chip-x:hover { opacity: 1 }
|
||||
.nex-tag-chip .ant-tag-close-icon { color: inherit; font-size: var(--ant-font-size-sm) }
|
||||
|
||||
/* ── 标签度量(Tag / Status / Badge 共用一套尺子)──────────────────────────
|
||||
尺寸不写在标签上:容器(TagGroup、密集表格)把 --tag-* 压到 sm 档,
|
||||
|
|
@ -405,7 +232,7 @@ h3 { font-size: var(--ant-font-size-heading-5); line-height: var(--ant-line-heig
|
|||
.nex-tag-icon { display: inline-flex; align-items: center; line-height: 0 }
|
||||
/* 只读标签行:组内一档、组与下方一档半,定死不商量 */
|
||||
.nex-taggroup { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ant-margin-xs); min-width: 0; margin-block-end: var(--ant-margin-sm) }
|
||||
.nex-taggroup > .nf-group-label { flex: none }
|
||||
.nex-taggroup > span:first-child { flex: none }
|
||||
|
||||
/* ── 分页条:page_size 唯一的家 ─────────────────────────────────────────── */
|
||||
.nex-pager {
|
||||
|
|
@ -450,15 +277,10 @@ h3 { font-size: var(--ant-font-size-heading-5); line-height: var(--ant-line-heig
|
|||
.nex-segmented .ant-segmented-item-label { display: flex; align-items: center; justify-content: center }
|
||||
.nex-segmented .ant-segmented-item-label > span { min-width: 0; overflow: hidden; text-overflow: ellipsis }
|
||||
|
||||
/* 长文本字段的最小高度:挂在容器上,往抽屉里加字段的人不必再记一遍。
|
||||
只准命中 textarea:以前连带命中了 .ant-input / affix-wrapper,
|
||||
抽屉里「名称」这种单行 Input 也被顶成 96px,一行三格就成了三块空盒子。
|
||||
3 × controlHeight 就是三行文本的起步高度,控件档位变了它自己跟着变。 */
|
||||
.nex-textarea-tall :is(textarea, .ant-input-textarea > textarea),
|
||||
.nex-textarea-tall:is(textarea) {
|
||||
min-height: calc(var(--ant-control-height) * 3);
|
||||
resize: vertical;
|
||||
}
|
||||
/* 长文本字段:高度由 antd TextArea 的 autoSize 自己长(见 components/ui/Input.tsx)。
|
||||
旧的 .nex-textarea-tall 给容器挂 min-height: 3×controlHeight,它让 rows=2 的设定
|
||||
失效——抽屉里每个长字段固定 96px 起、内容少时剩半盒空白,整张抽屉被迫滚动。
|
||||
补丁删除,「几行文本」回到组件属性上。 */
|
||||
|
||||
/* ── 浮层层级:站内自绘浮层(灯箱、下拉、抽屉)与 antd 浮层共用一套 z 轴 ──
|
||||
antd 默认 dropdown 1050 / drawer 1000 / modal 1000 / message 1010;
|
||||
|
|
|
|||
|
|
@ -13,12 +13,22 @@
|
|||
* 间距 paddingXS 8 / padding 16 / paddingLG 24(antd 默认)
|
||||
* 断点 576 / 768 / 992 / 1200 / 1600(antd Grid 的 xs…xxl,见 styles/index.css)
|
||||
*
|
||||
* 只有三类东西被改:
|
||||
* 1) 品牌色(colorPrimary + 主按钮上的文字色);
|
||||
* 2) 表面色(Layout / 容器 / 浮层的底色与描边——深色工作台产品,antd 的中性灰偏冷不够);
|
||||
* 3) 少数组件的结构性 token(Layout 三段底色、Menu 密度与选中态、Tabs 卡片页签),
|
||||
* 只有两类东西被改:
|
||||
* 1) 表面色(Layout / 容器 / 浮层的底色与描边——深色工作台产品,antd 的中性灰偏冷不够);
|
||||
* 2) 少数组件的结构性 token(Layout 三段底色、Menu 密度与选中态、Tabs 卡片页签),
|
||||
* 改的是 antd 自己的 token 名,不新增名字。
|
||||
*
|
||||
* 品牌色不在清单里:SEED 里根本不写 colorPrimary,主色就是 antd 5 的出厂蓝
|
||||
* (light #1677ff / dark #1668dc,由各自的 algorithm 给)。colorLink / colorInfo /
|
||||
* colorTextLightSolid 以及 hover · active · 浅底整条梯度都交给算法从它派生,
|
||||
* 一个都不覆盖。上一版自造的柠檬绿(dark #a0d911 / light #5b8c00)之所以要撤,
|
||||
* 不只因为它难看,而因为它逼着站内养出一套「只有这支绿才成立」的特例:
|
||||
* 主按钮上的文字要改成近黑(浅绿底压白字看不清)、链接不能沿用主色、
|
||||
* colorInfo 还得压成同色免得「绿品牌 + 蓝信息」两套强调打架、
|
||||
* 菜单选中态要手写四行十六进制。换回出厂蓝以后这些特例全部消失:
|
||||
* 站内剩下的颜色只有两种可能——antd 的语义色(success / warning / error)
|
||||
* 或中性表面色,任何一个数都能在 antd 的色板与算法里查到出处。
|
||||
*
|
||||
* 页面侧取数只有两条路:组件内 theme.useToken(),或自绘区域读 antd 落下来的
|
||||
* --ant-* CSS 变量(cssVar: true)。不要再抄十六进制,也不要再建 --c-*。
|
||||
*
|
||||
|
|
@ -31,16 +41,31 @@ import { token2CSSVar, unit } from '@ant-design/cssinjs'
|
|||
|
||||
export type ThemeMode = 'dark' | 'light'
|
||||
|
||||
/**
|
||||
* antd 5 出厂主色(light #1677ff / dark #1668dc),实测自 theme.getDesignToken。
|
||||
*
|
||||
* 症状:上一版把这两个数当「出厂值」直接填回 SEED.colorPrimary,探针量到的
|
||||
* `--ant-color-primary` 却是 #165bbe(dark),全站主色比 antd 官方浅一档。
|
||||
* 根因:darkAlgorithm 不是「原样使用你给的主色」,它把 seed.colorPrimary
|
||||
* 丢进色板生成器再取第 5 档——不给的时候喂的是 #1677ff,取到 #1668dc;
|
||||
* 喂 #1668dc 进去,得到的是另一条色板的第 5 档 #165bbe。
|
||||
* 「写死出厂值」和「什么都不写」不等价。
|
||||
* 做法:SEED 里彻底不出现 colorPrimary,出厂蓝由算法自己给;
|
||||
* 这两个数只留在这里,供深色侧栏的选中态取数(那里需要实心主色块,
|
||||
* 见下面 Menu 的注释),别再往 token 里回填。
|
||||
* 为什么不只留注释:Menu 的深色选中态确实要用同一支蓝,抄字面量就会出现
|
||||
* 「哪一天改主色忘了同步这里」;探针 scripts/ui/visualcheck.py 里
|
||||
* 也按这两个数断言,两边一起改才不会漂。
|
||||
*/
|
||||
export const PRIMARY = { light: '#1677ff', dark: '#1668dc' }
|
||||
|
||||
/**
|
||||
* 品牌与表面:每个模式只留十几个数,其余梯度全部交给 antd 的派生算法。
|
||||
* 键名直接就是 antd token 名,读的人不用再去查「accent 对应 antd 的哪一个」。
|
||||
*/
|
||||
const SEED: Record<ThemeMode, Record<string, string>> = {
|
||||
dark: {
|
||||
/* 品牌:站内那支柠檬绿。给中间档,hover / active / 浅色底由算法推。 */
|
||||
colorPrimary: '#a0d911',
|
||||
colorTextLightSolid: '#1a2407',
|
||||
colorLink: '#a0d911',
|
||||
/* 品牌色不写覆盖——见下面 PRIMARY 的注释,这里写了反而不是出厂值。 */
|
||||
/* 文字基准:secondary / tertiary / quaternary / disabled 整条梯度由算法推 */
|
||||
colorTextBase: '#e9edf2',
|
||||
/* 表面:由底到浮三层,fill / mask / 表头底色由算法推 */
|
||||
|
|
@ -56,9 +81,7 @@ const SEED: Record<ThemeMode, Record<string, string>> = {
|
|||
shell: '#111820'
|
||||
},
|
||||
light: {
|
||||
colorPrimary: '#5b8c00',
|
||||
colorTextLightSolid: '#ffffff',
|
||||
colorLink: '#5b8c00',
|
||||
/* 同上:不写 colorPrimary */
|
||||
colorTextBase: '#111a22',
|
||||
colorBgLayout: '#f0f4f8',
|
||||
colorBgContainer: '#ffffff',
|
||||
|
|
@ -89,8 +112,19 @@ export function buildAntdTheme(mode: ThemeMode): ThemeConfig {
|
|||
token: {
|
||||
...seed,
|
||||
fontFamily: FONT_FAMILY,
|
||||
/* 信息色与主色同色,避免出现「绿色品牌 + 蓝色链接」两套强调 */
|
||||
colorInfo: seed.colorPrimary,
|
||||
/* colorLink / colorInfo / colorTextLightSolid 一律不覆盖:
|
||||
antd 默认 colorLink = colorInfo = colorPrimary,主色是标准蓝的时候,
|
||||
「蓝链接 + 蓝信息」本来就是同一套强调,不需要当初那条压同色的补丁;
|
||||
主按钮上的文字回到默认白。
|
||||
三个状态色保留覆盖,但它们不是品牌色而是语义色:喂进去的是
|
||||
@ant-design/colors 现成色板的档位(dark 取 5~6 档,light 取 7 档),
|
||||
只调深浅不改含义——出厂的深色档(success #49aa19 / warning #d89614 /
|
||||
error #dc4446)压在 #0d1117 上偏闷,而「已完成 / 有风险 / 失败」是
|
||||
工作台的主信息,读不清就是功能问题。
|
||||
注意这三条和 colorPrimary 一样会再走一遍 darkAlgorithm 的色板:
|
||||
实测 dark 落地的不是 #95de64 而是 #82c058(warning #d8bd14、error #dc6966),
|
||||
light 原样保留(#389e0d / #d48806 / #cf1322)。这两个口径都由探针量过,
|
||||
别按字面量去猜。除这三条以外,站内没有任何自造色。 */
|
||||
colorSuccess: dark ? '#95de64' : '#389e0d',
|
||||
colorWarning: dark ? '#fadb14' : '#d48806',
|
||||
colorError: dark ? '#ff7875' : '#cf1322'
|
||||
|
|
@ -115,9 +149,19 @@ export function buildAntdTheme(mode: ThemeMode): ThemeConfig {
|
|||
},
|
||||
/**
|
||||
* 侧栏菜单:整行圆角 + 内缩是 antd inline 菜单的默认行为,这里只调密度与透明底。
|
||||
* 选中态必须显式给:侧栏底色比容器低一档,直接沿用算法算出来的
|
||||
* itemSelectedBg(colorPrimaryBg)压在深底上会变成一大块灰绿,
|
||||
* 文字又只剩 colorPrimary,对比度一起塌。两套主题各给一档半透明主色底。
|
||||
* 选中态只在深色下给,而且给的是 antd 自己那一套,不是新的数:
|
||||
* · 浅色:什么都不写。antd 的 light 菜单默认 itemSelectedBg =
|
||||
* controlItemBgActive(#e6f4ff)、itemSelectedColor = colorPrimary
|
||||
* (#1677ff),压在白侧栏上是 4.4:1,就是 antd 官网侧栏那个样子。
|
||||
* · 深色:AppSider 两套主题都走 theme="light"(原因见该文件注释),
|
||||
* 于是深色下拿到的仍是 light 菜单那一对,即 #15325b 底 + #1668dc 字,
|
||||
* 实测对比度 2.2:1,选中项比未选中还弱。这里把它换成 antd 自己的
|
||||
* dark 菜单那一组默认值——源码里 darkItemSelectedBg = colorPrimary、
|
||||
* darkItemSelectedColor = colorTextLightSolid(#fff),实心主色块 + 白字
|
||||
* 6.4:1,也就是 VS Code / GitHub 深色侧栏的做法。按下态取
|
||||
* colorPrimaryActive(#1554ad),与主按钮 :active 同低一档。
|
||||
* 绿色时代这里写的是四行手写十六进制(半透明柠檬绿底 + #b7e35f 字),
|
||||
* 那套值只能配那支绿,换任何主色都要重调;现在两行都指回 antd 的梯度。
|
||||
*/
|
||||
Menu: {
|
||||
itemHeight: 40,
|
||||
|
|
@ -139,14 +183,19 @@ export function buildAntdTheme(mode: ThemeMode): ThemeConfig {
|
|||
itemColor: dark ? '#a9b6c1' : '#3f4c58',
|
||||
itemHoverColor: dark ? '#e9edf2' : '#111a22',
|
||||
itemHoverBg: dark ? 'rgba(233, 237, 242, 0.06)' : 'rgba(17, 26, 34, 0.04)',
|
||||
itemActiveBg: dark ? 'rgba(160, 217, 17, 0.20)' : '#e8f3d5',
|
||||
itemSelectedBg: dark ? 'rgba(160, 217, 17, 0.14)' : '#f0f7e2',
|
||||
itemSelectedColor: dark ? '#b7e35f' : '#4f7d00',
|
||||
subMenuItemSelectedColor: dark ? '#b7e35f' : '#4f7d00',
|
||||
...(dark
|
||||
? {
|
||||
itemActiveBg: '#1554ad',
|
||||
itemSelectedBg: PRIMARY.dark,
|
||||
itemSelectedColor: '#ffffff',
|
||||
subMenuItemSelectedColor: '#ffffff'
|
||||
}
|
||||
: {}),
|
||||
/* 圆角行 + 内缩之后,贴在容器边线上的 activeBar 会显得错位,靠底色就够了 */
|
||||
activeBarWidth: 0,
|
||||
groupTitleColor: dark ? '#6f7d88' : '#8a97a3',
|
||||
dangerItemColor: seed.colorError,
|
||||
/* dangerItemColor 不写:上一版这里读 seed.colorError,而 SEED 里根本没有
|
||||
这个键,等于一直是个 undefined 走 antd 默认(= colorError)。删掉死代码。 */
|
||||
dangerItemSelectedBg: dark ? 'rgba(255, 120, 117, 0.14)' : '#fff1f0',
|
||||
popupBg: seed.colorBgElevated
|
||||
},
|
||||
|
|
|
|||
|
|
@ -44,6 +44,60 @@ PWD = os.environ.get("NEX_PASS", "admin1234")
|
|||
# rc-resize-observer 在 React 18 下的已知告警,antd 内部依赖,与应用代码无关
|
||||
IGNORE = ("findDOMNode is deprecated", "Support for React will be removed")
|
||||
|
||||
# ── 颜色闸(2026-11 撤掉自造的柠檬绿品牌之后常驻)────────────────────────────
|
||||
# 1) 主色必须等于 antd 各自 algorithm 的出厂蓝。这个数非量不可:
|
||||
# darkAlgorithm 会把喂进来的 seed 再走一遍色板生成器取第 5 档,
|
||||
# 「把出厂值 #1668dc 填回 SEED.colorPrimary」量到的是 #165bbe(差一档),
|
||||
# 截图上肉眼看不出来,只有读 --ant-color-primary 才发现覆盖回来了。
|
||||
# 2) 侧栏选中态必须是 antd 自己那一组:浅色 = controlItemBgActive + colorPrimary
|
||||
# (#e6f4ff / #1677ff,4.4:1,antd 官网同款);深色由 theme/antd.ts 补 antd
|
||||
# dark 菜单的默认对(实心主色 + 白字,6.4:1)。深色要是删掉这两条,
|
||||
# light 菜单的 #15325b 底 + #1668dc 字只有 2.2:1,选中项比未选中还淡。
|
||||
# 3) 全站不许再出现旧品牌那一族(antd lime-1..10:#a0d911 / #5b8c00 是它的 6/8 档)。
|
||||
ANTD_PRIMARY = {"light": "#1677ff", "dark": "#1668dc"}
|
||||
MENU_SELECTED = {
|
||||
"light": ("rgb(230, 244, 255)", "rgb(22, 119, 255)"),
|
||||
"dark": ("rgb(22, 104, 220)", "rgb(255, 255, 255)"),
|
||||
}
|
||||
|
||||
# lime 族的色相窗口:实测 antd lime-1..10 落在 71°~83°,而 green 族(语义 success
|
||||
# 用的那一族,含 darkAlgorithm 重映射出来的 #82c058 / #3b512c)落在 88°~102°。
|
||||
# 取 62~88 当窗口:黄橙(warning 一族 45°~55°)和状态绿都进不来。
|
||||
COLORSCAN = r"""() => {
|
||||
const props = ['color', 'backgroundColor', 'borderTopColor', 'borderLeftColor', 'outlineColor', 'fill', 'stroke'];
|
||||
const hit = {};
|
||||
const parse = (s) => {
|
||||
if (!s || s === 'transparent' || s === 'none') return null;
|
||||
let m = s.match(/^rgba?\(([^)]]+)\)$/i);
|
||||
if (m) { const p = m[1].split(/[,\s/]+/).filter(Boolean).map(Number);
|
||||
return {r: p[0], g: p[1], b: p[2], a: p.length > 3 ? p[3] : 1}; }
|
||||
m = s.match(/^#([0-9a-f]{6})$/i);
|
||||
if (m) { const v = parseInt(m[1], 16); return {r: v >> 16 & 255, g: v >> 8 & 255, b: v & 255, a: 1}; }
|
||||
return null;
|
||||
};
|
||||
for (const el of document.querySelectorAll('body *')) {
|
||||
const cs = getComputedStyle(el);
|
||||
if (cs.display === 'none') continue;
|
||||
for (const p of props) {
|
||||
const c = parse(cs[p]);
|
||||
if (!c || c.a < 0.05) continue;
|
||||
const mx = Math.max(c.r, c.g, c.b), mn = Math.min(c.r, c.g, c.b);
|
||||
if (mx === mn) continue;
|
||||
const h = mx === c.r ? 60 * (((c.g - c.b) / (mx - mn)) % 6)
|
||||
: mx === c.g ? 60 * ((c.b - c.r) / (mx - mn) + 2)
|
||||
: 60 * ((c.r - c.g) / (mx - mn) + 4);
|
||||
const hue = h < 0 ? h + 360 : h;
|
||||
if (!(hue >= 62 && hue <= 88 && (mx - mn) / mx > 0.12)) continue;
|
||||
const key = '#' + [c.r, c.g, c.b].map((n) => n.toString(16).padStart(2, '0')).join('');
|
||||
const rec = hit[key] || (hit[key] = {n: 0, e: ''});
|
||||
rec.n++;
|
||||
if (!rec.e) rec.e = el.tagName.toLowerCase() + '.' +
|
||||
((typeof el.className === 'string' ? el.className : '').trim().slice(0, 48) || '-') + ' {' + p + '}';
|
||||
}
|
||||
}
|
||||
return hit;
|
||||
}"""
|
||||
|
||||
PROBE = """() => {
|
||||
const cs = getComputedStyle(document.documentElement);
|
||||
const v = (n) => (cs.getPropertyValue(n) || '').trim();
|
||||
|
|
@ -259,12 +313,26 @@ def audit(page, route: str, width: int, theme: str, problems: list[str], *,
|
|||
for k, val in probe["root"].items():
|
||||
if not val:
|
||||
problems.append(f"{width}/{theme}{route}: :root 缺 --{k}")
|
||||
want = ANTD_PRIMARY[theme]
|
||||
got = probe["root"]["primary"].lower()
|
||||
if got != want:
|
||||
problems.append(f"{width}/{theme}{route}: 主色 {got} ≠ antd 出厂蓝 {want}"
|
||||
f"(站内不覆盖 colorPrimary,见 theme/antd.ts)")
|
||||
# 逐元素扫颜色只在主宽度做:换色不看宽度,四个宽度重复扫只是多花一倍时间
|
||||
if width == WIDTHS[0]:
|
||||
for hexv, rec in page.evaluate(COLORSCAN).items():
|
||||
problems.append(f"{width}/{theme}{route}: 残留旧品牌lime族 {hexv} ×{rec['n']} e.g. {rec['e']}")
|
||||
for bad in probe["text"]:
|
||||
problems.append(f"{width}/{theme}{route}: 行高塌了 {bad}")
|
||||
if menu_required:
|
||||
if not probe["menu"]:
|
||||
problems.append(f"{width}/{theme}{route}: 菜单没有选中项")
|
||||
elif probe.get("collapsed") and probe.get("subSelected"):
|
||||
else:
|
||||
want_bg, want_fg = MENU_SELECTED[theme]
|
||||
if probe["menu"]["bg"] != want_bg or probe["menu"]["color"] != want_fg:
|
||||
problems.append(f"{width}/{theme}{route}: 侧栏选中态 {probe['menu']['bg']}"
|
||||
f"/{probe['menu']['color']},应为 {want_bg}/{want_fg}")
|
||||
if probe.get("collapsed") and probe.get("subSelected"):
|
||||
# 折叠态下只验到父级还不够:selectedKeys 传错时父级照样会亮。
|
||||
# 展开浮层,确认这一条路由对应的二级项真的在里面被选中。
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in New Issue