Fix PWA shortcut icon on Windows
Allow unauthenticated access to favicon and manifest, generate favicon.ico, and add multi-size manifest icons. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -89,11 +89,33 @@ function isAuthenticated(req) {
|
||||
return Boolean(req.session?.user)
|
||||
}
|
||||
|
||||
const PUBLIC_PATHS = new Set([
|
||||
'/favicon.ico',
|
||||
'/favicon.png',
|
||||
'/favicon.svg',
|
||||
'/apple-touch-icon.png',
|
||||
'/icon-192.png',
|
||||
'/icon-512.png',
|
||||
'/site.webmanifest',
|
||||
'/vp-icons.css',
|
||||
'/hashmap.json',
|
||||
])
|
||||
|
||||
function isPublicPath(reqPath) {
|
||||
if (PUBLIC_PATHS.has(reqPath)) return true
|
||||
if (reqPath.startsWith('/assets/')) return true
|
||||
return false
|
||||
}
|
||||
|
||||
function authGuard(req, res, next) {
|
||||
if (req.path === '/login' || req.path.startsWith('/api/login')) {
|
||||
return next()
|
||||
}
|
||||
|
||||
if (isPublicPath(req.path)) {
|
||||
return next()
|
||||
}
|
||||
|
||||
if (isAuthenticated(req)) {
|
||||
return next()
|
||||
}
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="#0f3460" />
|
||||
<meta name="apple-mobile-web-app-title" content="道德经" />
|
||||
<link rel="icon" href="/favicon.ico" sizes="any" />
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
||||
<link rel="icon" href="/favicon.png" type="image/png" sizes="512x512" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
<meta name="msapplication-TileColor" content="#0f3460" />
|
||||
<meta name="msapplication-TileImage" content="/apple-touch-icon.png" />
|
||||
<title>登录 · DAO DE JING</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
Reference in New Issue
Block a user