#!/usr/bin/env python # -*- coding: utf-8 -*- """C-2b 旧蓝分流·令牌族批次 2 文件 19 处 $brand-legacy-blue 族(uni.scss L622-625,C-2 待翻转)页面引用清零, 按 C-2 三分法定性——两文件场景全部是 主行动/选中态/hero,无 info 蓝场景: $brand-legacy-blue #4A9BD7 -> $brand-primary #F97316 (按钮/勾号/选中描边/进度文字/百分位值) $brand-legacy-blue-light #63B3ED -> $brand-primary-light #FB923C (渐变亮档,角色伴生) $brand-legacy-blue-tint #F5FAFE -> $uni-primary-pale #FFF7ED (容器极浅底,C-2a-2 #F0F7FF 先例) $brand-legacy-blue-select #F0F8FF -> $brand-primary-soft rgba(249,115,22,0.12) (选中态浅底) dimension-detail.vue 7 处:容器 tint / header hero 渐变 / 百分位值 / 建议序号徽章 / 主按钮渐变 / 次级按钮文字+描边 dimension-questionnaire.vue 12 处:容器 tint / 维度卡选中描边+浅底 / 维度勾号 / 进度文字 / 进度条渐变 / 选项选中描边+浅底 / 选项勾号 / 主按钮渐变 / 次级按钮文字+描边 令牌定义暂留 uni.scss(C-2c 删),页面引用清零后无编译产物残留。 """ import io import re import sys # (page, [(old, new, expect)])——渐变先行,简单声明殿后(模式互斥,双保险) JOBS = [ ('pages/body-detail/dimension-detail.vue', [ ('linear-gradient(135deg, $brand-legacy-blue, $brand-legacy-blue-light)', 'linear-gradient(135deg, $brand-primary, $brand-primary-light)', 2), # header hero + 主按钮 ('background: $brand-legacy-blue-tint;', 'background: $uni-primary-pale;', 1), ('background: $brand-legacy-blue;', 'background: $brand-primary;', 1), # sug-num 徽章 ('color: $brand-legacy-blue;', 'color: $brand-primary;', 2), # 百分位值 + btn-outline ('border: 2rpx solid $brand-legacy-blue;', 'border: 2rpx solid $brand-primary;', 1), ]), ('pages/body-detail/dimension-questionnaire.vue', [ ('linear-gradient(90deg, $brand-legacy-blue, $brand-legacy-blue-light)', 'linear-gradient(90deg, $brand-primary, $brand-primary-light)', 1), # 进度条 ('linear-gradient(135deg, $brand-legacy-blue, $brand-legacy-blue-light)', 'linear-gradient(135deg, $brand-primary, $brand-primary-light)', 1), # 主按钮 ('background: $brand-legacy-blue-select;', 'background: $brand-primary-soft;', 2), # dim-item.active + option.selected ('background: $brand-legacy-blue-tint;', 'background: $uni-primary-pale;', 1), ('border-color: $brand-legacy-blue;', 'border-color: $brand-primary;', 2), # dim-item.active + option.selected ('background: $brand-legacy-blue;', 'background: $brand-primary;', 2), # dim-check + opt-check ('color: $brand-legacy-blue;', 'color: $brand-primary;', 2), # 进度文字 + btn-outline ('border: 2rpx solid $brand-legacy-blue;', 'border: 2rpx solid $brand-primary;', 1), ]), ] RESIDUAL_RE = re.compile(r'\$brand-legacy-blue[a-z0-9-]*') def main(): for page, 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) print(' %-64s -> %-52s x%d' % (old[:64], new[:52], n)) io.open(page, 'w', encoding='utf-8', newline='').write(src) residual = RESIDUAL_RE.findall(src) if residual: raise RuntimeError('%s: 终检残留 %s' % (page, residual)) print('C-2b 执行完毕') if __name__ == '__main__': sys.exit(main())