diff --git a/docs-vitepress/.vitepress/config.ts b/docs-vitepress/.vitepress/config.ts index c80ea14d68..110d668ffb 100644 --- a/docs-vitepress/.vitepress/config.ts +++ b/docs-vitepress/.vitepress/config.ts @@ -218,6 +218,12 @@ export default withPwa( base: "/", head: [ ["link", { rel: "icon", href: "/favicon.ico" }], + ["link", { rel: "manifest", href: "/manifest.webmanifest" }], + [ + "script", + { id: "unregister-sw" }, + "if('serviceWorker' in navigator) window.addEventListener('load', (e) => navigator.serviceWorker.register('/service-worker.js', { scope: '/' }))", + ], [ "script", { type: "text/javascript" }, @@ -225,7 +231,7 @@ export default withPwa( c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); - })(window, document, "clarity", "script", "jtvvy52wxy");`, + })(window, document, "clarity", "script", "jtvvy52wxy");`, ], ["meta", { name: "author", content: title }], ["meta", { property: "og:type", content: "website" }], @@ -251,12 +257,20 @@ export default withPwa( pwa: { base: "/", scope: "/", + filename: "service-worker.js", includeAssets: ["favicon.ico", "logo.png"], manifest: { - name: title, + name: "Mpx", short_name: "Mpx", description, theme_color: "#ffffff", + icons: [ + { + src: "https://dpubstatic.udache.com/static/dpubimg/1ESVodfAED/logo.png", + sizes: "192x192", + type: "image/png", + }, + ], }, workbox: { globPatterns: ["**/*.{css,js,html,svg,png,ico,txt,woff2}"], @@ -321,7 +335,7 @@ export default withPwa( notFound: { title: "页面未找到", linkText: "返回首页", - quote: "😩 抱歉,迷路了~" + quote: "😩 抱歉,迷路了~", }, docFooter: { prev: "上一页", diff --git a/docs-vitepress/package.json b/docs-vitepress/package.json index 2504083cc2..9b79010243 100644 --- a/docs-vitepress/package.json +++ b/docs-vitepress/package.json @@ -1,14 +1,10 @@ { - "name": "docs-vuepress", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "description": "", + "name": "docs-vitepress", + "private": true, "type": "module", + "description": "Mpx 官方文档", + "homepage": "https://mpxjs.cn", + "license": "ISC", "dependencies": { "vue": "^3.4.37" }, diff --git a/docs-vitepress/public/manifest.webmanifest b/docs-vitepress/public/manifest.webmanifest new file mode 100644 index 0000000000..dcc89dfc8b --- /dev/null +++ b/docs-vitepress/public/manifest.webmanifest @@ -0,0 +1,15 @@ +{ + "name": "Mpx", + "short_name": "Mpx", + "icons": [ + { + "src": "https://dpubstatic.udache.com/static/dpubimg/1ESVodfAED/logo.png", + "sizes": "192x192", + "type": "image/png" + } + ], + "start_url": "/index.html", + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "standalone" +} \ No newline at end of file diff --git a/docs-vitepress/public/service-worker.js b/docs-vitepress/public/service-worker.js new file mode 100644 index 0000000000..56d7f2ef95 --- /dev/null +++ b/docs-vitepress/public/service-worker.js @@ -0,0 +1,17 @@ +// force an unregister +// see https://discord.com/channels/325477692906536972/790509637598314527/1032614068164493402 +self.addEventListener('install', function (e) { + console.log('[old service-worker] install', e) + self.skipWaiting() +}) +self.addEventListener('activate', function (e) { + console.log('[old service-worker] activate', e) + self.registration + .unregister() + .then(function () { + return self.clients.matchAll() + }) + .then(function (clients) { + clients.forEach((client) => client.navigate(client.url)) + }) +})