| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """C-2a-4b 旧蓝分流·大家伙批次 7 文件
- child-index(16) / parent-index(6) / index-home(3 JS) / wuxing-sandbox(5) /
- articles.vue(4) / dimension-detail(3 JS) / member-detail(1 JS)
- 关键决策:
- - child-index:clay 设计系统整体迁移品牌橙(注释/渐变/边框/阴影);数据类目槽
- task-cat--life / quick-icon--growth -> sky-600 rgba(2,132,199,x)(防与 study/tasks 的
- sky-500 rgba(14,165,233,x) 及既有橙槽撞色)
- - parent-index:stat-icon-orange/act-add 名橙实蓝 -> 恢复品牌橙语义(主行动角色);
- milestone-trophy/pending-icon--blue/advice -> info 蓝;JS 渐变蓝槽 -> info 蓝渐变
- (数组第 4 槽已是橙,禁撞色)
- - wuxing-sandbox:深海军蓝面板上的旧蓝族仅翻「品牌氛围层」——ambient 光晕 + toggle 选中态;
- #8FC5E8 面板 chrome(title/badge/energy/toggle-inactive)与 #42A5F5 水行语义保留
- (chrome 翻橙会与火行 #FF6B35 撞色)
- - articles.vue:弃 $c-brand-legacy 局部声明(含 C-2 移交注释块),内联到用法
- - dimension-detail canvas / member-detail:JS 真实 hex(禁 SCSS 变量)
- """
- import io
- import re
- import sys
- ORANGE = '$brand-primary'
- ORANGE_DARK = '$brand-primary-dark'
- ORANGE_LIGHT = '$brand-primary-light'
- # 每文件:[(old, new, expect_hit)] 按序施加;fix_lang=True 时补 lang="scss"
- JOBS = [
- # ---- 1. child-index:clay 设计系统整体迁移 ----
- ('pages/home-pages/child-index.vue', True, [
- ('色彩体系:品牌蓝(#5B9BD5)+浅蓝(#8FC5E8)', '色彩体系:品牌橙(#F97316)+浅橙(#FB923C)', 1),
- ('积分卡片 — Flat Rounded 蓝色渐变', '积分卡片 — Flat Rounded 橙色渐变', 1),
- ('border: 4rpx solid #8FC5E8;', 'border: 4rpx solid %s;' % ORANGE_LIGHT, 1),
- ('rgba(143,197,232,0.30)', 'rgba(251,146,60,0.30)', 1),
- ('linear-gradient(145deg, #8FC5E8, #5B9BD5);',
- 'linear-gradient(145deg, %s, %s);' % (ORANGE_LIGHT, ORANGE), 1),
- ('border: 4rpx solid #3A7CC4;', 'border: 4rpx solid %s;' % ORANGE_DARK, 1),
- ('rgba(91,155,213,0.25)', 'rgba(249,115,22,0.25)', 1),
- ('rgba(91,155,213,0.18)', 'rgba(249,115,22,0.18)', 1),
- # 数据类目槽(值唯一,防撞色)
- ('rgba(91,155,213,0.12)', 'rgba(2,132,199,0.12)', 1), # task-cat--life
- ('rgba(91,155,213,0.15)', 'rgba(2,132,199,0.15)', 1), # quick-icon--growth
- # 中性 clay 阴影随品牌族
- ('rgba(91,155,213,0.08)', 'rgba(249,115,22,0.08)', 3),
- ('rgba(91,155,213,0.06)', 'rgba(249,115,22,0.06)', 3),
- ]),
- # ---- 2. parent-index:同名不同色需整行定位 ----
- ('pages/home-pages/parent-index.vue', False, [
- ("'linear-gradient(135deg, #5B9BD5, #8FC5E8)',",
- "'linear-gradient(135deg, #0EA5E9, #38BDF8)',", 1),
- ('.stat-icon-orange { background: rgba(91, 155, 213, 0.12); }',
- '.stat-icon-orange { background: rgba(249,115,22,0.12); }', 1),
- ('.milestone-trophy { background: rgba(91, 155, 213, 0.12); }',
- '.milestone-trophy { background: rgba(14,165,233,0.12); }', 1),
- ('.pending-icon--blue { background: rgba(91,155,213,0.12); }',
- '.pending-icon--blue { background: rgba(14,165,233,0.12); }', 1),
- ('background: rgba(91,155,213,0.1);', 'background: rgba(14,165,233,0.1);', 1),
- ('.act-add { background: rgba(91, 155, 213, 0.12); }',
- '.act-add { background: rgba(249,115,22,0.12); }', 1),
- ]),
- # ---- 3. index-home:JS 渐变蓝槽 x3(第 4 槽已橙,禁撞色)----
- ('pages/index-home/index.vue', False, [
- ("'linear-gradient(135deg, #5B9BD5, #8FC5E8)',",
- "'linear-gradient(135deg, #0EA5E9, #38BDF8)',", 3),
- ]),
- # ---- 4. wuxing-sandbox:氛围层 + 选中态翻橙,chrome/水行保留 ----
- ('components/wuxing-sandbox.vue', True, [
- ('rgba(91, 155, 213, 0.04)', 'rgba(249,115,22,0.04)', 1),
- ('rgba(66, 165, 245, 0.03)', 'rgba(251,146,60,0.03)', 1),
- ('rgba(91,155,213,0.10)', 'rgba(249,115,22,0.10)', 1),
- ('linear-gradient(135deg, #5B9BD5, #3A7CC2);',
- 'linear-gradient(135deg, %s, %s);' % (ORANGE, ORANGE_DARK), 1),
- ('border-color: #5B9BD5;', 'border-color: %s;' % ORANGE, 1),
- ]),
- # ---- 5. articles.vue:弃局部声明,内联到用法 ----
- ('pages/mind-detail/articles.vue', False, [
- ('// C-2 待翻转:旧品牌蓝残留(filter-chip.active 底色 / article-category 前景 + 浅底)。\n'
- '// B 批纪律保原值令牌化,翻转移交 C-2 角色分流(此处为品牌交互用法,预案翻品牌橙)\n'
- '$c-brand-legacy: #5B9BD5;\n'
- '$c-brand-legacy-tint: rgba(91,155,213,0.1);\n', '', 1),
- ('background: $c-brand-legacy;', 'background: %s;' % ORANGE, 1),
- ('color: $c-brand-legacy;', 'color: %s;' % ORANGE, 1),
- ('background: $c-brand-legacy-tint;', 'background: rgba(249,115,22,0.1);', 1),
- ]),
- # ---- 6. dimension-detail:canvas JS 真实 hex ----
- ('pages/body-detail/dimension-detail.vue', False, [
- ("ctx.setStrokeStyle('#4A9BD7')", "ctx.setStrokeStyle('#F97316')", 1),
- ("ctx.setFillStyle('rgba(74, 155, 215, 0.1)')",
- "ctx.setFillStyle('rgba(249,115,22,0.1)')", 1),
- ("ctx.setFillStyle('#4A9BD7')", "ctx.setFillStyle('#F97316')", 1),
- ]),
- # ---- 7. member-detail:home 槽 -> 品牌橙(与 FamilyRelationGraph home 一致)----
- ('pages/member-detail/member-detail.vue', False, [
- ("color: '#5B9BD5', gradient: 'linear-gradient(135deg, #5B9BD5, #3A7CC4)'",
- "color: '#F97316', gradient: 'linear-gradient(135deg, #F97316, #EA580C)'", 1),
- ]),
- ]
- RESIDUAL_RE = re.compile(
- r'(?<![0-9A-Fa-f])#(?:5B9BD5|3A7CC4|3A7CC2|4A9BD7|63B3ED|8FC5E8)(?![0-9A-Fa-f])', re.I)
- RESIDUAL_RGBA = re.compile(r'rgba\((?:91, ?155, ?213|74, ?155, ?215|143, ?197, ?232)')
- STYLE_RE = re.compile(r'^[ \t]*<style[^>]*>[\s\S]*?</style>', re.M)
- def fix_lang(src, page):
- m = STYLE_RE.search(src)
- block = m.group(0)
- first, rest = block.split('\n', 1)
- if 'lang=' not in first:
- if '<style scoped>' in first:
- first = first.replace('<style scoped>', '<style scoped lang="scss">', 1)
- elif '<style>' in first:
- first = first.replace('<style>', '<style lang="scss">', 1)
- else:
- raise RuntimeError('%s: 无法识别的 style 标签: %s' % (page, first.strip()))
- print(' [lang] 补 lang="scss"')
- src = src[:m.start()] + first + '\n' + rest + src[m.end():]
- return src
- def main():
- for page, need_lang, subs in JOBS:
- src = io.open(page, encoding='utf-8').read()
- print('== %s ==' % page)
- for old, new, expect in subs:
- n = src.count(old)
- if n != expect:
- raise RuntimeError('%s: hit=%d(要求 %d):: %r' % (page, n, expect, old[:60]))
- src = src.replace(old, new)
- label = (old[:50] + '…') if len(old) > 50 else old
- print(' %-52s -> %-30s x%d' % (label.replace('\n', '\\n'), new[:30], n))
- if need_lang:
- src = fix_lang(src, page)
- io.open(page, 'w', encoding='utf-8', newline='').write(src)
- residual = RESIDUAL_RE.findall(src) + RESIDUAL_RGBA.findall(src)
- if residual:
- raise RuntimeError('%s: 终检残留 %s' % (page, residual))
- print('C-2a-4b 执行完毕')
- if __name__ == '__main__':
- sys.exit(main())
|