diff --git a/.husky/pre-commit b/.husky/pre-commit index 798b8467..0591892e 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,9 +1,8 @@ #!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" echo "running docs:tsc" pnpm run docs:tsc -echo "running docs:eslint --fix" -pnpm run docs:eslint --fix +echo "running docs:format" +pnpm run docs:format # echo "running docs:zhlint" # pnpm run docs:zhlint diff --git a/.vitepress/config.ts b/.vitepress/config.ts index d241a1d7..dfd5948a 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -1,14 +1,20 @@ import process from "node:process" import { fileURLToPath } from "node:url" -import { defineConfig } from "vitepress" +import { defineConfigWithTheme } from "vitepress" import type { DefaultTheme } from "vitepress/theme" import { withPwa, type PwaOptions } from "@vite-pwa/vitepress" import { BiDirectionalLinks } from "@nolebase/markdown-it-bi-directional-links" import { InlineLinkPreviewElementTransform } from "@nolebase/vitepress-plugin-inline-link-preview/markdown-it" import { GitChangelog, - GitChangelogMarkdownSection, -} from "@nolebase/vitepress-plugin-git-changelog/vite" + GitChangelogMarkdownSection +} from "@nolebase/vitepress-plugin-git-changelog" + +import authors from "./data/authors.json" + +function generateAvatarUrl(username: string) { + return `https://cdn.crashmc.com/https://github.com/${username}.png` +} const COMMIT_ID = process.env.COMMIT_REF || @@ -26,6 +32,16 @@ const viteConfig = { "@": fileURLToPath(new URL(".", import.meta.url)), }, }, + plugins: [ + GitChangelog({ + repoURL: () => "https://github.com/GlobeMC/crashmc.com", + mapAuthors: authors.map((author) => ({ + ...author, + avatar: generateAvatarUrl(author.avatar) + })) + }), + GitChangelogMarkdownSection() + ], optimizeDeps: { include: [ // @rive-app/canvas is a CJS/UMD module, so it needs to be included here @@ -41,23 +57,6 @@ const viteConfig = { "@nolebase/vitepress-plugin-inline-link-preview", ], }, - plugins: [ - GitChangelog({ - // 填写在此处填写您的仓库链接 - repoURL: () => "https://github.com/GlobeMC/crashmc.com", - rewritePaths: { - "docs/": "", - }, - }), - GitChangelogMarkdownSection({ - locales: { - gitChangelogMarkdownSectionTitles: { - changelog: "文件历史", - contributors: "贡献者", - }, - }, - }), - ], } const pwaConfig: PwaOptions = { @@ -174,7 +173,7 @@ const themeConfig: DefaultTheme.Config = { { text: "贡献者列表", link: "/contribute/contributors" }, ], }, - { text: "捐赠支持", link: "https://afdian.net/a/Pigeon0v0" }, + { text: "捐赠支持", link: "https://afdian.com/a/Pigeon0v0" }, ], footer: { @@ -300,7 +299,7 @@ const themeConfig: DefaultTheme.Config = { } export default withPwa( - defineConfig({ + defineConfigWithTheme({ title: "GlobeMC", lang: "zh-CN", lastUpdated: true, @@ -319,13 +318,11 @@ export default withPwa( }, lineNumbers: true, config: (md) => { - md.use( - () => BiDirectionalLinks({ - dir: "docs", - baseDir: "/" - }) - ), - md.use(() => InlineLinkPreviewElementTransform) + md.use(BiDirectionalLinks({ + dir: "docs", + baseDir: "/" + })) + .use(InlineLinkPreviewElementTransform) }, }, diff --git a/.vitepress/data/authors.json b/.vitepress/data/authors.json new file mode 100644 index 00000000..678428d7 --- /dev/null +++ b/.vitepress/data/authors.json @@ -0,0 +1,135 @@ +[ + { + "name": "Big_Cake", + "nameAliases": [ + "Big-Cake-jpg", + "Big_Cake" + ], + "avatar": "Big-Cake-jpg" + }, + { + "name": "bingling_sama", + "nameAliases": [ + "bingling-sama", + "bingling_sama" + ], + "avatar": "bingling-sama" + }, + { + "name": "柚子柚子", + "nameAliases": [ + "youzi-2333", + "柚子柚子" + ], + "avatar": "youzi-2333" + }, + { + "name": "Pigeon0v0", + "nameAliases": [ + "bwtx2023", + "bwtx1981", + "Yousa Ling", + "Pigeon0v0" + ], + "avatar": "Pigeon0v0" + }, + { + "name": "233355607", + "nameAliases": [ + "2623684696", + "233355607" + ], + "avatar": "2623684696" + }, + { + "name": "hejiehao", + "nameAliases": [ + "何杰豪", + "hejiehao" + ], + "avatar": "hejiehao" + }, + { + "name": "Rovniced", + "nameAliases": [ + "Rovniced", + "Enlysure" + ], + "avatar": "Rovniced" + }, + { + "name": "zyxkad", + "nameAliases": [ + "zyxkad", + "Kevin Z" + ], + "avatar": "zyxkad" + }, + { + "name": "HRxiaohu", + "nameAliases": [ + "HRxiaohu" + ], + "avatar": "HRxiaohu" + }, + { + "name": "Pysio", + "nameAliases": [ + "pysio2007", + "Pysio" + ], + "avatar": "pysio2007" + }, + { + "name": "XieXiLin", + "nameAliases": [ + "XieXiLin", + "XieXiLin2" + ], + "avatar": "XieXiLin2" + }, + { + "name": "Z_Tsin", + "nameAliases": [ + "Z_Tsin", + "ztsinsun" + ], + "avatar": "ztsinsun" + }, + { + "name": "9Bakabaka", + "nameAliases": [ + "9Bakabaka" + ], + "avatar": "9Bakabaka" + }, + { + "name": "ZhuRuoLing", + "nameAliases": [ + "ZhuRuoLing" + ], + "avatar": "ZhuRuoLing" + }, + { + "name": "bingxin666", + "nameAliases": [ + "bingxin666" + ], + "avatar": "bingxin666" + }, + { + "name": "zkitefly", + "nameAliases": [ + "zkitefly" + ], + "avatar": "zkitefly" + }, + { + "name": "思遥方", + "nameAliases": [ + "Seayay", + "思遥方" + ], + "avatar": "Seayay" + } +] \ No newline at end of file diff --git a/.vitepress/theme/components/Analyzer.vue b/.vitepress/theme/components/Analyzer.vue index 6af6e9ae..6219beab 100644 --- a/.vitepress/theme/components/Analyzer.vue +++ b/.vitepress/theme/components/Analyzer.vue @@ -2,7 +2,7 @@ import JSZip from "jszip" import pako from "pako" import { TarReader } from "@gera2ld/tarjs" -import { useRouter } from "vitepress" +import { useRouter } from "vitepress/client" import { type Ref, ref, watch, onBeforeMount, onUnmounted } from "vue" import axios from "axios" import AnalyzingIcon from "./icons/AnalyzingIcon.vue" @@ -17,6 +17,7 @@ import { loadMCLA, MCLA_GH_DB_PREFIX, } from "@/analyzers/mcla" +import type { ITarFileInfo } from "@gera2ld/tarjs" // 类型&接口定义 interface SolutionOkSuccess { @@ -343,10 +344,11 @@ async function readFiles(file: MemFile, filename?: string): Promise { console.error(`Couldn't decompress file with ext ${ext}:`, error) throw new AnalysisError("UnzipErr", error) } + return readFiles(new MemFile(data, file.path), filebase) case "tar": { let files try { - files = await new TarReader().readFile(data) + files = await TarReader.load(data) } catch (error) { console.error("Couldn't read the tar file:", error) throw new AnalysisError("UnzipErr", error) @@ -354,13 +356,13 @@ async function readFiles(file: MemFile, filename?: string): Promise { let res: MemFile[] = [] await Promise.all( - files + files.fileInfos .filter( - (f) => + (f: ITarFileInfo) => !f.name.startsWith("._") && !f.name.toLowerCase().startsWith("paxheader/"), ) - .map((f) => + .map((f: ITarFileInfo) => readFiles( new MemFile( new Uint8Array(data.buffer, f.headerOffset + 512, f.size), @@ -1163,7 +1165,8 @@ onUnmounted(() => {
解决方案: - 打开文档 + 打开文档 +
diff --git a/.vitepress/theme/components/Contributors.vue b/.vitepress/theme/components/ResponsibleEditor.vue similarity index 56% rename from .vitepress/theme/components/Contributors.vue rename to .vitepress/theme/components/ResponsibleEditor.vue index a25b8b9a..543acb60 100644 --- a/.vitepress/theme/components/Contributors.vue +++ b/.vitepress/theme/components/ResponsibleEditor.vue @@ -6,11 +6,8 @@ import { useCDN } from "@/cdn" const defaultAuthor = "GlobeMC" const { frontmatter } = useData() -const contributors = computed(() => { - return [ - frontmatter.value?.author, - ...(frontmatter.value.contributors || []), - ].filter((x) => x) +const editor = computed(() => { + return frontmatter.value?.editor }) function getAvatarUrl(name: string) { @@ -21,34 +18,23 @@ function getGitHubLink(name: string) { return `https://github.com/${name}` } -function isNotEmpty(arr: string | string[]) { - return Array.isArray(arr) && arr.length -} +// function isNotEmpty(arr: string | string[]) { +// return Array.isArray(arr) && arr.length +// }