#!/usr/bin/env python # -*- coding: utf-8 -*- """C-2a-4a:生成 16 个 style 变更文件的验证规则 JSON(.tmp_equiv/sub_c2a4a_*.json)""" import io import json import os import sys TMP = '.tmp_equiv' ORANGE = '#F97316' ORANGE_DARK = '#EA580C' ORANGE_LIGHT = '#FB923C' INFO = '#0EA5E9' PALE = '#FFF7ED' GRAD_3A7CC4 = 'linear-gradient(135deg, #5B9BD5, #3A7CC4)' GRAD_3A7CC2 = 'linear-gradient(135deg, #5B9BD5, #3A7CC2)' GRAD_ORANGE_DARK = 'linear-gradient(135deg, #F97316, #EA580C)' RULES = { 'gates': [ ['border: 2rpx solid #5B9BD5', 'border: 2rpx solid ' + ORANGE], ['background: #5B9BD5', 'background: ' + ORANGE], ['color: #5B9BD5', 'color: ' + ORANGE], ['color: #3A7CC2', 'color: ' + INFO], ['rgba(66,165,245,0.15)', 'rgba(14,165,233,0.15)'], ], 't_families': [ ['border-left: 8rpx solid #4A9BD7', 'border-left: 8rpx solid ' + ORANGE], ['background: #5B9BD5', 'background: ' + ORANGE], ], 't_index': [ ['background: #4A9BD7', 'background: ' + ORANGE], ], 't_plancreate': [ ['color: #4A9BD7', 'color: ' + ORANGE], ['border: 1rpx solid #4A9BD7', 'border: 1rpx solid ' + ORANGE], ['background: #4A9BD7', 'background: ' + ORANGE], ], 't_plandetail': [ ['background: #4A9BD7', 'background: ' + ORANGE], ['color: #4A9BD7', 'color: ' + ORANGE], ], 't_planlist': [ ['background: #4A9BD7', 'background: ' + ORANGE], ], 't_reviewfamily': [ ['background: #4A9BD7', 'background: ' + ORANGE], ['color: #4A9BD7', 'color: ' + INFO], ], 't_reviewworkbench': [ ['background: #4A9BD7', 'background: ' + ORANGE], ['color: #4A9BD7', 'color: ' + INFO], ], 'reportdetail': [ ['#5B9BD5', ORANGE], ], 'profilemenu': [ ['#5B9BD5', INFO], ], 'coupons': [ ['color: #5B9BD5', 'color: ' + INFO], ['background: #5B9BD5', 'background: ' + ORANGE], ], 'reportmgmt': [ ['#5B9BD5', ORANGE], ], 'profileindex': [ [GRAD_3A7CC4, GRAD_ORANGE_DARK], ], 'memberhomedetail': [ [GRAD_3A7CC4, GRAD_ORANGE_DARK], ['#5B9BD5', ORANGE], ], 'articleedit': [ ['#E8F4FD', PALE], ['#5B9BD5', ORANGE], ], 'gatelock': [ [GRAD_3A7CC2, GRAD_ORANGE_DARK], ['color: #8FC5E8', 'color: ' + ORANGE_LIGHT], ['rgba(143,197,232,0.7)', 'rgba(251,146,60,0.7)'], ['rgba(143,197,232,0.5)', 'rgba(251,146,60,0.5)'], ], } def main(): if not os.path.isdir(TMP): os.makedirs(TMP) for name, rules in RULES.items(): p = os.path.join(TMP, 'sub_c2a4a_%s.json' % name) io.open(p, 'w', encoding='utf-8').write(json.dumps(rules, ensure_ascii=False, indent=2)) print('written %s (%d rules)' % (p, len(rules))) if __name__ == '__main__': sys.exit(main())