fix(web): make the favicon follow the color scheme

favicon.svg embeds @media (prefers-color-scheme: dark) so the DeepSeek
mark turns white under a dark browser scheme; index.html and the install
manifest gain a 32x32 PNG fallback (brand blue) for Safari, which cannot
render SVG favicons. pwa-manifest.e2e.ts pins the PNG link, both manifest
icons, and the dark media query.
This commit is contained in:
_Kerman
2026-08-10 11:50:33 +08:00
parent abaf8f5061
commit e8f884ba35
11 changed files with 98 additions and 15 deletions

View File

@@ -8,6 +8,7 @@ const DIST_ROOT = fileURLToPath(new URL('../dist', import.meta.url))
it('ships install metadata with the built web application', async () => {
const index = await readFile(join(DIST_ROOT, 'index.html'), 'utf8')
expect(index).toContain('<link rel="manifest" href="/manifest.webmanifest" />')
expect(index).toContain('<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />')
const manifest: unknown = JSON.parse(await readFile(join(DIST_ROOT, 'manifest.webmanifest'), 'utf8'))
expect(manifest).toEqual({
@@ -17,11 +18,25 @@ it('ships install metadata with the built web application', async () => {
start_url: '/',
scope: '/',
display: 'fullscreen',
icons: [{
src: '/favicon.svg',
sizes: 'any',
type: 'image/svg+xml',
purpose: 'any',
}],
icons: [
{
src: '/favicon-32x32.png',
sizes: '32x32',
type: 'image/png',
purpose: 'any',
},
{
src: '/favicon.svg',
sizes: 'any',
type: 'image/svg+xml',
purpose: 'any',
},
],
})
})
it('ships a favicon that switches to a light mark under dark color scheme', async () => {
const favicon = await readFile(join(DIST_ROOT, 'favicon.svg'), 'utf8')
expect(favicon).toContain('@media (prefers-color-scheme: dark)')
expect(favicon).toMatch(/path\s*{[^}]*fill:\s*#fff/i)
})