From 88a05eb18901fd3d89c0743bdbf67b5e96a89e47 Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Sun, 1 Nov 2026 16:59:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E8=B0=83=E5=BA=A6=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E9=A1=B5=E7=AD=BE=EF=BC=9BButton=20=E6=8A=BD=E5=87=BA?= =?UTF-8?q?=20buttonCls=20=E4=BE=9B=E7=AB=99=E5=86=85=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E3=80=81Chip/Check=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8F=AA=E8=AF=BB=E4=B8=8E=20title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/ui/Button.tsx | 32 +- frontend/src/components/ui/Controls.tsx | 15 +- frontend/src/pages/project/Dispatch.tsx | 436 +++++++++++++++++++++++- 3 files changed, 464 insertions(+), 19 deletions(-) diff --git a/frontend/src/components/ui/Button.tsx b/frontend/src/components/ui/Button.tsx index e38c485..50bd1d9 100644 --- a/frontend/src/components/ui/Button.tsx +++ b/frontend/src/components/ui/Button.tsx @@ -62,19 +62,29 @@ type CommonProps = { type ButtonProps = CommonProps & ButtonHTMLAttributes & { href?: undefined } type AnchorProps = CommonProps & AnchorHTMLAttributes & { href: string } +/** + * 按钮的样式计算单独拿出来: / 这类「看起来是按钮的站内链接」 + * (模型迁移入口、空状态里的「去创建」)复用同一份配方, + * 而不是再抄一遍类名 —— 抄的那份永远不会跟着变体调整。 + */ +export function buttonCls(opt: CommonProps & { variant?: ButtonVariant } = {}) { + const { variant = 'secondary', size = 'md', square, danger, on, className } = opt + return cn( + BASE, + VARIANTS[variant as ButtonVariant], + size !== 'md' && SIZES[size as ButtonSize], + square && 'w-(--ctl-h) px-0 text-ui', + danger && variant === 'outline' && 'text-danger-bright border-danger-line hover:not-disabled:bg-danger-tint-2', + danger && variant === 'ghost' && 'text-danger-bright border-danger-line', + danger && variant === 'del' && 'bg-danger border-danger text-danger-ink shadow-raise', + on && 'border-accent-line bg-accent-tint text-accent-bright', + className + ) +} + export const Button = forwardRef( function Button({ variant = 'secondary', size = 'md', square, danger, on, className, children, ...rest }: any, ref) { - const classes = cn( - BASE, - VARIANTS[variant as ButtonVariant], - size !== 'md' && SIZES[size as ButtonSize], - square && 'w-(--ctl-h) px-0 text-ui', - danger && variant === 'outline' && 'text-danger-bright border-danger-line hover:not-disabled:bg-danger-tint-2', - danger && variant === 'ghost' && 'text-danger-bright border-danger-line', - danger && variant === 'del' && 'bg-danger border-danger text-danger-ink shadow-raise', - on && 'border-accent-line bg-accent-tint text-accent-bright', - className - ) + const classes = buttonCls({ variant, size, square, danger, on, className }) /* ref 是「按钮或链接」的联合类型,到这里没法收窄,交给 DOM 元素自己判断 */ const nodeRef = ref as Ref | undefined if (rest.href !== undefined) { diff --git a/frontend/src/components/ui/Controls.tsx b/frontend/src/components/ui/Controls.tsx index 7266aad..e2e1c48 100644 --- a/frontend/src/components/ui/Controls.tsx +++ b/frontend/src/components/ui/Controls.tsx @@ -121,16 +121,21 @@ export function ChipBar({ children, label, className, top }: { children: ReactNo ) } -/** 筛选/开关胶囊(.chip) */ +/** + * 筛选/开关胶囊(.chip)。 + * 默认是可点的 button;只读计数(调度中心队列旁的「queued 12」那种)传 as="span", + * 否则一行里会冒出七八个按了没反应的 Tab 停靠点。 + */ export function Chip({ active, children, onClick, className, title, disabled, as = 'button', href }: { active?: boolean; children: ReactNode; onClick?: () => void; className?: string; title?: string - disabled?: boolean; as?: 'button' | 'a'; href?: string + disabled?: boolean; as?: 'button' | 'a' | 'span'; href?: string }) { const classes = cn('inline-flex items-center justify-center gap-[5px] h-(--ctl-h-md) px-2 text-tiny rounded-pill ' + 'border whitespace-nowrap shrink-0 no-underline transition-colors duration-150', active ? 'bg-accent-fill border-accent-fill text-on-accent font-bold' : 'bg-raise border-line-strong text-ink-3 hover:bg-active hover:text-ink', disabled && 'opacity-40 cursor-not-allowed', className) + if (as === 'span') return {children} if (as === 'a') return {children} return } @@ -176,11 +181,11 @@ export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra } /** 复选(.check):勾选框 + 文案,整块可点 */ -export function Check({ checked, onChange, children, disabled, className }: { - checked: boolean; onChange: (next: boolean) => void; children: ReactNode; disabled?: boolean; className?: string +export function Check({ checked, onChange, children, disabled, className, title }: { + checked: boolean; onChange: (next: boolean) => void; children: ReactNode; disabled?: boolean; className?: string; title?: string }) { return ( -