Files
DAO_DE_JING/.vitepress/theme/index.ts
T
dekun ecd4f25700 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>
2026-06-05 18:10:38 +08:00

31 lines
745 B
TypeScript

import DefaultTheme from 'vitepress/theme'
import { h, defineComponent } from 'vue'
import InstallApp from './InstallApp.vue'
import './custom.css'
if (typeof window !== 'undefined') {
import('virtual:pwa-register').then(({ registerSW }) => {
registerSW({ immediate: true })
})
}
/** 旧 markdown 的 <font> 标签改为 div,避免手机端布局溢出 */
const MdFont = defineComponent({
name: 'MdFont',
setup(_, { slots }) {
return () => h('div', { class: 'vp-md-font' }, slots.default?.())
},
})
export default {
extends: DefaultTheme,
enhanceApp({ app }) {
app.component('font', MdFont)
},
Layout: () => {
return h(DefaultTheme.Layout, null, {
'layout-bottom': () => h(InstallApp),
})
},
}