From 9c9745027b380c34f357ba915fc4e49c96e2a472 Mon Sep 17 00:00:00 2001 From: MrlingXD <90316914+wling-art@users.noreply.github.com> Date: Sat, 14 Mar 2026 10:15:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=20pwa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + astro.config.ts | 14 ++++++-- src/components/Head.astro | 68 ++++++++++++++++++++++++++++++++++----- src/env.d.ts | 8 +++++ tsconfig.json | 2 -- 5 files changed, 80 insertions(+), 13 deletions(-) create mode 100644 src/env.d.ts diff --git a/.gitignore b/.gitignore index f6fbc06b2..4f27addcd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # build output build/ +dev-dist/ # generated types .astro/ diff --git a/astro.config.ts b/astro.config.ts index 626d6c654..eaec5c8bc 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -1079,14 +1079,22 @@ export default defineConfig({ }), AstroPWA({ registerType: "autoUpdate", - + workbox: { + skipWaiting: true, + clientsClaim: true, + navigateFallback: "/404", + ignoreURLParametersMatching: [/./], + globPatterns: ["**/*.{html,js,css,png,svg,json,ttf,pf_fragment,pf_index,pf_meta,pagefind,wasm}"] + }, + experimental: { + directoryAndTrailingSlashHandler: true + }, manifest: { name: "Cubic Wiki", short_name: "Cubic Wiki", + display: "standalone", theme_color: "#2196f3", background_color: "#424242", - display: "standalone", - start_url: "/", icons: [ { src: "/icons/book-192.png", diff --git a/src/components/Head.astro b/src/components/Head.astro index defea6b11..c07dcd6d0 100644 --- a/src/components/Head.astro +++ b/src/components/Head.astro @@ -1,19 +1,71 @@ --- -import StarlightHead from '@astrojs/starlight/components/Head.astro'; +import StarlightHead from "@astrojs/starlight/components/Head.astro"; import VtbotStarlight from "astro-vtbot/components/starlight/Base.astro"; -import PageOffset from 'astro-vtbot/components/PageOffset.astro'; -import AutoNameSelected from 'astro-vtbot/components/AutoNameSelected.astro'; +import PageOffset from "astro-vtbot/components/PageOffset.astro"; +import AutoNameSelected from "astro-vtbot/components/AutoNameSelected.astro"; import ProgressBar from "astro-vtbot/components/ProgressBar.astro"; -import PageOrder from 'astro-vtbot/components/starlight/PageOrder.astro'; -import { fade, slide } from 'astro:transitions'; +import PageOrder from "astro-vtbot/components/starlight/PageOrder.astro"; +import { pwaInfo } from "virtual:pwa-info"; --- - + + + +{pwaInfo && } + - + diff --git a/src/env.d.ts b/src/env.d.ts new file mode 100644 index 000000000..5494bddf0 --- /dev/null +++ b/src/env.d.ts @@ -0,0 +1,8 @@ +/// +/// +/// +/// +/// +/// +/// +/// diff --git a/tsconfig.json b/tsconfig.json index 6742c701b..b1dfefdfe 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,5 @@ { "extends": "astro/tsconfigs/strict", - "include": [".astro/types.d.ts", "**/*"], - "exclude": ["dist"], "compilerOptions": { "resolveJsonModule": true, "jsx": "preserve", From 7f8be18f9c4e2fdcf7758ee4ca441ee33c1bd67a Mon Sep 17 00:00:00 2001 From: MrlingXD <90316914+wling-art@users.noreply.github.com> Date: Sat, 14 Mar 2026 10:17:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9E=95=20=E6=B7=BB=E5=8A=A0=20workbox-wi?= =?UTF-8?q?ndow=20=E4=BE=9D=E8=B5=96=E5=B9=B6=E6=9B=B4=E6=96=B0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astro.config.ts | 2 +- package.json | 3 ++- pnpm-lock.yaml | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/astro.config.ts b/astro.config.ts index eaec5c8bc..13c7e5e96 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -1116,7 +1116,7 @@ export default defineConfig({ vite: { plugins: [tailwindcss()], ssr: { - noExternal: ["naive-ui", "vueuc", "date-fns"] + noExternal: ["naive-ui", "vueuc", "date-fns", "workbox-window"] } } }); diff --git a/package.json b/package.json index 5d7c5f783..bf126e3e6 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "starlight-links-validator": "^0.19.2", "starlight-scroll-to-top": "^0.4.0", "tailwindcss": "^4.1.18", - "typescript": "^5.9.3" + "typescript": "^5.9.3", + "workbox-window": "^7.4.0" }, "engines": { "node": ">=18.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 677df9ffa..3fe19c375 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,6 +75,9 @@ importers: typescript: specifier: ^5.9.3 version: 5.9.3 + workbox-window: + specifier: ^7.4.0 + version: 7.4.0 packages: From 75d64ddf94868cfaf832765cf6c64c86bcaed613 Mon Sep 17 00:00:00 2001 From: MrlingXD <90316914+wling-art@users.noreply.github.com> Date: Sat, 14 Mar 2026 10:22:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=94=A7=20=E7=A7=BB=E9=99=A4=20PWA=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=AD=E7=9A=84=E5=9B=BE=E6=A0=87=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astro.config.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/astro.config.ts b/astro.config.ts index 13c7e5e96..8805e6364 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -1094,19 +1094,7 @@ export default defineConfig({ short_name: "Cubic Wiki", display: "standalone", theme_color: "#2196f3", - background_color: "#424242", - icons: [ - { - src: "/icons/book-192.png", - sizes: "192x192", - type: "image/png" - }, - { - src: "/icons/book-512.png", - sizes: "512x512", - type: "image/png" - } - ] + background_color: "#424242" } }), mermaid({