/** * 修复 el-table-column 标签替换问题,避免响应式列宽塌陷 */ const fs = require('fs') const path = require('path') const projects = [ path.join(__dirname, '../../saas-adminui/src/views/lobster'), path.join(__dirname, '../../saas-companyui/src/views/lobster') ] function walk(dir, files = []) { if (!fs.existsSync(dir)) return files for (const name of fs.readdirSync(dir)) { const full = path.join(dir, name) if (fs.statSync(full).isDirectory()) walk(full, files) else if (name.endsWith('.vue')) files.push(full) } return files } const COLUMN_FIXES = [ [/label="配置名" prop="configName" width="200"/g, 'label="配置名" prop="configName" min-width="140"'], [/label="关键词" prop="keywords" width="320"/g, 'label="关键词" prop="keywords" min-width="180"'], [/label="敏感词" prop="word" width="220"/g, 'label="敏感词" prop="word" min-width="100"'], [/label="提示词名称" align="center" prop="prompt_name" width="180"/g, 'label="提示词名称" align="center" prop="prompt_name" min-width="120"'], [/label="提示词标识" align="center" prop="prompt_key" width="200"/g, 'label="提示词标识" align="center" prop="prompt_key" min-width="140"'], [/label="提示词名称" align="center" prop="promptName" width="180"/g, 'label="提示词名称" align="center" prop="promptName" min-width="120"'], [/label="提示词标识" align="center" prop="promptKey" width="200"/g, 'label="提示词标识" align="center" prop="promptKey" min-width="140"'], [/label="模型A (评分/初审)" prop="modelA" width="180"/g, 'label="模型A (评分/初审)" prop="modelA" min-width="120"'], [/label="模型B (重试/复审)" prop="modelB" width="180"/g, 'label="模型B (重试/复审)" prop="modelB" min-width="120"'], [/label="模型C (校验/终审)" prop="modelC" width="180"/g, 'label="模型C (校验/终审)" prop="modelC" min-width="120"'] ]; function addTableClass(content) { return content.replace(/]*?)>/g, (match, attrs) => { if (/lobster-list-table/.test(attrs)) return match if (/class="([^"]*)"/.test(attrs)) { return match.replace(/class="([^"]*)"/, 'class="$1 lobster-list-table"') } return `` }) } let changed = 0 for (const root of projects) { for (const file of walk(root)) { let content = fs.readFileSync(file, 'utf8') if (!content.includes('