#!/usr/bin/env node /** * D25: parent-index.vue 家长首页清理 (debt 57 -> 0) * 1) template 5 个五维自检图标内联色 -> 语义 class($dim-* 令牌) * 2) script 5 条渐变 -> BrandColors * 3) style 4 色 -> 全局令牌 */ const fs = require('fs'); const F = 'pages/home-pages/parent-index.vue'; let src = fs.readFileSync(F, 'utf8'); let replaced = 0; function repl(from, to) { const cnt = src.split(from).length - 1; if (cnt === 0) { console.warn('NOT FOUND: ' + from.slice(0, 100)); return; } src = src.split(from).join(to); replaced += cnt; } // ---- 1. template 内联色 -> class ---- repl('', ''); repl('', ''); repl('', ''); repl('', ''); repl('', ''); // ---- 2. script 渐变 ---- repl(" 'linear-gradient(135deg, #10B981, #34D399)',", " 'linear-gradient(135deg, ' + BrandColors.success + ', ' + BrandColors.successLight3 + ')',"); repl(" 'linear-gradient(135deg, #0EA5E9, #38BDF8)',", " 'linear-gradient(135deg, ' + BrandColors.infoSky + ', ' + BrandColors.infoLight + ')',"); repl(" 'linear-gradient(135deg, #8B5CF6, #C084FC)',", " 'linear-gradient(135deg, ' + BrandColors.violet + ', ' + BrandColors.violetLighter + ')',"); repl(" 'linear-gradient(135deg, #F97316, #FB923C)',", " 'linear-gradient(135deg, ' + BrandColors.primary + ', ' + BrandColors.primaryLight + ')',"); repl(" 'linear-gradient(135deg, #6366F1, #818CF8)'", " 'linear-gradient(135deg, ' + BrandColors.wisdom + ', ' + BrandColors.wisdomLight + ')'"); // ---- 3. style ---- repl('.pink-color { color: #EC4899; }', '.pink-color { color: $accent-pink; }'); repl('background: linear-gradient(135deg, $status-success-tint-2, #ECFDF5);', 'background: linear-gradient(135deg, $status-success-tint-2, $status-success-tint);'); repl('color: #065F46;', 'color: $status-success-strong;'); repl('color: #9A3412;', 'color: $mat-orange-deep;'); // ---- 4. 图标 class 定义(追加到 .selfcheck-icon-circle 规则后)---- repl( '.selfcheck-icon-circle {', '// 五维自检图标底色(全局维度令牌)\n.selfcheck-icon-body { background: $dim-body; }\n.selfcheck-icon-wisdom { background: $dim-wisdom; }\n.selfcheck-icon-wealth { background: $dim-wealth; }\n.selfcheck-icon-action { background: $dim-action; }\n.selfcheck-icon-mind { background: $dim-mind; }\n\n.selfcheck-icon-circle {' ); fs.writeFileSync(F, src); console.log('total replaced:', replaced); const lines = src.split('\n'); let n = 0; for (let i = 0; i < lines.length; i++) { if (/#[0-9a-fA-F]{3,8}\b/.test(lines[i])) { console.log('HEX ' + (i + 1) + ': ' + lines[i].trim().slice(0, 110)); n++; } } console.log('remaining hex lines:', n);