| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #!/usr/bin/env node
- /**
- * D26: child-index.vue 孩子首页清理 (debt 54 -> 0)
- * 全局令牌 3 色 + Tailwind pastel 描边族 5 色;页面专属 5 色收编局部 $c-ci-*
- */
- const fs = require('fs');
- const F = 'pages/home-pages/child-index.vue';
- let src = fs.readFileSync(F, 'utf8');
- let replaced = 0;
- const styleIdx = src.indexOf('<style');
- const before = src.slice(0, styleIdx);
- let styleBody = src.slice(styleIdx);
- const GLOBAL = [
- ['#2563EB', '$status-info-deep'],
- ['#EDF2F7', '$uni-bg-color-grey'],
- ['#FDE68A', '$status-warning-light'],
- ['#BAE6FD', '$tint-sky-line'],
- ['#BBF7D0', '$tint-green-line'],
- ['#BFDBFE', '$tint-blue-line'],
- ['#FBCFE8', '$tint-pink-line'],
- ['#C7D2FE', '$tint-indigo-line'],
- ];
- for (const [from, to] of GLOBAL) {
- const re = new RegExp(from + '(?![0-9a-fA-F])', 'gi');
- replaced += (styleBody.match(re) || []).length;
- styleBody = styleBody.replace(re, to);
- }
- const LOCAL = [
- ['#E0ECF8', '$c-ci-sky'],
- ['#1E4A7A', '$c-ci-navy'],
- ['#FFB800', '$c-ci-gold'],
- ['#DCE8F5', '$c-ci-blue-1'],
- ['#C8DDF0', '$c-ci-blue-2'],
- ];
- for (const [from, to] of LOCAL) {
- const re = new RegExp(from + '(?![0-9a-fA-F])', 'gi');
- replaced += (styleBody.match(re) || []).length;
- styleBody = styleBody.replace(re, to);
- }
- const palette = [
- '// ===== 孩子首页专属色阶(天空蓝渐变族 + 徽章金;单页专用,约定见 uni.scss §14)=====',
- '$c-ci-sky: #E0ECF8; // 顶部渐变终(浅天蓝)',
- '$c-ci-navy: #1E4A7A; // 深海军蓝文字',
- '$c-ci-gold: #FFB800; // 徽章金渐变终',
- '$c-ci-blue-1: #DCE8F5; // 空态卡渐变起',
- '$c-ci-blue-2: #C8DDF0; // 空态卡渐变终',
- ''
- ].join('\n');
- styleBody = styleBody.replace(/(<style[^>]*>\s*\n)/, '$1' + palette + '\n');
- fs.writeFileSync(F, before + styleBody);
- 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, 110)); n++; }
- }
- console.log('remaining non-palette hex:', n);
|