fix(industry): 三轮审计修复 — 3 HIGH + 4 MEDIUM 清零
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

H1: status 值不匹配 disabled→inactive + source 补 admin 映射 + valueEnum
H2: experience.rs format_for_injection 添加 xml_escape
H3: TriggerContext industry_keywords 接通全局缓存
M2: ID 自动生成移除中文字符保留 + 无 ASCII 时提示手动输入
M3: TS CreateIndustryRequest 添加 id? 字段
M4: ListIndustriesQuery 添加 deny_unknown_fields
This commit is contained in:
iven
2026-04-12 21:04:00 +08:00
parent 168dd87af4
commit 0b512a3d85
6 changed files with 50 additions and 13 deletions

View File

@@ -21,9 +21,9 @@ import { PageHeader } from '@/components/PageHeader'
const { TextArea } = Input
const { Text } = Typography
const statusLabels: Record<string, string> = { active: '启用', disabled: '禁用' }
const statusColors: Record<string, string> = { active: 'green', disabled: 'default' }
const sourceLabels: Record<string, string> = { builtin: '内置', custom: '自定义' }
const statusLabels: Record<string, string> = { active: '启用', inactive: '禁用' }
const statusColors: Record<string, string> = { active: 'green', inactive: 'default' }
const sourceLabels: Record<string, string> = { builtin: '内置', admin: '自定义', custom: '自定义' }
// === 行业列表 ===
@@ -77,6 +77,7 @@ function IndustryListPanel() {
valueType: 'select',
valueEnum: {
builtin: { text: '内置' },
admin: { text: '自定义' },
custom: { text: '自定义' },
},
render: (_, r) => <Tag color={r.source === 'builtin' ? 'blue' : 'purple'}>{sourceLabels[r.source] || r.source}</Tag>,
@@ -95,7 +96,7 @@ function IndustryListPanel() {
valueType: 'select',
valueEnum: {
active: { text: '启用', status: 'Success' },
disabled: { text: '禁用', status: 'Default' },
inactive: { text: '禁用', status: 'Default' },
},
render: (_, r) => <Tag color={statusColors[r.status]}>{statusLabels[r.status] || r.status}</Tag>,
},
@@ -121,7 +122,7 @@ function IndustryListPanel() {
</Button>
{r.status === 'active' ? (
<Popconfirm title="确定禁用此行业?" onConfirm={() => updateStatusMutation.mutate({ id: r.id, status: 'disabled' })}>
<Popconfirm title="确定禁用此行业?" onConfirm={() => updateStatusMutation.mutate({ id: r.id, status: 'inactive' })}>
<Button type="link" size="small" danger icon={<StopOutlined />}></Button>
</Popconfirm>
) : (
@@ -309,9 +310,17 @@ function IndustryCreateModal({ open, onClose }: {
onFinish={(values) => {
// Auto-generate id from name if not provided
if (!values.id && values.name) {
values.id = values.name.toLowerCase()
.replace(/[^a-z0-9\u4e00-\u9fff]+/g, '-')
// Strip non-ASCII, keep only lowercase alphanumeric + hyphens
const generated = values.name.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-|-$/g, '')
if (generated) {
values.id = generated
} else {
// Name has no ASCII chars — require manual ID entry
message.warning('中文行业名称无法自动生成标识,请手动填写行业标识')
return
}
}
createMutation.mutate(values)
}}

View File

@@ -38,6 +38,7 @@ export interface IndustryFullConfig {
/** 创建行业请求 */
export interface CreateIndustryRequest {
id?: string
name: string
icon: string
description: string