| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #!/usr/bin/env node
- /**
- * D28: diet/preferences.vue 饮食偏好页清理 (debt 48 -> 0)
- * #FFF3E6 -> $warm-cream(4 文件复用);其余暖棕/奶油色阶收编局部 $c-dp-*
- */
- const fs = require('fs');
- const F = 'pages/diet/preferences.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 = [['#FFF3E6', '$warm-cream']];
- 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 = [
- ['#FFE3C7', '$c-dp-track'],
- ['#C2A78A', '$c-dp-label'],
- ['#4A2E1A', '$c-dp-ink'],
- ['#A08B72', '$c-dp-muted'],
- ['#F5F0EA', '$c-dp-chip'],
- ['#6B5340', '$c-dp-chip-ink'],
- ['#E8732A', '$c-dp-accent'],
- ['#FFD9B8', '$c-dp-line'],
- ['#FFF9F2', '$c-dp-input'],
- ['#FFFDF8', '$c-dp-footer'],
- ['#FFE9D4', '$c-dp-footer-line'],
- ];
- 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-dp-track: #FFE3C7; // 进度条底轨',
- '$c-dp-label: #C2A78A; // 进度标签文字',
- '$c-dp-ink: #4A2E1A; // 主文字深棕',
- '$c-dp-muted: #A08B72; // 辅助文字浅棕',
- '$c-dp-chip: #F5F0EA; // 选项胶囊底',
- '$c-dp-chip-ink: #6B5340; // 选项胶囊文字',
- '$c-dp-accent: #E8732A; // 选中态强调橙',
- '$c-dp-line: #FFD9B8; // 输入框描边',
- '$c-dp-input: #FFF9F2; // 输入框底',
- '$c-dp-footer: #FFFDF8; // 底部操作条底',
- '$c-dp-footer-line: #FFE9D4; // 底部操作条描边',
- ''
- ].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);
|