/* eslint-disable max-lines-per-function, complexity -- 页面组件集中编排筛选、表单与弹层,拆散会割裂数据流;纯逻辑已抽到 *-utils.ts */ import { Button, Input, Switch } from '@douyinfe/semi-ui-19'; import type { SystemConfig } from '@lingxi/shared'; import { IconAlert, IconShare } from '@lingxi/ui/icons'; import type { ReactNode } from 'react'; import { configValueText, formatConfigTime, namingPreview, rangeTextOf } from './config-utils'; const SHARED_FIELD_KEYS: ReadonlySet = new Set([ 'limit.customer.base_field', 'limit.customer.gen_field', ]); function LabelBlock({ config, dirty }: { config: SystemConfig; dirty: boolean }): ReactNode { return (
{config.label} {dirty ? 未保存 : null} {config.key}

{config.description}

{config.impact}

{SHARED_FIELD_KEYS.has(config.key) ? (

A3 客户字段、表单校验与任务提交共用(R-26)

) : null}
); } function ValueMeta({ config, error }: { config: SystemConfig; error: string | null }): ReactNode { if (error !== null) return {error}; const range = rangeTextOf(config); return ( {range === '' ? null : `${range} · `}v{config.version} · {config.updatedBy ?? '—'}{' '} {formatConfigTime(config.updatedAt)} ); } export interface ConfigRowProps { config: SystemConfig; raw: string; dirty: boolean; readOnly: boolean; error: string | null; editingPattern: boolean; namingMaxLength: number; onRawChange: (raw: string) => void; onEditPattern: () => void; onCollapsePattern: () => void; } /** 单个配置项:文本 / 数字 / 开关;命名模板(pattern)展开行内编辑 + 校验提示 */ export function ConfigRow({ config, raw, dirty, readOnly, error, editingPattern, namingMaxLength, onRawChange, onEditPattern, onCollapsePattern, }: ConfigRowProps): ReactNode { if (config.type === 'pattern') { const preview = namingPreview(raw, namingMaxLength); const patternError = error ?? preview.error; return (
{editingPattern && !readOnly ? (
{patternError === null ? '校验通过' : `校验未通过:${patternError}`} {' '} · {raw.length} / {namingMaxLength} 字符 · 点击右侧占位符插入
) : (
{configValueText(config, raw)} {readOnly ? null : ( )}
)}
); } const control = config.type === 'boolean' ? ( {raw === 'true' ? '开启' : '关闭'} { onRawChange(checked ? 'true' : 'false'); }} /> ) : ( {config.unit === null || config.unit === '' ? null : ( {config.unit} )} ); return (
{control}
); }