✨ feat: 重构管理后台并增强组件系统与回收站功能
* 新增自适应数值与窗口分析工具,提升交互体验 * 优化回收站模块逻辑,增加展示与选择功能 * 引入 Macaron 主题配置文件并更新 Tailwind 配置 * 精简基础组件代码,移除冗余样式与设置项 * 完善测试用例,覆盖 UI 系统与回收站工作流 * 更新多语言配置,支持功能变更后的文案需求
This commit is contained in:
1 parent
614b9a2104
commit
9b22534e2b
61 files changed
+1624
-832
No files matched your search
@@ -35,3 +35,22 @@ Seven days is inclusive in both directions; older or more distant dates use
|
||||
exact local date/time. Relative labels refresh every minute. Native title text
|
||||
retains the exact date/time. The three-day cleanup warning is independent of
|
||||
the seven-day formatting boundary. These tests do not modify backend data.
|
||||
|
||||
## 2026 buttons, palette and responsive controls
|
||||
|
||||
- `npm run test:ui`: palette text contrast, native action coverage, stationary
|
||||
large sections, no submit hover overlays, and real Vue component SSR tests.
|
||||
- With Vite running, open `/theme-assets/tests/ui-system.html` in a clean browser
|
||||
window. Test at 320/390/430px and desktop widths; append `?dark` for dark mode.
|
||||
The fixture uses real components and checks rendered heights, same-row pagination,
|
||||
date part styling, leap-year changes and pagination emissions. It displays its
|
||||
results; hover on buttons/cards to inspect motion without business operations.
|
||||
|
||||
The native UI harness is separate from server-side integration tests. Code
|
||||
coverage for the existing motion/time helpers does not measure CSS coverage.
|
||||
|
||||
Final interaction rules: large settings/table/section containers stay fixed;
|
||||
inner cards and action buttons retain their motion. List rows only fade their
|
||||
background with no border or box-shadow. Light card shadows are bright at the
|
||||
upper left and shaded at the lower right; dark mode reverses that direction.
|
||||
Primary submit actions must not add white/gradient hover overlays.
|
||||
@@ -0,0 +1,10 @@
|
||||
import {test} from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {fitValueFontSize} from '../src/utils/adaptiveValue.ts'
|
||||
test('fits the value to available width without exceeding readable bounds',()=>{
|
||||
assert.equal(fitValueFontSize(120,100,24,14),24)
|
||||
assert.equal(fitValueFontSize(80,120,24,14),16)
|
||||
assert.equal(fitValueFontSize(20,120,24,14),14)
|
||||
assert.equal(fitValueFontSize(0,120,24,14),24)
|
||||
assert.equal(fitValueFontSize(100,0,24,14),24)
|
||||
})
|
||||
@@ -0,0 +1,25 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { summarizeAnalyticsWindow } from '../src/utils/analyticsWindow.ts'
|
||||
const rows = [
|
||||
{ date: 'a', downloads: 1, uploads: 2, downloadTraffic: 100, uploadTraffic: 10 },
|
||||
{ date: 'b', downloads: 3, uploads: 4, downloadTraffic: 300, uploadTraffic: 30 },
|
||||
{ date: 'c', downloads: 5, uploads: 6, downloadTraffic: 500, uploadTraffic: 50 },
|
||||
{ date: 'd', downloads: 7, uploads: 8, downloadTraffic: 700, uploadTraffic: 70 }
|
||||
]
|
||||
test('window totals only include the currently visible chart range', () => {
|
||||
assert.deepEqual(summarizeAnalyticsWindow(rows, 1, 2), {
|
||||
downloads: 8, uploads: 10, downloadTraffic: 800, uploadTraffic: 80
|
||||
})
|
||||
assert.deepEqual(summarizeAnalyticsWindow(rows, 2.3, 1.2), {
|
||||
downloads: 12, uploads: 14, downloadTraffic: 1200, uploadTraffic: 120
|
||||
})
|
||||
})
|
||||
test('window totals clamp outside offsets and empty rows safely', () => {
|
||||
assert.deepEqual(summarizeAnalyticsWindow(rows, -4, 1), {
|
||||
downloads: 1, uploads: 2, downloadTraffic: 100, uploadTraffic: 10
|
||||
})
|
||||
assert.deepEqual(summarizeAnalyticsWindow(rows, 99, 10), {
|
||||
downloads: 0, uploads: 0, downloadTraffic: 0, uploadTraffic: 0
|
||||
})
|
||||
})
|
||||
Vendored
+98
@@ -0,0 +1,98 @@
|
||||
<template>
|
||||
<main :style="{padding:'12px',background:'var(--fcb-bg)',color:'var(--fcb-text)'}">
|
||||
<h2 style="font-size:18px;font-weight:bold">2026 组件回归 · {{ width }}px</h2>
|
||||
<p style="font-size:12px;margin:8px 0">本地测试,无业务数据</p>
|
||||
<pre data-results style="white-space:pre-wrap;font-size:12px;margin:10px 0;color:inherit">{{ result }}</pre>
|
||||
<div style="display:flex;flex-wrap:wrap;gap:8px;margin:12px 0" data-buttons>
|
||||
<BaseButton v-for="variant in variants" :key="variant" :variant="variant" @pointerenter="trackHover" @pointerleave="trackLeave">{{ labels[variant] }}</BaseButton>
|
||||
<button class="fcb-action inline-flex min-h-11 items-center rounded-xl border px-3 py-2 text-sm" @pointerenter="trackHover" @pointerleave="trackLeave">展开</button>
|
||||
<BaseButton class="fcb-refresh-button" variant="secondary" @pointerenter="trackHover" @pointerleave="trackLeave"><template #icon><RefreshCwIcon class="mr-2 h-4 w-4" /></template>刷新</BaseButton>
|
||||
<BaseButton disabled>禁用</BaseButton><BaseButton loading>加载</BaseButton>
|
||||
<button class="fcb-action fcb-icon-action flex h-11 w-11 items-center justify-center" aria-label="关闭"><XIcon class="h-6 w-6" /></button>
|
||||
</div>
|
||||
<p style="font-size:12px" data-hover>{{ hoverResult }}</p>
|
||||
<h3 style="margin:16px 0 8px;font-size:16px;font-weight:bold">下载 / 上传趋势</h3>
|
||||
<div class="analytics-date-range grid w-full min-w-0 grid-cols-2 gap-2">
|
||||
<NativeDateSelect v-model="start" aria-label="开始日期" />
|
||||
<NativeDateSelect v-model="end" aria-label="结束日期" />
|
||||
</div>
|
||||
<div class="grid w-full grid-cols-3 gap-2" style="margin:8px 0">
|
||||
<BaseButton variant="outline">放大</BaseButton><BaseButton variant="outline">缩小</BaseButton><BaseButton variant="outline">重置</BaseButton>
|
||||
</div>
|
||||
<h3 style="margin:16px 0 8px;font-size:16px;font-weight:bold">过期方式(多选)</h3>
|
||||
<div style="display:flex;flex-wrap:wrap;gap:8px" data-choices>
|
||||
<label v-for="(label, index) in ['天','小时','分钟','永久','次数']" :key="label" class="fcb-choice relative inline-flex items-center group cursor-pointer">
|
||||
<input type="checkbox" v-model="chosen" :value="label" class="peer sr-only" />
|
||||
<div class="fcb-action fcb-choice-face inline-flex min-h-11 items-center justify-center px-4 py-2 rounded-full border" :class="chosen.includes(label)?'fcb-button-primary':'fcb-button-secondary'" @pointerenter="trackHover" @pointerleave="trackLeave">{{ label }}</div>
|
||||
</label>
|
||||
</div>
|
||||
<h3 style="margin:16px 0 8px;font-size:16px;font-weight:bold">列表高亮</h3>
|
||||
<table style="width:100%"><tbody><tr v-for="n in 2" :key="n" class="fcb-list-row" @pointerenter="trackHover" @pointerleave="trackLeave"><td style="padding:12px;font-size:12px">示例文件 {{ n }}</td></tr></tbody></table>
|
||||
<h3 style="margin:16px 0 8px;font-size:16px;font-weight:bold">分页</h3>
|
||||
<DataPagination :current-page="page" :page-size="size" :total="85" @page-change="page=$event" @page-size-change="size=$event;page=1" />
|
||||
<h3 style="margin:16px 0 8px;font-size:16px;font-weight:bold">简短统计</h3>
|
||||
<div class="fcb-summary-grid grid grid-cols-3 gap-2">
|
||||
<div @pointerenter="trackHover" @pointerleave="trackLeave" v-for="(label,i) in ['回收站记录','可恢复','仅审计记录']" :key="label" class="theme-2026-card theme-2026-card-hover fcb-secondary-card min-w-0 rounded-[20px] border p-2.5 shadow-sm"><p class="text-xs">{{ label }}</p><strong class="mt-1 block text-xl">{{ i===2?0:1 }}</strong></div>
|
||||
</div>
|
||||
<h3 style="margin:16px 0 8px;font-size:16px;font-weight:bold">常规统计</h3>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<StatCard title="存储空间" value="481.9 MB" :icon="HardDriveIcon" icon-color="purple"><template #description>今日新增 0 Bytes</template></StatCard>
|
||||
<StatCard title="累计取件" value="123456789" :icon="HardDriveIcon" icon-color="green"><template #description>运行 10 天</template></StatCard>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, provide, onMounted, nextTick } from 'vue'
|
||||
import BaseButton from '/src/components/common/BaseButton.vue'
|
||||
import DataPagination from '/src/components/common/DataPagination.vue'
|
||||
import NativeDateSelect from '/src/components/common/NativeDateSelect.vue'
|
||||
import StatCard from '/src/components/common/StatCard.vue'
|
||||
import { HardDriveIcon, RefreshCwIcon, XIcon } from 'lucide-vue-next'
|
||||
const dark = new URLSearchParams(location.search).has('dark')
|
||||
provide('isDarkMode', ref(dark))
|
||||
document.documentElement.classList.toggle('dark', dark)
|
||||
const width=innerWidth
|
||||
const variants=['primary','secondary','success','danger','outline']
|
||||
const labels={primary:'详情',secondary:'编辑',success:'恢复',danger:'删除',outline:'更多'}
|
||||
const start=ref('2026-05-19'),end=ref('2026-09-16'),page=ref(1),size=ref(20)
|
||||
const chosen=ref(['天'])
|
||||
const result=ref('检测中…'),hoverResult=ref('将鼠标移到按钮上验证上浮')
|
||||
const wait=ms=>new Promise(r=>setTimeout(r,ms))
|
||||
const check=(condition,message)=>{if(!condition)throw new Error(message)}
|
||||
function trackHover(event) {
|
||||
const el=event.currentTarget
|
||||
setTimeout(()=>{hoverResult.value=`${el.textContent.trim()}:移入 ${getComputedStyle(el).translate} / ${getComputedStyle(el).transform};过渡 ${getComputedStyle(el).transitionDuration};阴影 ${getComputedStyle(el).boxShadow}`},380)
|
||||
}
|
||||
function trackLeave(event){const el=event.currentTarget;setTimeout(()=>{hoverResult.value=`${el.textContent.trim()}:移出 ${getComputedStyle(el).translate} / ${getComputedStyle(el).transform}`},380)}
|
||||
onMounted(async()=>{
|
||||
try {
|
||||
await wait(400)
|
||||
const buttonHeights=[...document.querySelectorAll('[data-buttons] .fcb-action')].map(e=>e.getBoundingClientRect().height)
|
||||
if(width<640) check(buttonHeights.every(h=>h>=36&&h<=40.5),`按钮高度异常 ${buttonHeights}`)
|
||||
const controls=document.querySelector('.fcb-pagination-controls')
|
||||
const sizeSelect=controls.querySelector('select')
|
||||
const before=controls.querySelector('button')
|
||||
if(width<640) check(Math.abs(sizeSelect.getBoundingClientRect().top-before.getBoundingClientRect().top)<2,'分页下拉框不同行')
|
||||
check(document.documentElement.scrollWidth<=innerWidth,'存在横向溢出')
|
||||
check([...document.querySelectorAll('.fcb-action')].every(e=>getComputedStyle(e).transitionProperty.includes('translate')),'按钮缺少位移过渡')
|
||||
const statCard=document.querySelector('.fcb-summary-grid > div')
|
||||
check(statCard.classList.contains('theme-2026-card-hover'),'统计卡片未接入悬浮')
|
||||
if(dark) check(getComputedStyle(statCard,'::before').display==='none','深色卡片残留白色渐变高光')
|
||||
check([...document.querySelectorAll('.native-date-part')].every(e=>getComputedStyle(e).boxShadow==='none'&&getComputedStyle(e).backgroundColor==='rgba(0, 0, 0, 0)'),'年月日仍有独立阴影或背景')
|
||||
start.value='2024-01-31';await nextTick()
|
||||
const select=document.querySelector('[aria-label="开始日期月"]');select.value='2';select.dispatchEvent(new Event('change',{bubbles:true}));await nextTick()
|
||||
check(start.value==='2024-02-29','月份切换没有正确保留闰日')
|
||||
const year=document.querySelector('[aria-label="开始日期年"]');year.value='2025';year.dispatchEvent(new Event('change',{bubbles:true}));await nextTick()
|
||||
check(start.value==='2025-02-28','平年日期没有正确裁到月底')
|
||||
const checks=[...document.querySelectorAll('[data-choices] input')]
|
||||
checks[1].click();await nextTick();check(chosen.value.includes('小时')&&chosen.value.includes('天'),'多选行为被改变')
|
||||
checks[1].click();await nextTick();check(chosen.value.length===1,'取消选中失败')
|
||||
sizeSelect.value='50';sizeSelect.dispatchEvent(new Event('change',{bubbles:true}));await nextTick()
|
||||
check(size.value===50&&page.value===1,'每页数量事件失败')
|
||||
controls.querySelectorAll('button')[controls.querySelectorAll('button').length-1].click();await nextTick()
|
||||
check(page.value===2,'下一页事件失败')
|
||||
start.value='2026-05-19';size.value=20;page.value=1;await nextTick()
|
||||
result.value=`通过:按钮 ${buttonHeights[0].toFixed(1)}px;分页同排;日期无分块;日期/分页交互正常;无横向溢出。 系统深色:${matchMedia('(prefers-color-scheme: dark)').matches};颜色方案:${getComputedStyle(document.documentElement).colorScheme};外部样式:${[...document.querySelectorAll('style')].filter(e=>(e.className+' '+e.id).includes('darkreader')).length}。`
|
||||
} catch(e) {result.value=`失败:${e.message}`}
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,6 @@
|
||||
<!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>回收站交互验证 · 独立测试数据</title><div style="position:sticky;top:0;z-index:90;padding:10px 16px;background:#e8e0f2;color:#504165;font:13px sans-serif">独立测试数据 · 用于验证筛选、批量操作和清理时间,不连接线上文件</div><div id="app"></div><script type="module">
|
||||
import {createApp,ref} from 'vue';import {createRouter,createMemoryHistory} from 'vue-router';import {createI18n} from 'vue-i18n';import TrashView from '/src/views/manage/TrashView.vue';import zh from '/src/i18n/locales/zh-CN.ts';import '/src/assets/style/main.css';
|
||||
const dark=new URLSearchParams(location.search).has('dark');document.documentElement.classList.toggle('dark',dark);
|
||||
const app=createApp(TrashView);app.provide('isDarkMode',ref(dark));app.use(createI18n({legacy:false,locale:'zh-CN',messages:{'zh-CN':zh}}));app.use(createRouter({history:createMemoryHistory(),routes:[{path:'/',component:{template:'<div/>'}}]}));app.mount('#app');
|
||||
if(new URLSearchParams(location.search).has('autotest')) import('./trashWorkflow.browser.mjs').then(m=>m.runTrashWorkflowChecks());
|
||||
</script></html>
|
||||
@@ -28,7 +28,7 @@ test('purged and permanent records do not show a misleading countdown', async ()
|
||||
test('urgent status remains readable with explicit text in dark mode', async () => {
|
||||
const html = await render({ trashExpiresAt: '2026-09-16T15:00:00+08:00', trashReason: 'expired' }, true)
|
||||
assert.ok(html.includes('trash-item-info--dark') && html.includes('trash-tone-warning'))
|
||||
assert.ok(html.includes('3 小时后') && html.includes('即将清理') && html.includes('已过期或次数用尽'))
|
||||
assert.ok(html.includes('3 小时后') && html.includes('即将清理') && html.includes('历史自动回收'))
|
||||
})
|
||||
test('missing metadata has safe fallbacks and filenames are escaped', async () => {
|
||||
const html = await render({ name: '<script>alert(1)</script>', code: '', size: -1, trashedAt: null, trashExpiresAt: null })
|
||||
|
||||
@@ -46,7 +46,7 @@ test('missing and invalid deadlines never imply permanent retention or NaN dates
|
||||
assert.match(formatTrashTime('2026-09-14T16:51:32'), /2026-09-14 16:51:32/)
|
||||
})
|
||||
test('expiry reason does not claim that count exhaustion was a manual deletion', () => {
|
||||
assert.equal(present({ trashReason: 'expired' }).reason, '已过期或次数用尽')
|
||||
assert.equal(present({ trashReason: 'expired' }).reason, '历史自动回收')
|
||||
assert.equal(present({ trashReason: 'unexpected' }).reason, '其他原因')
|
||||
assert.equal(present({ trashReason: null }).reason, '未记录')
|
||||
})
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { selectableTrashIds, buildTrashRetention, summarizeTrashBatch } from '../src/utils/trashSelection.ts'
|
||||
const now = new Date('2026-09-16T12:00:00Z').getTime()
|
||||
test('select-all excludes cleared audit records and duplicate ids',()=>{
|
||||
assert.deepEqual(selectableTrashIds([{id:1},{id:2,isTrashPurged:true},{id:1},{id:3}]),[1,3])
|
||||
})
|
||||
test('custom deadline keeps timezone and enforces the future 365-day window',()=>{
|
||||
assert.deepEqual(buildTrashRetention(true,'',now),{retentionDays:0})
|
||||
assert.deepEqual(buildTrashRetention(false,'2026-09-17T20:00:00+08:00',now),{expiresAt:'2026-09-17T12:00:00.000Z'})
|
||||
for(const date of ['', 'invalid','2026-09-15T12:00:00Z','2028-09-16T12:00:00Z']) assert.throws(()=>buildTrashRetention(false,date,now))
|
||||
})
|
||||
test('mixed operation results never report full success',()=>{
|
||||
assert.equal(summarizeTrashBatch({succeeded:[{id:1}],failed:[{id:2,reason:'error'}]}),'成功 1 项,失败 1 项')
|
||||
assert.equal(summarizeTrashBatch({succeeded:[],failed:[{id:2,reason:'error'}]}),'成功 0 项,失败 1 项')
|
||||
assert.equal(summarizeTrashBatch({succeeded:[{id:1}],failed:[]}),'已完成 1 项')
|
||||
})
|
||||
@@ -0,0 +1,61 @@
|
||||
// Only run on the isolated localhost in-memory backend fixture, never production.
|
||||
export async function runTrashWorkflowChecks() {
|
||||
if (location.hostname !== '127.0.0.1' || location.port !== '5180') throw new Error('Use the isolated fixture on port 5180')
|
||||
const output=document.createElement('pre')
|
||||
output.style.cssText='position:sticky;top:0;z-index:100;white-space:pre-wrap;background:#e6f0eb;color:#284b3b;padding:10px;font-size:12px'
|
||||
document.body.prepend(output)
|
||||
const checks=[]
|
||||
const wait=async(fn)=>{const end=Date.now()+6000;while(!fn()){if(Date.now()>end)throw new Error('等待页面状态超时');await new Promise(r=>setTimeout(r,30))}}
|
||||
const button=(text,root=document)=>[...root.querySelectorAll('button')].find(e=>e.textContent.trim()===text)
|
||||
const done=text=>{checks.push(text);output.textContent=checks.join('\n')}
|
||||
const assert=(v,m)=>{if(!v)throw new Error(m)}
|
||||
const submit=()=>document.querySelector('form').dispatchEvent(new Event('submit',{bubbles:true,cancelable:true}))
|
||||
try {
|
||||
await wait(()=>document.querySelectorAll('article').length===6)
|
||||
const keyword=document.querySelector('form input')
|
||||
keyword.value='示例记录-1.txt';keyword.dispatchEvent(new Event('input',{bubbles:true}));submit()
|
||||
await wait(()=>document.querySelectorAll('article').length===1)
|
||||
assert(document.querySelector('article').textContent.includes('示例记录-1'),'关键词命中错误')
|
||||
done('通过:全量文件名筛选')
|
||||
button('重置').click();await wait(()=>document.querySelectorAll('article').length===6)
|
||||
const status=document.querySelector('form select');status.value='purged';status.dispatchEvent(new Event('change',{bubbles:true}));submit()
|
||||
await wait(()=>document.querySelectorAll('article').length===1)
|
||||
assert(document.querySelector('article input').disabled,'审计记录可被选中')
|
||||
assert(!button('恢复',document.querySelector('article')),'审计记录出现恢复操作')
|
||||
done('通过:状态筛选与已删除记录禁用')
|
||||
button('重置').click();await wait(()=>document.querySelectorAll('article').length===6)
|
||||
document.querySelector('input[type=checkbox]').click()
|
||||
await wait(()=>button('设置清理时间'))
|
||||
assert([...document.querySelectorAll('article input')].filter(e=>e.checked).length===5,'全选未排除已清理记录')
|
||||
button('设置清理时间').click();await wait(()=>document.querySelector('[role=dialog]'))
|
||||
let modal=document.querySelector('[role=dialog]')
|
||||
modal.querySelector('input[type=checkbox]').click();button('保存时间',modal).click()
|
||||
await wait(()=>!document.querySelector('[role=dialog]'))
|
||||
await wait(()=>document.querySelectorAll('article').length===6)
|
||||
assert([...document.querySelectorAll('article')].filter(e=>e.textContent.includes('不自动清理')).length===5,'批量永久保留未生效')
|
||||
done('通过:批量永久保留与全选排除审计记录')
|
||||
const record=[...document.querySelectorAll('article')].find(e=>button('清理时间',e))
|
||||
button('清理时间',record).click();await wait(()=>document.querySelector('[role=dialog]'))
|
||||
modal=document.querySelector('[role=dialog]');modal.querySelector('input[type=checkbox]').click()
|
||||
await wait(()=>modal.querySelector('select'))
|
||||
const year=modal.querySelector('select');const original=year.value;year.value='2020';year.dispatchEvent(new Event('change',{bubbles:true}));button('保存时间',modal).click()
|
||||
await wait(()=>modal.querySelector('[role=alert]'))
|
||||
assert(modal.textContent.includes('未来 365 天'),'日期校验提示缺失')
|
||||
year.value=original;year.dispatchEvent(new Event('change',{bubbles:true}));button('保存时间',modal).click()
|
||||
await wait(()=>!document.querySelector('[role=dialog]'))
|
||||
done('通过:单条时间编辑与无效日期拦截')
|
||||
await wait(()=>document.querySelectorAll('article').length===6)
|
||||
const selectable=[...document.querySelectorAll('article input')].filter(e=>!e.disabled)
|
||||
selectable[0].click();await new Promise(r=>setTimeout(r,0));selectable[1].click();await new Promise(r=>setTimeout(r,0));await wait(()=>button('批量恢复'));assert([...document.querySelectorAll('article input')].filter(e=>e.checked).length===2,'未选中两条记录')
|
||||
button('批量恢复').click();await wait(()=>document.querySelectorAll('article').length===4)
|
||||
assert(document.querySelectorAll('code').length===2,'未展示恢复后的新取件码')
|
||||
done('通过:批量恢复、列表刷新和新取件码展示')
|
||||
document.querySelector('input[type=checkbox]').click();await wait(()=>button('批量清理'))
|
||||
button('批量清理').click();await wait(()=>document.querySelector('[role=dialog]'))
|
||||
modal=document.querySelector('[role=dialog]');assert(modal.textContent.includes('不可恢复')&&modal.textContent.includes('3'),'缺少删除数量或后果提示')
|
||||
button('取消',modal).click();await wait(()=>!document.querySelector('[role=dialog]'))
|
||||
assert(document.querySelectorAll('article').length===4,'取消删除改变了数据')
|
||||
done('通过:彻底删除确认数量、取消不修改数据')
|
||||
done('全部 6 组交互检查通过(独立内存数据库)')
|
||||
} catch(error) {output.textContent=checks.join('\n')+'\n失败:'+error.message;throw error}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>2026 UI 回归</title><div id="app"></div><script type="module">
|
||||
import {createApp} from 'vue';import {createI18n} from 'vue-i18n';import App from './fixtures/UiSystem.vue';import zh from '/src/i18n/locales/zh-CN.ts';import '/src/assets/style/main.css';createApp(App).use(createI18n({legacy:false,locale:'zh-CN',messages:{'zh-CN':zh}})).mount('#app');
|
||||
</script></html>
|
||||
@@ -0,0 +1,45 @@
|
||||
import { test, before, after } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { createServer } from 'vite'
|
||||
import { createSSRApp, h } from 'vue'
|
||||
import { renderToString } from 'vue/server-renderer'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
let server, Button, Pagination, DateSelect, zh
|
||||
before(async()=>{
|
||||
server=await createServer({server:{middlewareMode:true,watch:null},appType:'custom'})
|
||||
Button=(await server.ssrLoadModule('/src/components/common/BaseButton.vue')).default
|
||||
Pagination=(await server.ssrLoadModule('/src/components/common/DataPagination.vue')).default
|
||||
DateSelect=(await server.ssrLoadModule('/src/components/common/NativeDateSelect.vue')).default
|
||||
zh=(await server.ssrLoadModule('/src/i18n/locales/zh-CN.ts')).default
|
||||
})
|
||||
after(async()=>await server?.close())
|
||||
async function render(component,props,slots={}) {
|
||||
const app=createSSRApp({render:()=>h(component,props,slots)})
|
||||
app.use(createI18n({legacy:false,locale:'zh-CN',messages:{'zh-CN':zh}}))
|
||||
return renderToString(app)
|
||||
}
|
||||
test('button variants retain their semantic role and disabled/loading behavior',async()=>{
|
||||
for(const variant of ['primary','secondary','danger','success','outline']) {
|
||||
const html=await render(Button,{variant},{default:()=> '刷新'})
|
||||
assert.ok(html.includes(`fcb-button-${variant}`) && html.includes('fcb-action') && html.includes('刷新'))
|
||||
}
|
||||
const loading=await render(Button,{loading:true},{icon:()=>h('span','CUSTOM ICON'),default:()=> '刷新'})
|
||||
assert.match(loading, /disabled/);assert.ok(!loading.includes('CUSTOM ICON'))
|
||||
assert.match(await render(Button,{disabled:true}),/disabled/)
|
||||
})
|
||||
test('pagination retains accessible labels and correct edge controls',async()=>{
|
||||
const first=await render(Pagination,{currentPage:1,pageSize:20,total:85})
|
||||
assert.ok(first.includes('每页显示数量') && first.includes('20/页') && first.includes('1 / 5'))
|
||||
assert.match(first,/<button[^>]*disabled[^>]*>[\s\S]*?上一页/)
|
||||
const last=await render(Pagination,{currentPage:5,pageSize:20,total:85})
|
||||
assert.ok(last.includes('第 81 到 85 条') && last.includes('5 / 5'))
|
||||
assert.ok(!last.includes('col-span-3'))
|
||||
})
|
||||
test('date field keeps real selects, readable labels, leap days and optional time',async()=>{
|
||||
const leap=await render(DateSelect,{modelValue:'2024-02-29',ariaLabel:'开始日期'})
|
||||
assert.ok(leap.includes('开始日期年')&&leap.includes('开始日期月')&&leap.includes('开始日期日'))
|
||||
assert.match(leap,/<option[^>]*value="29"/)
|
||||
const ordinary=await render(DateSelect,{modelValue:'2025-02-28T14:30',ariaLabel:'过期时间',includeTime:true})
|
||||
assert.ok(ordinary.includes('过期时间时')&&ordinary.includes('过期时间分'))
|
||||
assert.ok(ordinary.includes('native-date-label'))
|
||||
})
|
||||
@@ -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