From 83afef132d51850006bcc75147d615c954738adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E7=94=B5=E8=84=91=E7=9A=84=E6=B0=B8=E5=B9=B3?= Date: Thu, 17 Jul 2025 11:13:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cunkebao/scripts/update-page-headers.js | 87 ------------------------- 1 file changed, 87 deletions(-) delete mode 100644 Cunkebao/scripts/update-page-headers.js diff --git a/Cunkebao/scripts/update-page-headers.js b/Cunkebao/scripts/update-page-headers.js deleted file mode 100644 index 1e299f28..00000000 --- a/Cunkebao/scripts/update-page-headers.js +++ /dev/null @@ -1,87 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -// 需要更新的页面文件列表 -const pagesToUpdate = [ - 'src/pages/scenarios/ScenarioDetail.tsx', - 'src/pages/scenarios/NewPlan.tsx', - 'src/pages/plans/Plans.tsx', - 'src/pages/plans/PlanDetail.tsx', - 'src/pages/orders/Orders.tsx', - 'src/pages/profile/Profile.tsx', - 'src/pages/content/Content.tsx', - 'src/pages/contact-import/ContactImport.tsx', - 'src/pages/traffic-pool/TrafficPool.tsx', - 'src/pages/workspace/Workspace.tsx' -]; - -// 更新规则 -const updateRules = [ - { - // 替换旧的header结构 - pattern: /
\s*
\s*
\s*]*onClick=\{\(\) => navigate\(-1\)\}[^>]*>\s*]*\/>\s*<\/button>\s*]*>([^<]*)<\/h1>\s*<\/div>\s*(?:]*>([\s\S]*?)<\/div>)?\s*<\/div>\s*<\/header>/g, - replacement: (match, title, rightContent) => { - const rightContentStr = rightContent ? `\n rightContent={\n ${rightContent.trim()}\n }` : ''; - return ``; - } - }, - { - // 替换简单的header结构 - pattern: /
\s*
\s*]*>([^<]*)<\/h1>\s*<\/div>\s*<\/header>/g, - replacement: (match, title) => { - return ``; - } - }, - { - // 添加PageHeader导入 - pattern: /import React[^;]+;/, - replacement: (match) => { - return `${match}\nimport PageHeader from '@/components/PageHeader';`; - } - } -]; - -function updateFile(filePath) { - try { - const fullPath = path.join(process.cwd(), filePath); - if (!fs.existsSync(fullPath)) { - console.log(`文件不存在: ${filePath}`); - return; - } - - let content = fs.readFileSync(fullPath, 'utf8'); - let updated = false; - - // 应用更新规则 - updateRules.forEach(rule => { - const newContent = content.replace(rule.pattern, rule.replacement); - if (newContent !== content) { - content = newContent; - updated = true; - } - }); - - if (updated) { - fs.writeFileSync(fullPath, content, 'utf8'); - console.log(`✅ 已更新: ${filePath}`); - } else { - console.log(`⏭️ 无需更新: ${filePath}`); - } - } catch (error) { - console.error(`❌ 更新失败: ${filePath}`, error.message); - } -} - -// 执行批量更新 -console.log('🚀 开始批量更新页面Header...\n'); - -pagesToUpdate.forEach(filePath => { - updateFile(filePath); -}); - -console.log('\n✨ 批量更新完成!'); -console.log('\n📝 注意事项:'); -console.log('1. 请检查更新后的文件是否正确'); -console.log('2. 可能需要手动调整一些特殊的header结构'); -console.log('3. 确保所有页面都正确导入了PageHeader组件'); -console.log('4. 运行 npm run build 检查是否有编译错误'); \ No newline at end of file