🐛 fix: 修复仪表盘刷新按钮间距

* 恢复桌面刷新按钮的左右留白和图标文字间距
* 保持手机端图标与加载动画居中,避免挤压和换行
* 验证深浅主题、三种屏宽及刷新请求与加载状态
This commit is contained in:
orion committed 2026-09-19 00:53:48 +08:00
1 parent 4fefcd0f0a
commit fe6d812857
3 files changed
+48 -1

No files matched your search

+16 -1
View File
@@ -15,7 +15,7 @@
:loading="isDashboardRefreshing" :loading="isDashboardRefreshing"
:title="t('admin.dashboard.refresh')" :title="t('admin.dashboard.refresh')"
:aria-label="t('admin.dashboard.refresh')" :aria-label="t('admin.dashboard.refresh')"
class="fcb-icon-action shrink-0 max-sm:h-11 max-sm:w-11 max-sm:!px-0" class="fcb-dashboard-refresh shrink-0 whitespace-nowrap"
@click="refreshDashboardPage" @click="refreshDashboardPage"
> >
<template #icon> <template #icon>
@@ -689,3 +689,18 @@ onMounted(() => {
void refreshDashboardPage() void refreshDashboardPage()
}) })
</script> </script>
<style scoped>
@media (max-width: 639px) {
.fcb-dashboard-refresh {
width: var(--fcb-control-size);
height: var(--fcb-control-size) !important;
padding: 0 !important;
}
.fcb-dashboard-refresh :deep(svg),
.fcb-dashboard-refresh :deep(.animate-spin) {
margin-inline: 0 !important;
}
}
</style>
+8
View File
@@ -121,3 +121,11 @@ Playwright Page。Vite 固定运行于 `127.0.0.1:5180`;分别传入 `http`
仅在浏览器内替换静态资源进行部署前验证,不修改站点。 仅在浏览器内替换静态资源进行部署前验证,不修改站点。
- 前端单元/集成 72 项通过;新增列宽计算工具覆盖率 100%。Node 原生覆盖率 - 前端单元/集成 72 项通过;新增列宽计算工具覆盖率 100%。Node 原生覆盖率
不涵盖 Vite SSR 动态载入的 Vue 和指令模块,真实 DOM 行为由浏览器验收覆盖。 不涵盖 Vite SSR 动态载入的 Vue 和指令模块,真实 DOM 行为由浏览器验收覆盖。
### 仪表盘刷新按钮
- `tests/browser/dashboard-refresh.cjs` 验证深浅主题和 1440/640/390px 屏宽下的左右留白、
图标间距、移动端图标及加载动画居中,同时确认禁用加载状态和两类数据刷新请求。
- 使用 `FCB_TEST_PASSWORD`、可选 `FCB_TEST_URL` 和 `FCB_FRONTEND_DIST`,运行方式同表格验收脚本。
- 72 项前端单元/集成与覆盖率检查、类型检查、架构检查和生产构建通过;
本轮仅修改仪表盘按钮样式,未变更后端。Vue 样式行为通过真实浏览器测量验证。
+24
View File
@@ -0,0 +1,24 @@
const {chromium}=require('playwright');const {expect}=require('playwright/test');const assert=require('node:assert/strict');const fs=require('node:fs');const path=require('node:path');
const site=process.env.FCB_TEST_URL||'https://filetest.orionc.me';
(async()=>{const browser=await chromium.launch({headless:false});try{
const context=await browser.newContext({viewport:{width:1440,height:1000},colorScheme:'dark'});const page=await context.newPage();const errors=[];page.on('pageerror',e=>errors.push(e.message));
const login=await page.request.post(site+'/admin/login',{data:{password:process.env.FCB_TEST_PASSWORD}});const token=(await login.json()).detail.token;assert.ok(token);
await context.addInitScript(token=>localStorage.setItem('token',token),token);
if(process.env.FCB_FRONTEND_DIST)await page.route(site+'/**',async route=>{const u=new URL(route.request().url());const rel=u.pathname==='/'?'index.html':u.pathname.startsWith('/theme-assets/')?u.pathname.slice(14):null;const file=rel&&path.join(process.env.FCB_FRONTEND_DIST,rel);if(file&&fs.existsSync(file)&&fs.statSync(file).isFile())await route.fulfill({path:file});else await route.continue()});
await page.goto(site+'/#/admin/dashboard');const button=page.getByRole('button',{name:'刷新数据',exact:true});await expect(button).toBeEnabled();
let hold=false;const gates=[];const counts={dashboard:0,analytics:0};
for(const endpoint of Object.keys(counts))await page.route(site+'/admin/'+endpoint+'**',async route=>{counts[endpoint]++;if(hold)await new Promise(r=>gates.push(r));await route.continue()});
const geometry=()=>button.evaluate(b=>{const icon=b.querySelector('svg,.animate-spin'),label=b.querySelector('span'),r=b.getBoundingClientRect(),i=icon.getBoundingClientRect(),l=label.getBoundingClientRect(),s=getComputedStyle(b);return {width:r.width,height:r.height,left:i.left-r.left,right:r.right-l.right,gap:l.left-i.right,centerDelta:(i.left+i.right-r.left-r.right)/2,paddingLeft:parseFloat(s.paddingLeft),paddingRight:parseFloat(s.paddingRight)}});
for(const theme of ['dark','light']){
await page.emulateMedia({colorScheme:theme});
for(const width of [1440,640,390]){
await page.setViewportSize({width,height:1000});await button.scrollIntoViewIfNeeded();const idle=await geometry();
if(width>=640){assert.ok(idle.paddingLeft>=15&&idle.paddingRight>=15,JSON.stringify(idle));assert.ok(idle.gap>=7,JSON.stringify(idle));assert.ok(idle.left>=15&&idle.right>=15,JSON.stringify(idle))}else assert.ok(Math.abs(idle.centerDelta)<1,JSON.stringify(idle));
hold=true;await button.click();await expect(button).toBeDisabled();await expect.poll(()=>gates.length).toBe(2);
const loading=await geometry();if(width>=640)assert.ok(loading.gap>=7,JSON.stringify(loading));else assert.ok(Math.abs(loading.centerDelta)<1,JSON.stringify(loading));
hold=false;gates.splice(0).forEach(r=>r());await expect(button).toBeEnabled();
await page.screenshot({path:`/tmp/fcb-refresh-${theme}-${width}.png`});
}
}
assert.deepEqual(counts,{dashboard:6,analytics:6});assert.deepEqual(errors,[]);console.log('PASS: dark/light at 1440/640/390; desktop padding/gap, mobile icon/spinner centering; both refresh requests and disabled loading state.');
}finally{await browser.close()}})().catch(e=>{console.error(e);process.exitCode=1});