fix: keep release notes readable and stabilize mobile verification

This commit is contained in:
abaishu0730 committed 2026-10-27 14:36:53 +08:00
1 parent f161322532
commit 0d19ade4d8
2 files changed
+9 -2

No files matched your search

+8 -1
View File
@@ -21,6 +21,7 @@ test('authenticated update endpoint returns the checker result',async t=>{
t.after(async()=>{server.closeAllConnections();await new Promise(resolve=>server.close(resolve));fs.rmSync(dir,{recursive:true,force:true});});
const base='http://127.0.0.1:'+server.address().port;
const call=(route,body,cookie)=>fetch(base+route,{method:body===undefined?'GET':'POST',headers:{...(body?{'Content-Type':'application/json','Origin':base}:{}),...(cookie?{Cookie:cookie}:{})},body:body===undefined?undefined:JSON.stringify(body)});
assert.equal((await call('/api/update')).status,401);
const login=await call('/api/login',{username:'admin',password:'Update-test-123'});const cookie=login.headers.get('set-cookie').split(';')[0];
const response=await call('/api/update',undefined,cookie);assert.equal(response.status,200);assert.deepEqual(await response.json(),{status:'none',currentVersion:'0.1.0',latest:null});
});
@@ -40,11 +41,17 @@ test('sidebar displays the current version and a newer release after checking',a
const dialog=page.getByRole('dialog',{name:'系统更新',exact:true});await dialog.waitFor();
await dialog.getByText('发现新版本 v0.2.0',{exact:true}).waitFor();
assert.equal(await dialog.locator('img').count(),0);assert.match(await dialog.locator('pre').textContent(),/<img src=x/);
const contrast=await dialog.locator('pre').evaluate(node=>{
const canvas=document.createElement('canvas');canvas.width=canvas.height=1;const context=canvas.getContext('2d');
const luminance=value=>{context.fillStyle=value;context.fillRect(0,0,1,1);const parts=Array.from(context.getImageData(0,0,1,1).data).slice(0,3).map(v=>{v/=255;return v<=.04045?v/12.92:((v+.055)/1.055)**2.4;});return parts[0]*.2126+parts[1]*.7152+parts[2]*.0722;};
const style=getComputedStyle(node),a=luminance(style.color),b=luminance(style.backgroundColor);return (Math.max(a,b)+.05)/(Math.min(a,b)+.05);
});assert.ok(contrast>=4.5,'release notes must remain readable on their background');
assert.match(await dialog.textContent(),/2026/);assert.equal(await dialog.getByRole('link',{name:'前往发行页面'}).getAttribute('href'),state.latest.url);
await dialog.getByRole('button',{name:'关闭',exact:true}).click();await dialog.waitFor({state:'hidden'});
state={status:'unavailable',currentVersion:'0.1.0',latest:null};await page.getByRole('button',{name:'检查更新',exact:true}).click();await dialog.getByText('暂时无法检查更新',{exact:true}).waitFor();
assert.match(await page.locator('#app-version').textContent(),/v0\.1\.0/);
await page.keyboard.press('Escape');await page.setViewportSize({width:390,height:844});await page.getByRole('button',{name:'展开菜单',exact:true}).click();
await page.keyboard.press('Escape');await dialog.waitFor({state:'hidden'});await page.setViewportSize({width:390,height:844});await page.getByRole('button',{name:'展开菜单',exact:true}).click();
await page.locator('#sidebar-menu.show').waitFor();await page.waitForFunction(()=>!document.querySelector('#sidebar-menu').classList.contains('collapsing'));
await page.getByRole('button',{name:'检查更新',exact:true}).click();await dialog.waitFor();assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);
assert.deepEqual(errors,[]);
});
+1 -1
View File
@@ -61,4 +61,4 @@
.bpm-account-status{display:inline-flex;align-items:center;gap:7px;font-size:.8rem;font-weight:600;white-space:nowrap}.bpm-status-light{width:9px;height:9px;border-radius:50%;background:currentColor;flex-shrink:0}.bpm-status-green{color:#23834b}.bpm-status-yellow{color:#996600}.bpm-status-red{color:#c53030}.bpm-status-details>summary{cursor:pointer;font-size:.8rem;color:#657b81}.bpm-status-details>div{display:flex;gap:.75rem;flex-wrap:wrap;align-items:center;margin-top:.65rem}
.bpm-sync-summary{display:flex;align-items:center;gap:.75rem;flex-wrap:wrap}
.sidebar-system-update{line-height:1.6}.sidebar-version{margin-top:9px;color:#52655d;font-variant-numeric:tabular-nums}.sidebar-update-button{margin-top:8px;padding:.25rem .55rem;font-size:.68rem}.sidebar-update-status{margin-top:6px;font-size:.68rem;color:#87958e;overflow-wrap:anywhere}.sidebar-update-status.is-update{color:#a35d1b;font-weight:600}.sidebar-update-status a{color:inherit;text-decoration:underline;font-weight:500}@media(max-width:991px){.sidebar-system-update{margin-top:1rem;padding:1rem!important}.sidebar-update-status{max-width:320px}}
.sidebar-release-details{border:0;background:none;padding:4px 0;color:inherit;text-decoration:underline;font-size:inherit;display:block}.system-update-dialog{width:min(580px,calc(100vw - 32px));max-height:85vh;overflow:auto;border:1px solid var(--tblr-border-color);border-radius:12px;padding:24px;color:var(--tblr-body-color);background:#fff}.system-update-dialog::backdrop{background:#18243366}.system-update-notes{white-space:pre-wrap;overflow-wrap:anywhere;font:inherit;font-size:.85rem;max-height:40vh;overflow:auto;background:#f5f7f8;padding:12px;border-radius:8px}
.sidebar-release-details{border:0;background:none;padding:4px 0;color:inherit;text-decoration:underline;font-size:inherit;display:block}.system-update-dialog{width:min(580px,calc(100vw - 32px));max-height:85vh;overflow:auto;border:1px solid var(--tblr-border-color);border-radius:12px;padding:24px;color:var(--tblr-body-color);background:#fff}.system-update-dialog::backdrop{background:#18243366}.system-update-notes{color:inherit;white-space:pre-wrap;overflow-wrap:anywhere;font:inherit;font-size:.85rem;max-height:40vh;overflow:auto;background:#f5f7f8;padding:12px;border-radius:8px}