Skip to content

Commit 007efb2

Browse files
Weekly Merge 2024-7-29 Mon. (#316)
2 parents 4b35c31 + f0aa5f0 commit 007efb2

16 files changed

+2999
-2676
lines changed

.husky/pre-commit

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
32

43
echo "running docs:tsc"
54
pnpm run docs:tsc
6-
echo "running docs:eslint --fix"
7-
pnpm run docs:eslint --fix
5+
echo "running docs:format"
6+
pnpm run docs:format
87
# echo "running docs:zhlint"
98
# pnpm run docs:zhlint

.vitepress/config.ts

+26-29
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import process from "node:process"
22
import { fileURLToPath } from "node:url"
3-
import { defineConfig } from "vitepress"
3+
import { defineConfigWithTheme } from "vitepress"
44
import type { DefaultTheme } from "vitepress/theme"
55
import { withPwa, type PwaOptions } from "@vite-pwa/vitepress"
66
import { BiDirectionalLinks } from "@nolebase/markdown-it-bi-directional-links"
77
import { InlineLinkPreviewElementTransform } from "@nolebase/vitepress-plugin-inline-link-preview/markdown-it"
88
import {
99
GitChangelog,
10-
GitChangelogMarkdownSection,
11-
} from "@nolebase/vitepress-plugin-git-changelog/vite"
10+
GitChangelogMarkdownSection
11+
} from "@nolebase/vitepress-plugin-git-changelog"
12+
13+
import authors from "./data/authors.json"
14+
15+
function generateAvatarUrl(username: string) {
16+
return `https://cdn.crashmc.com/https://github.com/${username}.png`
17+
}
1218

1319
const COMMIT_ID =
1420
process.env.COMMIT_REF ||
@@ -26,6 +32,16 @@ const viteConfig = {
2632
"@": fileURLToPath(new URL(".", import.meta.url)),
2733
},
2834
},
35+
plugins: [
36+
GitChangelog({
37+
repoURL: () => "https://github.com/GlobeMC/crashmc.com",
38+
mapAuthors: authors.map((author) => ({
39+
...author,
40+
avatar: generateAvatarUrl(author.avatar)
41+
}))
42+
}),
43+
GitChangelogMarkdownSection()
44+
],
2945
optimizeDeps: {
3046
include: [
3147
// @rive-app/canvas is a CJS/UMD module, so it needs to be included here
@@ -41,23 +57,6 @@ const viteConfig = {
4157
"@nolebase/vitepress-plugin-inline-link-preview",
4258
],
4359
},
44-
plugins: [
45-
GitChangelog({
46-
// 填写在此处填写您的仓库链接
47-
repoURL: () => "https://github.com/GlobeMC/crashmc.com",
48-
rewritePaths: {
49-
"docs/": "",
50-
},
51-
}),
52-
GitChangelogMarkdownSection({
53-
locales: {
54-
gitChangelogMarkdownSectionTitles: {
55-
changelog: "文件历史",
56-
contributors: "贡献者",
57-
},
58-
},
59-
}),
60-
],
6160
}
6261

6362
const pwaConfig: PwaOptions = {
@@ -174,7 +173,7 @@ const themeConfig: DefaultTheme.Config = {
174173
{ text: "贡献者列表", link: "/contribute/contributors" },
175174
],
176175
},
177-
{ text: "捐赠支持", link: "https://afdian.net/a/Pigeon0v0" },
176+
{ text: "捐赠支持", link: "https://afdian.com/a/Pigeon0v0" },
178177
],
179178

