✨ feat: 重构管理后台并增强组件系统与回收站功能
* 新增自适应数值与窗口分析工具,提升交互体验 * 优化回收站模块逻辑,增加展示与选择功能 * 引入 Macaron 主题配置文件并更新 Tailwind 配置 * 精简基础组件代码,移除冗余样式与设置项 * 完善测试用例,覆盖 UI 系统与回收站工作流 * 更新多语言配置,支持功能变更后的文案需求
This commit is contained in:
1 parent
614b9a2104
commit
9b22534e2b
61 files changed
+1624
-832
No files matched your search
@@ -0,0 +1,109 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { parse } from 'vue/compiler-sfc'
|
||||
const palettePath = new URL('../src/theme/macaron.json', import.meta.url)
|
||||
const luminance = hex => {
|
||||
const channels = hex.slice(1).match(/../g).map(c => parseInt(c, 16) / 255).map(c => c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4)
|
||||
return channels[0] * .2126 + channels[1] * .7152 + channels[2] * .0722
|
||||
}
|
||||
test('all semantic button colors retain AA text contrast in both themes', () => {
|
||||
const { buttons } = JSON.parse(readFileSync(palettePath))
|
||||
for (const mode of ['light', 'dark']) for (const [name, colors] of Object.entries(buttons[mode])) {
|
||||
for (const bg of [colors.bg, colors.hover]) {
|
||||
const values = [luminance(bg), luminance(colors.text)].sort((a,b) => b-a)
|
||||
assert.ok((values[0]+.05)/(values[1]+.05)>=4.5, `${mode}/${name}: low contrast`)
|
||||
}
|
||||
}
|
||||
})
|
||||
test('palette covers all Tailwind color families used by the application including opacity variants', () => {
|
||||
const { colors } = JSON.parse(readFileSync(palettePath))
|
||||
for (const family of ['blue','indigo','cyan','sky','green','emerald','teal','red','rose','pink','purple','violet','yellow','amber','orange','gray','slate','zinc','neutral','stone','lime','fuchsia']) {
|
||||
for (const shade of [50,100,200,300,400,500,600,700,800,900,950]) assert.match(colors[family][shade], /^#[a-f0-9]{6}$/)
|
||||
}
|
||||
})
|
||||
test('mobile page-size chooser does not span the whole pagination row', () => {
|
||||
const { descriptor }=parse(readFileSync(new URL('../src/components/common/DataPagination.vue',import.meta.url),'utf8'))
|
||||
assert.ok(!descriptor.template.content.match(/<select[\s\S]*?class="[^"]*col-span-3/), 'page size occupies the full row')
|
||||
})
|
||||
|
||||
test('all native action buttons use shared motion unless they are cards, switches or backdrops', async () => {
|
||||
const { globSync } = await import('glob')
|
||||
for(const file of globSync('src/**/*.vue')) {
|
||||
const { descriptor }=parse(readFileSync(file,'utf8'))
|
||||
function visit(node) {
|
||||
if(node.tag==='button') {
|
||||
const opening=node.loc.source.match(/^<button\b(?:[^>"']|"[^"]*"|'[^']*')*>/s)?.[0]||''
|
||||
assert.ok(/fcb-action|theme-2026-card-hover|role="switch"|inset-0/.test(opening), `Missing button motion: ${file}`)
|
||||
}
|
||||
for(const child of node.children||[])visit(child)
|
||||
}
|
||||
if(descriptor.template?.ast)visit(descriptor.template.ast)
|
||||
}
|
||||
})
|
||||
|
||||
test('primary submit buttons do not add a second white or gradient hover overlay', () => {
|
||||
for(const path of ['src/views/SendFileView.vue','src/components/common/RetrieveForm.vue']) {
|
||||
const source=readFileSync(path,'utf8')
|
||||
assert.ok(!/group-hover:opacity-(20|100)/.test(source), `${path}: extra hover brightness layer`)
|
||||
assert.ok(source.includes('fcb-button-primary'))
|
||||
}
|
||||
})
|
||||
|
||||
test('large content sections do not opt into card movement', async () => {
|
||||
const {globSync}=await import('glob')
|
||||
for(const path of globSync('src/views/**/*.vue')) {
|
||||
const {descriptor}=parse(readFileSync(path,'utf8'))
|
||||
function visit(node) {
|
||||
if(node.tag==='section') {
|
||||
const opening=node.loc.source.match(/^<section\b(?:[^>"']|"[^"]*"|'[^']*')*>/s)?.[0]||''
|
||||
assert.ok(!opening.includes('theme-2026-card-hover'), `Moving large container: ${path}`)
|
||||
}
|
||||
for(const child of node.children||[])visit(child)
|
||||
}
|
||||
if(descriptor.template?.ast)visit(descriptor.template.ast)
|
||||
}
|
||||
})
|
||||
|
||||
test('settings shell and shared data table stay stationary while child actions opt in separately', () => {
|
||||
for(const path of ['src/views/manage/SystemSettingsView.vue','src/components/common/DataTable.vue']) {
|
||||
const source=readFileSync(path,'utf8')
|
||||
const outer=source.match(/class="[^"]*fcb-static-container[^"]*"/)?.[0]
|
||||
assert.ok(outer && !outer.includes('theme-2026-card-hover'),path)
|
||||
}
|
||||
})
|
||||
|
||||
test('list hover styles do not render an inset frame or lift rows', async () => {
|
||||
const {default:postcss}=await import('postcss')
|
||||
const css=postcss.parse(readFileSync('src/assets/style/main.css','utf8'))
|
||||
let found=false
|
||||
css.walkRules(rule=>{
|
||||
if(rule.selector.includes('.fcb-list-row:hover')) {
|
||||
const declarations=Object.fromEntries(rule.nodes.filter(n=>n.type==='decl').map(n=>[n.prop,n.value]))
|
||||
assert.equal(declarations['box-shadow'],'none')
|
||||
assert.equal(declarations.transform,'none')
|
||||
found=true
|
||||
}
|
||||
})
|
||||
assert.ok(found)
|
||||
})
|
||||
|
||||
test('light and dark card shadows use their separately approved light directions', async () => {
|
||||
const {default:postcss}=await import('postcss')
|
||||
const css=postcss.parse(readFileSync('src/assets/style/main.css','utf8'))
|
||||
const shadows={}
|
||||
css.walkDecls('--fcb-card-shadow',decl=>{shadows[decl.parent.selector]=decl.value})
|
||||
const rgb=shadow=>[...shadow.matchAll(/rgba\((\d+),(\d+),(\d+),[^)]+\)/g)].map(m=>Number(m[1])+Number(m[2])+Number(m[3]))
|
||||
const light=rgb(shadows[':root']),dark=rgb(shadows['.dark'])
|
||||
assert.equal(light.length,2);assert.equal(dark.length,2)
|
||||
assert.ok(light[0]>light[1],'light theme: top-left must be lighter')
|
||||
assert.ok(dark[0]<dark[1],'dark theme: top-left must be darker')
|
||||
})
|
||||
|
||||
test('all five expiration choices retain native multi-selection and shared action motion', () => {
|
||||
const source=readFileSync('src/views/manage/SystemSettingsView.vue','utf8')
|
||||
const group=source.slice(source.indexOf('v-for="style in'),source.indexOf('v-for="style in')+1500)
|
||||
assert.ok(group.includes("['day', 'hour', 'minute', 'forever', 'count']"))
|
||||
assert.ok(group.includes('type="checkbox"') && group.includes('v-model="config.expireStyle"'))
|
||||
assert.ok(group.includes('fcb-action fcb-choice-face'))
|
||||
})
|
||||
Reference in new issue
Block a user