fix(admin): 统一后台使用说明、普通金额和报表辅助色
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const assert = require('node:assert/strict')
|
||||
const test = require('node:test')
|
||||
const { parse, compileScript } = require('@vue/compiler-sfc')
|
||||
const ts = require('typescript')
|
||||
const vue = require('vue')
|
||||
const { renderToString } = require('vue/server-renderer')
|
||||
const src = path.join(__dirname, '../src')
|
||||
const read = rel => fs.readFileSync(path.join(src, rel), 'utf8')
|
||||
const pages = ["channel/h5","channel/open_setting","channel/weapp","channel/wx_oa/config","channel/wx_oa/reply/default_reply","channel/wx_oa/reply/follow_reply","channel/wx_oa/reply/keyword_reply","article/column/index","finance/balance_details","finance/recharge_record","message/notice/index","setting/pay/config/index","setting/system/cache"]
|
||||
test('普通说明仅在 V2 使用原生 info 图标,经典版保留 warning;内容与关闭行为不变', async () => {
|
||||
const filename = path.join(src, 'components/AdminPageHint.vue')
|
||||
const { descriptor } = parse(fs.readFileSync(filename, 'utf8'), { filename })
|
||||
const { content } = compileScript(descriptor, { id: 'hint', inlineTemplate: true })
|
||||
const js = ts.transpileModule(content, { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 } }).outputText
|
||||
for (const [adminUi, type] of [['v2','info'], ['legacy','warning']]) {
|
||||
const m = { exports: {} }
|
||||
new Function('require', 'module', 'exports', js)(k => k === '@/stores/modules/setting' ? { default: () => ({ adminUi }) } : require(k), m, m.exports)
|
||||
let actual
|
||||
const app = vue.createSSRApp(m.exports.default, { title: '用户充值记录' })
|
||||
app.component('el-alert', { props: { title: String, type: String, closable: Boolean, showIcon: Boolean },
|
||||
setup(props) { actual = { ...props };return () => vue.h('div', props.title) } })
|
||||
assert.match(await renderToString(app), /用户充值记录/)
|
||||
assert.deepEqual(actual, { title: '用户充值记录', type, closable: false, showIcon: true })
|
||||
}
|
||||
})
|
||||
test('仅这 13 个常驻使用说明启用;存储迁移、身份冲突和退款仍使用原语义', () => {
|
||||
for (const page of pages) assert.match(read('views/'+page+'.vue'), /<admin-page-hint title="温馨提示:[^"]+"\s*\/>/)
|
||||
const storage = read('views/setting/storage/index.vue')
|
||||
assert.match(storage, /<el-alert type="warning"/)
|
||||
assert.match(storage, /请勿随意切换存储方式/)
|
||||
assert.match(read('views/permission/identity/index.vue'), /type="warning"/)
|
||||
assert.doesNotMatch(read('views/finance/refund_record.vue'), /admin-page-hint/)
|
||||
})
|
||||
@@ -0,0 +1,45 @@
|
||||
const assert = require('node:assert/strict')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const test = require('node:test')
|
||||
const { parse, compileStyle } = require('@vue/compiler-sfc')
|
||||
const postcss = require('postcss')
|
||||
|
||||
const cases = [
|
||||
['doctor/medicine.vue', 'medicine-price', ['row.settlement_price', 'row.retail_price']],
|
||||
['tcm/diagnosis/components/PatientOrderList.vue', 'patient-order-amount', ['row.amount']],
|
||||
['consumer/prescription/components/PrescriptionOrderDetailDrawer.vue', 'po-regular-metric', [
|
||||
'detailData.amount', 'detailData.linked_pay_paid_total', 'detailLinkedPayOrders.length',
|
||||
'detailPrescription.amount', 'row.amount', 'row.amount'
|
||||
]]
|
||||
]
|
||||
|
||||
for (const [rel, marker, fields] of cases) {
|
||||
test(rel + ':只给普通金额/笔数上浅色墨色,不覆盖同屏状态或 H5', () => {
|
||||
const filename = path.join(__dirname, '../src/views', rel)
|
||||
const { descriptor, errors } = parse(fs.readFileSync(filename, 'utf8'), { filename })
|
||||
assert.deepEqual(errors, [])
|
||||
const template = descriptor.template.content
|
||||
const nodes = [...template.matchAll(new RegExp('<(?:div|span) class="[^"]*\\b' + marker + '\\b[^"]*">([^<]+)<', 'g'))]
|
||||
assert.deepEqual(nodes.map((m, n) => m[1].includes(fields[n])), fields.map(() => true))
|
||||
|
||||
const rules = []
|
||||
for (const block of descriptor.styles) {
|
||||
const style = compileStyle({ filename, source: block.content, id: 'data-v-price-test', scoped: block.scoped, preprocessLang: block.lang })
|
||||
assert.deepEqual(style.errors, [])
|
||||
postcss.parse(style.code).walkRules(rule => {
|
||||
if (rule.selector.includes('.' + marker)) rules.push(rule)
|
||||
})
|
||||
}
|
||||
assert.equal(rules.length, 1)
|
||||
const rule = rules[0]
|
||||
assert.equal(rule.selectors.length, 1)
|
||||
assert.equal(rule.parent.name, 'media')
|
||||
assert.equal(rule.parent.params, 'screen')
|
||||
assert.match(rule.selector, /:root\[data-admin-ui=['"]?v2['"]?\]:not\(\.dark\)/)
|
||||
assert.ok(rule.selector.endsWith('.' + marker + '[data-v-price-test]'))
|
||||
// 共享子件会出现在独立 H5 诊单;透传到 body 的订单详情仍须以后台外壳为限。
|
||||
if (rel.includes('/components/')) assert.ok(rule.selector.includes('.layout-default'))
|
||||
assert.deepEqual(rule.nodes.map(d => [d.prop, d.value]), [['color', 'var(--zyt-ink)']])
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
const test = require('node:test')
|
||||
const assert = require('node:assert/strict')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const { parse, compileStyle } = require('@vue/compiler-sfc')
|
||||
const postcss = require('postcss')
|
||||
|
||||
function read(name) {
|
||||
const filename = path.join(__dirname, '../src/views/decoration', name)
|
||||
const { descriptor, errors } = parse(fs.readFileSync(filename, 'utf8'), { filename })
|
||||
assert.deepEqual(errors, [])
|
||||
const rules = []
|
||||
for (const block of descriptor.styles) {
|
||||
const css = compileStyle({ filename, source: block.content, id: 'data-v-editor-test', scoped: block.scoped, preprocessLang: block.lang })
|
||||
assert.deepEqual(css.errors, [])
|
||||
postcss.parse(css.code).walkRules(rule => rules.push(rule))
|
||||
}
|
||||
return { rules, template: descriptor.template.content }
|
||||
}
|
||||
test('PC 编辑工具条只在新版换成系统卡面;保存身份校验和原操作不变', () => {
|
||||
const { rules, template } = read('pc_details.vue')
|
||||
const theme = rules.filter(r => /data-admin-ui=['"]?v2/.test(r.selector))
|
||||
assert.equal(theme.length, 1)
|
||||
assert.match(theme[0].selector, /\.pc-editor-toolbar\[/)
|
||||
assert.deepEqual(Object.fromEntries(theme[0].nodes.map(d => [d.prop, d.value])), {
|
||||
'--editor-toolbar-surface': 'var(--zyt-surface)', '--editor-toolbar-ink': 'var(--zyt-text)'
|
||||
})
|
||||
assert.match(template, /v-perms="\['decorate:pages:save'\]"/)
|
||||
assert.match(template, /:type="settings\.adminUi === 'v2' \? 'primary' : 'default'"/)
|
||||
assert.match(template, /@click="setData"/)
|
||||
assert.match(template, /@click="handleBack"/)
|
||||
})
|
||||
test('轮播的后台说明取中性底色和正文色;改动不选择预览图或单选项', () => {
|
||||
const { rules, template } = read('component/widgets/banner/attr.vue')
|
||||
const theme = rules.filter(r => /data-admin-ui=['"]?v2/.test(r.selector))
|
||||
assert.equal(theme.length, 1)
|
||||
assert.match(theme[0].selector, /\.banner-editor-hint\[/)
|
||||
assert.deepEqual(Object.fromEntries(theme[0].nodes.map(d => [d.prop, d.value])), {
|
||||
'background-color': 'var(--zyt-surface-subtle)', color: 'var(--zyt-text)'
|
||||
})
|
||||
assert.match(template, /banner-editor-hint[^>]*>\s*开启背景联动后/)
|
||||
assert.match(template, /v-model="contentData.bg_style"/)
|
||||
})
|
||||
@@ -0,0 +1,28 @@
|
||||
const assert = require('node:assert/strict')
|
||||
const test = require('node:test')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const postcss = require('postcss')
|
||||
const { parse, compileStyle } = require('@vue/compiler-sfc')
|
||||
for (const file of ['revisit_rate/index.vue', 'revisit_assign_rate/components/CohortReport.vue']) {
|
||||
test(file + ':真实分母不冒用占位色;经典、暗色与打印保持原值', () => {
|
||||
const filename = path.join(__dirname, '../src/views/stats', file)
|
||||
const { descriptor } = parse(fs.readFileSync(filename,'utf8'), { filename })
|
||||
const block = descriptor.styles.at(-1)
|
||||
const result = compileStyle({ filename, id: 'data-v-rate', scoped: block.scoped, source: block.content, preprocessLang: block.lang })
|
||||
assert.deepEqual(result.errors, [])
|
||||
const css = postcss.parse(result.code), refs = []
|
||||
css.walkDecls('--revisit-ratio-ink', d => {
|
||||
assert.equal(d.value, 'var(--zyt-text)')
|
||||
assert.match(d.parent.selector, /data-admin-ui=v2\]:not\(\.dark\).*\.revisit-rate-page/)
|
||||
assert.equal(d.parent.parent.params, 'screen')
|
||||
refs.push('definition')
|
||||
})
|
||||
css.walkDecls('color', d => { if(d.value.includes('--revisit-ratio-ink')) {
|
||||
assert.equal(d.value,'var(--revisit-ratio-ink, var(--el-text-color-placeholder))')
|
||||
assert.match(d.parent.selector,/\.rate-cell-sub/)
|
||||
refs.push('consumer')
|
||||
}})
|
||||
assert.deepEqual(refs, ['definition','consumer'])
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
const assert = require('node:assert/strict')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const test = require('node:test')
|
||||
const postcss = require('postcss')
|
||||
const { compileStyle, parse } = require('@vue/compiler-sfc')
|
||||
|
||||
function lightPageStyle(page, root) {
|
||||
const filename = path.join(__dirname, '../src/views', page)
|
||||
const { descriptor, errors } = parse(fs.readFileSync(filename, 'utf8'), { filename })
|
||||
assert.deepEqual(errors, [])
|
||||
const block = descriptor.styles.find(s => s.scoped && s.content.includes('data-admin-ui'))
|
||||
assert.ok(block, page + ' 缺少局部亮色规则')
|
||||
const css = compileStyle({
|
||||
filename, id: 'data-v-tone-test', scoped: true, source: block.content, preprocessLang: block.lang
|
||||
})
|
||||
assert.deepEqual(css.errors, [])
|
||||
const declarations = new Map()
|
||||
postcss.parse(css.code).walkRules(rule => {
|
||||
assert.equal(rule.parent.name, 'media')
|
||||
assert.equal(rule.parent.params, 'screen')
|
||||
for (const selector of rule.selectors) {
|
||||
assert.ok(selector.startsWith(':root[data-admin-ui=v2]:not(.dark) ' + root))
|
||||
assert.match(selector, /\[data-v-tone-test\]/)
|
||||
assert.doesNotMatch(selector, /\.el-|\.active\b|\.bubble-|\.task-error|\.session-tag/)
|
||||
rule.walkDecls(decl => {
|
||||
assert.match(decl.prop, /^(?:color|background-color|outline-color)$/)
|
||||
assert.ok(!decl.important)
|
||||
declarations.set(selector.replaceAll('[data-v-tone-test]', '') + ':' + decl.prop, decl.value)
|
||||
})
|
||||
}
|
||||
})
|
||||
function value(target, prop) {
|
||||
return declarations.get(':root[data-admin-ui=v2]:not(.dark) ' + root + ' ' + target + ':' + prop)
|
||||
}
|
||||
return { value, template: descriptor.template.content, original: descriptor.styles[0].content }
|
||||
}
|
||||
|
||||
test('企微会话的管理区小字采用正常可读的正文色,保留会话选中、消息方向和任务状态', () => {
|
||||
const { value, original } = lightPageStyle('chat/index.vue', '.qywx-im')
|
||||
for (const name of ['.session-preview', '.session-time', '.session-staff', '.msg-customer-sub', '.no-session .tips .text-sm']) {
|
||||
assert.equal(value(name, 'color'), 'var(--zyt-text)', name)
|
||||
}
|
||||
assert.equal(value('.col-message', 'background-color'), 'var(--art-gray-200)')
|
||||
assert.match(original, /&\.active\s*\{\s*background: #e6f1fc;/)
|
||||
assert.match(fs.readFileSync(path.join(__dirname, '../src/views/chat/components/MessageBubble.vue'), 'utf8'), /background: #95ec69;/)
|
||||
})
|
||||
|
||||
test('企微客户总数与今日新增共用指标文字色,24 小时图保留零值轨道和当前小时标记', () => {
|
||||
const { value, template, original } = lightPageStyle('fans/qywx.vue', '.qywx-customer-page')
|
||||
assert.equal(value('.customer-kpi-value', 'color'), 'var(--zyt-ink)')
|
||||
assert.equal(value('.hourly-bar:not(.is-empty)', 'background-color'), 'var(--zyt-selected-ink, var(--zyt-primary))')
|
||||
assert.equal(value('.hourly-bar.is-current', 'outline-color'), 'var(--zyt-ink)')
|
||||
for (const metric of ['total', 'today']) {
|
||||
assert.match(template, new RegExp('class="[^"]*customer-kpi-value[^"]*">\\s*{{ stats\\.' + metric + ' }}'))
|
||||
}
|
||||
assert.match(template, /'is-empty': c === 0/)
|
||||
assert.match(template, /'is-current': h === currentHour/)
|
||||
assert.match(template, /:type="syncStatusTagType"/)
|
||||
assert.match(original, /&\.is-empty\s*\{\s*background: var\(--el-border-color-lighter\);/)
|
||||
})
|
||||
Reference in New Issue
Block a user