180179
footer: {
@@ -300,7 +299,7 @@ const themeConfig: DefaultTheme.Config = {
300299
}
301300

302301
export default withPwa(
303-
defineConfig({
302+
defineConfigWithTheme({
304303
title: "GlobeMC",
305304
lang: "zh-CN",
306305
lastUpdated: true,
@@ -319,13 +318,11 @@ export default withPwa(
319318
},
320319
lineNumbers: true,
321320
config: (md) => {
322-
md.use(
323-
() => BiDirectionalLinks({
324-
dir: "docs",
325-
baseDir: "/"
326-
})
327-
),
328-
md.use(() => InlineLinkPreviewElementTransform)
321+
md.use(BiDirectionalLinks({
322+
dir: "docs",
323+
baseDir: "/"
324+
}))
325+
.use(InlineLinkPreviewElementTransform)
329326
},
330327
},
331328

.vitepress/data/authors.json

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
[
2+
{
3+
"name": "Big_Cake",
4+
"nameAliases": [
5+
"Big-Cake-jpg",
6+
"Big_Cake"
7+
],
8+
"avatar": "Big-Cake-jpg"
9+
},
10+
{
11+
"name": "bingling_sama",
12+
"nameAliases": [
13+
"bingling-sama",
14+
"bingling_sama"
15+
],
16+
"avatar": "bingling-sama"
17+
},
18+
{
19+
"name": "柚子柚子",
20+
"nameAliases": [
21+
"youzi-2333",
22+
"柚子柚子"
23+
],
24+
"avatar": "youzi-2333"
25+
},
26+
{
27+
"name": "Pigeon0v0",
28+
"nameAliases": [
29+
"bwtx2023",
30+
"bwtx1981",
31+
"Yousa Ling",
32+
"Pigeon0v0"
33+
],
34+
"avatar": "Pigeon0v0"
35+
},
36+
{
37+
"name": "233355607",
38+
"nameAliases": [
39+
"2623684696",
40+
"233355607"
41+
],
42+
"avatar": "2623684696"
43+
},
44+
{
45+
"name": "hejiehao",
46+
"nameAliases": [
47+
"何杰豪",
48+
"hejiehao"
49+
],
50+
"avatar": "hejiehao"
51+
},
52+
{
53+
"name": "Rovniced",
54+
"nameAliases": [
55+
"Rovniced",
56+
"Enlysure"
57+
],
58+
"avatar": "Rovniced"
59+
},
60+
{
61+
"name": "zyxkad",
62+
"nameAliases": [
63+
"zyxkad",
64+
"Kevin Z"
65+
],
66+
"avatar": "zyxkad"
67+
},
68+
{
69+
"name": "HRxiaohu",
70+
"nameAliases": [
71+
"HRxiaohu"
72+
],
73+
"avatar": "HRxiaohu"
74+
},
75+
{
76+
"name": "Pysio",
77+
"nameAliases": [
78+
"pysio2007",
79+
"Pysio"
80+
],
81+
"avatar": "pysio2007"
82+
},
83+
{
84+
"name": "XieXiLin",
85+
"nameAliases": [
86+
"XieXiLin",
87+
"XieXiLin2"
88+
],
89+
"avatar": "XieXiLin2"
90+
},
91+
{
92+
"name": "Z_Tsin",
93+
"nameAliases": [
94+
"Z_Tsin",
95+
"ztsinsun"
96+
],
97+
"avatar": "ztsinsun"
98+
},
99+
{
100+
"name": "9Bakabaka",
101+
"nameAliases": [
102+
"9Bakabaka"
103+
],
104+
"avatar": "9Bakabaka"
105+
},
106+
{
107+
"name": "ZhuRuoLing",
108+
"nameAliases": [
109+
"ZhuRuoLing"
110+
],
111+
"avatar": "ZhuRuoLing"
112+
},
113+
{
114+
"name": "bingxin666",
115+
"nameAliases": [
116+
"bingxin666"
117+
],
118+
"avatar": "bingxin666"
119+
},
120+
{
121+
"name": "zkitefly",
122+
"nameAliases": [
123+
"zkitefly"
124+
],
125+
"avatar": "zkitefly"
126+
},
127+
{
128+
"name": "思遥方",
129+
"nameAliases": [
130+
"Seayay",
131+
"思遥方"
132+
],
133+
"avatar": "Seayay"
134+
}
135+
]

.vitepress/theme/components/Analyzer.vue

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import JSZip from "jszip"
33
import pako from "pako"
44
import { TarReader } from "@gera2ld/tarjs"
5-
import { useRouter } from "vitepress"
5+
import { useRouter } from "vitepress/client"
66
import { type Ref, ref, watch, onBeforeMount, onUnmounted } from "vue"
77
import axios from "axios"
88
import AnalyzingIcon from "./icons/AnalyzingIcon.vue"
@@ -17,6 +17,7 @@ import {
1717
loadMCLA,
1818
MCLA_GH_DB_PREFIX,
1919
} from "@/analyzers/mcla"
20+
import type { ITarFileInfo } from "@gera2ld/tarjs"
2021
2122
// 类型&接口定义
2223
interface SolutionOkSuccess {
@@ -343,24 +344,25 @@ async function readFiles(file: MemFile, filename?: string): Promise<MemFile[]> {
343344
console.error(`Couldn't decompress file with ext ${ext}:`, error)
344345
throw new AnalysisError("UnzipErr", error)
345346
}
347+
return readFiles(new MemFile(data, file.path), filebase)
346348
case "tar": {
347349
let files
348350
try {
349-
files = await new TarReader().readFile(data)
351+
files = await TarReader.load(data)
350352
} catch (error) {
351353
console.error("Couldn't read the tar file:", error)
352354
throw new AnalysisError("UnzipErr", error)
353355
}
354356
355357
let res: MemFile[] = []
356358
await Promise.all(
357-
files
359+
files.fileInfos
358360
.filter(
359-
(f) =>
361+
(f: ITarFileInfo) =>
360362
!f.name.startsWith("._") &&
361363
!f.name.toLowerCase().startsWith("paxheader/"),
362364
)
363-
.map((f) =>
365+
.map((f: ITarFileInfo) =>
364366
readFiles(
365367
new MemFile(
366368
new Uint8Array(data.buffer, f.headerOffset + 512, f.size),
@@ -1163,7 +1165,8 @@ onUnmounted(() => {
11631165
<div>
11641166
<b>解决方案: </b>
11651167
<a target="_blank" :href="sol.res.link_to">
1166-
打开文档 <OpenTabIcon />
1168+
打开文档
1169+
<OpenTabIcon />
11671170
</a>
11681171
</div>
11691172
</details>

.vitepress/theme/components/Contributors.vue .vitepress/theme/components/ResponsibleEditor.vue

+12-26
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ import { useCDN } from "@/cdn"
66
const defaultAuthor = "GlobeMC"
77
const { frontmatter } = useData()
88
9-
const contributors = computed(() => {
10-
return [
11-
frontmatter.value?.author,
12-
...(frontmatter.value.contributors || []),
13-
].filter((x) => x)
9+
const editor = computed(() => {
10+
return frontmatter.value?.editor
1411
})
1512
1613
function getAvatarUrl(name: string) {
@@ -21,34 +18,23 @@ function getGitHubLink(name: string) {
2118
return `https://github.com/${name}`
2219
}
2320
24-
function isNotEmpty(arr: string | string[]) {
25-
return Array.isArray(arr) && arr.length
26-
}
21+
// function isNotEmpty(arr: string | string[]) {
22+
// return Array.isArray(arr) && arr.length
23+
// }
2724
</script>
2825

2926
<template>
30-
<p class="vp-main-color con">本文贡献者:</p>
31-
<div v-if="isNotEmpty(contributors)" class="flex flex-wrap gap-4">
32-
<div
33-
v-for="contributor of contributors"
34-
:key="contributor"
35-
class="flex gap-2 items-center vp-main-color">
36-
<a
37-
:href="getGitHubLink(contributor)"
38-
rel="noreferrer"
39-
target="_blank"
40-
class="flex items-center gap-2">
41-
<img :src="getAvatarUrl(contributor)" class="w-8 h-8 rounded-full" />
42-
<p class="vp-main-color">{{ contributor }}</p>
27+
<p class="vp-main-color con">本文责任编辑:</p>
28+
<div v-if="editor" class="flex flex-wrap gap-4">
29+
<div class="flex gap-2 items-center vp-main-color">
30+
<a :href="getGitHubLink(editor)" rel="noreferrer" target="_blank" class="flex items-center gap-2">
31+
<img :src="getAvatarUrl(editor)" class="w-8 h-8 rounded-full" />
32+
<p class="vp-main-color">{{ editor }}</p>
4333
</a>
4434
</div>
4535
</div>
4636
<div v-else class="flex gap-2 items-center">
47-
<a
48-
:href="getGitHubLink(defaultAuthor)"
49-
rel="noreferrer"
50-
target="_blank"
51-
class="flex items-center gap-2">
37+
<a :href="getGitHubLink(defaultAuthor)" rel="noreferrer" target="_blank" class="flex items-center gap-2">
5238
<img src="/logo-brand.webp" class="w-8 h-8 rounded-full" />
5339
<p class="vp-main-clolr">{{ "GlobeMC" }}</p>
5440
</a>

0 commit comments

Comments
 (0)