Fix PWA icons and mobile reading overflow
Generate PNG icons from favicon.svg at build time so manifest icons resolve, replace legacy font tags with div wrappers, and tighten mobile layout so long text wraps instead of clipping. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -162,6 +162,15 @@ app.get('/api/me', authGuard, (req, res) => {
|
||||
|
||||
app.use(authGuard)
|
||||
|
||||
function sendDistFile(res, relativePath, contentType) {
|
||||
const filePath = path.join(distPath, relativePath)
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return res.status(404).end('Not Found')
|
||||
}
|
||||
if (contentType) res.type(contentType)
|
||||
return res.sendFile(filePath)
|
||||
}
|
||||
|
||||
if (!fs.existsSync(distPath)) {
|
||||
console.error(
|
||||
'未找到构建产物 .vitepress/dist,请先运行: npm run build',
|
||||
@@ -169,10 +178,19 @@ if (!fs.existsSync(distPath)) {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
app.get('/site.webmanifest', (req, res) => {
|
||||
sendDistFile(res, 'site.webmanifest', 'application/manifest+json')
|
||||
})
|
||||
|
||||
app.use(
|
||||
express.static(distPath, {
|
||||
index: false,
|
||||
fallthrough: true,
|
||||
setHeaders(res, filePath) {
|
||||
if (filePath.endsWith('.webmanifest')) {
|
||||
res.setHeader('Content-Type', 'application/manifest+json')
|
||||
}
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user