Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<meta name="apple-mobile-web-app-title" content="DataBack" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<link rel="icon" type="image/x-icon" sizes="16x16 32x32 48x48" href="/favicon.ico?v=20261024" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="icon" type="image/svg+xml" sizes="any" href="/favicon.svg?v=20261024" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="manifest" href="/manifest.webmanifest" />
<link rel="icon" type="image/x-icon" sizes="16x16 32x32 48x48" href="/favicon.ico?v=20261026" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=20261026" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=20261026" />
<link rel="icon" type="image/svg+xml" sizes="any" href="/favicon.svg?v=20261026" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=20261026" />
<link rel="manifest" href="/manifest.webmanifest?v=20261026" />
<title>DataBack</title>
</head>
<body>
Expand Down
Binary file modified web/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/public/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/public/favicon.ico
Binary file not shown.
12 changes: 10 additions & 2 deletions web/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/public/icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/public/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/public/icon-maskable-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions web/public/manifest.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
"theme_color": "#ffffff",
"icons": [
{
"src": "/icon-192.png",
"src": "/icon-192.png?v=20261026",
"sizes": "192x192",
"type": "image/png",
"purpose": "any"
},
{
"src": "/icon-512.png",
"src": "/icon-512.png?v=20261026",
"sizes": "512x512",
"type": "image/png",
"purpose": "any"
},
{
"src": "/icon-maskable-512.png",
"src": "/icon-maskable-512.png?v=20261026",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
Expand Down
3 changes: 3 additions & 0 deletions web/src/components/BrandIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function BrandIcon() {
return <img className="brand-icon" src="/favicon.svg?v=20261026" width={36} height={36} alt="" aria-hidden="true" draggable={false} />;
}
5 changes: 3 additions & 2 deletions web/src/components/SessionGate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import type { FormEvent } from 'react';
import { Archive, LogIn, RefreshCw } from 'lucide-react';
import { LogIn, RefreshCw } from 'lucide-react';
import { BrandIcon } from './BrandIcon';
import type { SessionSnapshot } from '../session';
import { Field, FormError } from './ui';
import { MAX_PASSWORD_CHARS } from '../inputLimits';
Expand All @@ -25,7 +26,7 @@ export function SessionGate({snapshot, onLogin, onRetry, onLogout}: {
if (await onLogin(password)) setPassword('');
}
return <main className="session-page"><section className="session-card surface" aria-labelledby="session-title">
<div className="session-brand"><Archive size={35} strokeWidth={1.7} /><strong>DataBack</strong></div>
<div className="session-brand"><BrandIcon /><strong>DataBack</strong></div>
<h1 id="session-title">{checking ? '正在确认会话…' : snapshot.status === 'logging-out' ? '正在退出登录…' : snapshot.status === 'error' ? '连接暂时不可用' : '登录'}</h1>
<FormError message={snapshot.error} />
{snapshot.logoutUnconfirmed ? <button className="button secondary" type="button" disabled={busy} onClick={() => void onLogout()}><RefreshCw size={18} />重试退出</button> : snapshot.status === 'error' ? <button className="button secondary" type="button" onClick={() => void onRetry()}><RefreshCw size={18} />重试连接</button> : !checking && snapshot.status !== 'logging-out' ? <form onSubmit={submit} className="session-form">
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/Shell.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Archive, Database, Folder, History, Plus } from 'lucide-react';
import { Database, Folder, History, Plus } from 'lucide-react';
import type { ReactNode } from 'react';
import type { Page } from '../types';
import { BrandIcon } from './BrandIcon';

const navigation = [
{ id: 'overview', label: '资料目录', Icon: Folder },
{ id: 'history', label: '历史记录', Icon: History },
{ id: 'data', label: '数据管理', Icon: Database },
] as const;
export function Shell({ page, onNavigate, children, privacyOpen=false, onTogglePrivacy }: { page: Page; onNavigate: (page: Page) => void; children?: ReactNode; authRequired?: boolean; onLogout?: () => void; privacyOpen?:boolean; onTogglePrivacy?:()=>void }) {
return <div className="app-shell"><aside className="sidebar"><button type="button" className="brand brand-button" aria-label="DataBack" aria-pressed={privacyOpen} disabled={!onTogglePrivacy} onClick={onTogglePrivacy}><Archive size={35} strokeWidth={1.7} /><strong>DataBack</strong></button>
return <div className="app-shell"><aside className="sidebar"><button type="button" className="brand brand-button" aria-label="DataBack" aria-pressed={privacyOpen} disabled={!onTogglePrivacy} onClick={onTogglePrivacy}><BrandIcon /><strong>DataBack</strong></button>
<nav aria-label="主导航">{navigation.map(({ id, label, Icon }) => <button key={id} type="button" className={`nav-item ${id === page ? 'active' : ''}`} aria-current={id === page ? 'page' : undefined} onClick={() => onNavigate(id)}><Icon size={21} strokeWidth={1.8} /><span>{label}</span></button>)}</nav>
</aside><main className="main-content">{children}</main></div>;
}
Expand Down
5 changes: 3 additions & 2 deletions web/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ small { font-size: 12px; }
.sidebar { width: 208px; background: #fff; border-right: 1px solid var(--border); padding: 26px 12px; position: fixed; inset: 0 auto 0 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 11px; margin-bottom: 30px; }
.brand strong { display: block; font-size: 22px; font-weight: 650; letter-spacing: -.4px; white-space: nowrap; }
.brand > svg { color: var(--accent); width: 28px; height: 28px; flex-shrink: 0; }
.brand-icon { display: block; width: 36px; height: 36px; flex-shrink: 0; object-fit: contain; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { width: 100%; background: transparent; border: 0; border-radius: 8px; padding: 13px 15px; display: flex; align-items: center; gap: 14px; font-size: 14px; font-weight: 500; text-align: left; min-height: 48px; }
.nav-item > svg { width: 20px; height: 20px; color: #7183a1; }
Expand Down Expand Up @@ -213,6 +213,7 @@ tbody tr:hover { background: #fcfdff; }
.session-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.session-card { width: min(100%, 400px); padding: 30px; }
.session-brand { display: flex; align-items: center; gap: 12px; color: var(--accent); margin-bottom: 26px; }
.session-brand .brand-icon { width: 44px; height: 44px; }
.session-brand strong { color: #172b4d; font-size: 23px; }
.session-card h1 { font-size: 22px; margin-bottom: 22px; }
.session-card .error-message { margin-bottom: 18px; }
Expand All @@ -231,7 +232,7 @@ tbody tr:hover { background: #fcfdff; }
.sidebar { position: static; width: 100%; border-right: 0; border-bottom: 1px solid var(--border); padding: 16px 12px 10px; }
.brand { padding: 0 4px; margin-bottom: 14px; gap: 9px; }
.brand strong { font-size: 20px; }
.brand > svg { width: 25px; height: 25px; }
.brand > .brand-icon { width: 30px; height: 30px; }
.sidebar nav { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 2px; }
.nav-item { flex: 0 0 auto; width: auto; justify-content: center; min-height: 40px; padding: 9px 10px; font-size: 12px; gap: 5px; }
.nav-item > svg { width: 16px; height: 16px; }
Expand Down
11 changes: 11 additions & 0 deletions web/tests/frontend-targets.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ test('app initial render contains a session check and never mounts private ledge
assert.doesNotMatch(html,/主导航|资料目录|正在读取本机台账/);
});

test('navigation and session gate share the same icon artwork as the browser tab', () => {
const head=readFileSync(new URL('../index.html',import.meta.url),'utf8');
const href=head.match(/href="([^"]*favicon\.svg[^\"]*)"/)[1];
const shell=render(Shell,{page:'overview',onNavigate:noop,onTogglePrivacy:noop});
globalThis.window={location:{hash:''}};
const gate=render(App);
delete globalThis.window;
for(const html of [shell,gate]) assert.ok(html.includes(`src="${href}"`),'The visible brand must use the same revision as the favicon');
assert.match(shell,/<button[^>]+aria-label="DataBack"/);
});


test('protected SQLite shell remains minimal independently of its storage engine', () => {
const html=render(Shell,{page:'overview',onNavigate:noop,storage:'sqlite',authRequired:true,onLogout:noop});
Expand Down
13 changes: 12 additions & 1 deletion web/tests/test_app_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import xml.etree.ElementTree as ET
from html.parser import HTMLParser
from pathlib import Path
from urllib.parse import parse_qs, urlsplit

from backend.config import ServerConfig
from backend.server import make_server
Expand Down Expand Up @@ -55,11 +56,21 @@ def test_desktop_manifest_uses_large_regular_and_maskable_icons(self):
for icon in manifest['icons']))
self.assertTrue(any(icon.get('purpose') == 'maskable' for icon in manifest['icons']))
for icon in manifest['icons']:
data = (PUBLIC / icon['src'].lstrip('/')).read_bytes()
data = (PUBLIC / urlsplit(icon['src']).path.lstrip('/')).read_bytes()
self.assertEqual(data[:8], b'\x89PNG\r\n\x1a\n')
width, height = struct.unpack('>II', data[16:24])
self.assertEqual(f'{width}x{height}', icon['sizes'])

def test_all_icon_entrypoints_share_a_cache_revision(self):
head = HeadLinks()
head.feed((WEB / 'index.html').read_text(encoding='utf-8'))
links = [item['href'] for item in head.links if item.get('rel') in ('icon', 'apple-touch-icon', 'manifest')]
manifest = json.loads((PUBLIC / 'manifest.webmanifest').read_text(encoding='utf-8'))
links.extend(icon['src'] for icon in manifest['icons'])
revisions = [parse_qs(urlsplit(link).query).get('v', [''])[0] for link in links]
self.assertTrue(all(revisions), 'Every icon URL needs a revision so updated installs can fetch the new artwork')
self.assertEqual(len(set(revisions)), 1)

def test_raster_icons_are_opaque_and_svg_covers_the_entire_background(self):
pngs = list(PUBLIC.glob('*.png'))
self.assertGreaterEqual(len(pngs), 5)
Expand Down