#!/usr/bin/env node /** * D21: gut-flora-detail.vue 肠道菌群详情页清理 (debt 60) * script 9 个指标色收编 BrandColors;style 全局令牌 3 + 局部 Material Teal 色阶 6 */ const fs = require('fs'); const F = 'pages/health/gut-flora-detail.vue'; let src = fs.readFileSync(F, 'utf8'); let replaced = 0; // ---- 1. import ---- if (!src.includes('utils/brand-colors.js')) { src = src.replace( "import HealthKnowledgePopup from '@/pages/health/components/health-knowledge-popup.vue'", "import HealthKnowledgePopup from '@/pages/health/components/health-knowledge-popup.vue'\nimport { BrandColors } from '../../utils/brand-colors.js'" ); } // ---- 2. script 色值 ---- const styleIdx = src.indexOf(']*>\s*\n)/, '$1' + palette + '\n'); fs.writeFileSync(F, scriptPart + stylePart); console.log('total replaced:', replaced); const out = fs.readFileSync(F, 'utf8'); const lines = out.split('\n'); let n = 0; for (let i = 0; i < lines.length; i++) { const L = lines[i].trim(); if (/#[0-9a-fA-F]{3,8}\b/.test(L) && L.charAt(0) !== '$') { console.log('HEX ' + (i + 1) + ': ' + L.slice(0, 100)); n++; } } console.log('remaining non-palette hex:', n);