From 285489296777590cd1d9771879c0ca33205351bf Mon Sep 17 00:00:00 2001 From: Big-Cake-jpg <2577117205@qq.com> Date: Fri, 18 Aug 2023 12:17:01 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E5=A4=8D=E8=AF=84=E8=AE=BA=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=B8=8E=20PWA=20=E7=A6=BB=E7=BA=BF=E7=BC=93=E5=AD=98=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8Cclose=20#134?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/config.ts | 3 +- docs/.vitepress/scripts/pwa.ts | 20 ++++++- docs/.vitepress/theme/components/Comment.vue | 40 +++++++------- package.json | 5 +- pnpm-lock.yaml | 56 ++++++++++---------- 5 files changed, 72 insertions(+), 52 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 65f0c02c..7a77b94b 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -3,7 +3,8 @@ import process from "node:process" import { defineConfig } from "vitepress" import { pwa } from "./scripts/pwa" -const COMMIT_ID = process.env.CF_PAGES_COMMIT_SHA || process.env.COMMIT_REF || "local" +const COMMIT_ID = + process.env.CF_PAGES_COMMIT_SHA || process.env.COMMIT_REF || "local" const commitRef = COMMIT_ID?.slice(0, 8) const environment = process.env.NODE_ENV diff --git a/docs/.vitepress/scripts/pwa.ts b/docs/.vitepress/scripts/pwa.ts index 9aa4ab9b..094616d4 100644 --- a/docs/.vitepress/scripts/pwa.ts +++ b/docs/.vitepress/scripts/pwa.ts @@ -1,13 +1,15 @@ import type { VitePWAOptions } from "vite-plugin-pwa" +const pwaName = process.env.PWA_NAME || "CrashMC 文档(本地)" + export const pwa: Partial = { outDir: ".vitepress/dist", registerType: "prompt", includeManifestIcons: false, manifest: { id: "/", - name: "CrashMC 文档", - short_name: "CrashMC 文档", + name: `${pwaName}`, + short_name: `${pwaName}`, description: "为一般玩家编写的 Minecraft 崩溃分析指南", theme_color: "#ffffff", start_url: "/?utm_source=web_app_manifest", @@ -69,6 +71,20 @@ export const pwa: Partial = { }, }, }, + { + urlPattern: /^https:\/\/cdn\.crashmc\.com\/.*/i, + handler: "NetworkFirst", + options: { + cacheName: "github-images-cache", + expiration: { + maxEntries: 10, + maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days + }, + cacheableResponse: { + statuses: [0, 200], + }, + }, + }, ], }, } diff --git a/docs/.vitepress/theme/components/Comment.vue b/docs/.vitepress/theme/components/Comment.vue index f26d0f40..d648798e 100644 --- a/docs/.vitepress/theme/components/Comment.vue +++ b/docs/.vitepress/theme/components/Comment.vue @@ -1,23 +1,25 @@ - From af3e88914d57cb5c1106598c5a8d1d2af29d5e2d Mon Sep 17 00:00:00 2001 From: Big_Cake <2577117205@qq.com> Date: Sat, 19 Aug 2023 10:04:15 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=B8=8A=E5=B8=9D?= =?UTF-8?q?=EF=BC=8C=E5=BF=98=E8=AE=B0=E6=94=B9=E8=BF=99=E4=B8=AA=E5=9C=B0?= =?UTF-8?q?=E6=96=B9=E7=9A=84=E5=88=86=E6=94=AF=E5=90=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index e7889386..90cfd16e 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -162,7 +162,7 @@ export default withPwa( socialLinks: [{ icon: "github", link: "https://github.com/GlobeMC" }], editLink: { - pattern: "https://github.com/GlobeMC/crashmc.com/edit/main/docs/:path", + pattern: "https://github.com/GlobeMC/crashmc.com/edit/dev/docs/:path", text: "在 GitHub 上帮助我们完善这个页面", }, From 0fcab7246d65b3fcb78af35d1fc84c6fcfc589b5 Mon Sep 17 00:00:00 2001 From: Kevin Z Date: Sat, 19 Aug 2023 00:47:54 -0600 Subject: [PATCH 07/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0Analyzer,=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8MCLA=20API=E5=B9=B6=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=94=99=E8=AF=AF=20(#138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * use MCLA web assembly module as the first analyzer * fixed styles * use vue-router instead of window.href * fix overflow button animation * nice! cdn fixed; makes the cdn url configurable * makes the cdn cache limit larger * we don't need cdn when redirect to github * add MCLA error catcher * use newer API to read file * Update docs/.vitepress/theme/components/Analyzer.vue --------- Co-authored-by: Big_Cake <2577117205@qq.com> --- docs/.vitepress/cdn.js | 25 + docs/.vitepress/scripts/pwa.ts | 2 +- docs/.vitepress/theme/components/Analyzer.vue | 438 ++++++------------ .../theme/components/Contributors.vue | 9 +- package.json | 1 + pnpm-lock.yaml | 64 ++- 6 files changed, 243 insertions(+), 296 deletions(-) create mode 100644 docs/.vitepress/cdn.js diff --git a/docs/.vitepress/cdn.js b/docs/.vitepress/cdn.js new file mode 100644 index 00000000..aa05b993 --- /dev/null +++ b/docs/.vitepress/cdn.js @@ -0,0 +1,25 @@ + +// this file makes the cdn link configurable, then we can disable or switch it easily + +var enabled = true + +export function isCDNEnabled(){ + return enabled +} + +export function enableCDN(){ + enabled = true +} + +export function disableCDN(){ + enabled = false +} + +export const CDN_PREFIX = "https://cdn.crashmc.com/" + +export function useCDN(url){ + if(!url.startsWith('https://')){ // DO NOT allow http here + throw 'URL must starts with https' + } + return enabled ?CDN_PREFIX + url :url +} diff --git a/docs/.vitepress/scripts/pwa.ts b/docs/.vitepress/scripts/pwa.ts index 094616d4..fe34368a 100644 --- a/docs/.vitepress/scripts/pwa.ts +++ b/docs/.vitepress/scripts/pwa.ts @@ -77,7 +77,7 @@ export const pwa: Partial = { options: { cacheName: "github-images-cache", expiration: { - maxEntries: 10, + maxEntries: 20, maxAgeSeconds: 60 * 60 * 24 * 365, // <== 365 days }, cacheableResponse: { diff --git a/docs/.vitepress/theme/components/Analyzer.vue b/docs/.vitepress/theme/components/Analyzer.vue index 2ab3cc8e..47b45b18 100644 --- a/docs/.vitepress/theme/components/Analyzer.vue +++ b/docs/.vitepress/theme/components/Analyzer.vue @@ -1,6 +1,16 @@