const fs = require('fs') const paths = [ 'd:/ylrz_saas_new/saas-companyui/src/utils/lobster/sensitiveWordCategory.js', 'd:/ylrz_saas_new/saas-mgnui/src/utils/lobster/sensitiveWordCategory.js', 'd:/ylrz_saas_new/adminui/src/utils/lobster/sensitiveWordCategory.js' ] const content = `/** Sensitive word categories: value is stored code, label is display text. */ export const SENSITIVE_WORD_CATEGORY_OPTIONS = [ { value: 'wechat_ban', label: '\\u5fae\\u4fe1\\u8fdd\\u89c4' }, { value: 'fin_ban', label: '\\u91d1\\u878d\\u8fdd\\u89c4' }, { value: 'medical_ban', label: '\\u533b\\u7597\\u8fdd\\u89c4' }, { value: 'edu_ban', label: '\\u6559\\u80b2\\u8fdd\\u89c4' }, { value: 'competitor', label: '\\u7ade\\u54c1\\u5f15\\u6d41' }, { value: 'scam_high_risk', label: '\\u8bc8\\u9a97\\u9ad8\\u98ce\\u9669' }, { value: 'custom', label: '\\u81ea\\u5b9a\\u4e49' }, { value: 'auto', label: '\\u81ea\\u52a8\\u5206\\u7c7b' }, { value: 'politic', label: '\\u653f\\u6cbb' }, { value: 'violence', label: '\\u66b4\\u529b' }, { value: 'porn', label: '\\u8272\\u60c5' }, { value: 'finance', label: '\\u91d1\\u878d' }, { value: '\\u91d1\\u878d', label: '\\u91d1\\u878d' }, { value: '\\u533b\\u7597', label: '\\u533b\\u7597' }, { value: '\\u5e7f\\u544a', label: '\\u5e7f\\u544a' }, { value: '\\u6cd5\\u5f8b', label: '\\u6cd5\\u5f8b' }, { value: '\\u653f\\u6cbb', label: '\\u653f\\u6cbb' }, { value: '\\u8bc8\\u9a97', label: '\\u8bc8\\u9a97' }, { value: '\\u8272\\u60c5', label: '\\u8272\\u60c5' }, { value: '\\u66b4\\u529b', label: '\\u66b4\\u529b' }, { value: '\\u901a\\u7528', label: '\\u901a\\u7528' } ] const LABEL_MAP = SENSITIVE_WORD_CATEGORY_OPTIONS.reduce((acc, item) => { acc[item.value] = item.label return acc }, Object.create(null)) const HAN_RE = /[\\u4e00-\\u9fff]/ export function sensitiveWordCategoryLabel(code) { if (code == null || code === '') return '\\u2014' const key = String(code).trim() if (LABEL_MAP[key]) return LABEL_MAP[key] if (HAN_RE.test(key)) return key return key } export function buildSensitiveWordCategoryOptions(extraCodes) { const known = new Map(SENSITIVE_WORD_CATEGORY_OPTIONS.map(o => [o.value, o.label])) ;(extraCodes || []).forEach(c => { if (c && !known.has(c)) { known.set(c, sensitiveWordCategoryLabel(c)) } }) return Array.from(known.entries()).map(([value, label]) => ({ value, label })) } ` paths.forEach(p => { fs.writeFileSync(p, content, 'utf8') const t = fs.readFileSync(p, 'utf8') console.log(p, t.includes('微信违规'), /^[\\x00-\\x7f]*$/.test(t)) })