Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weekly Merge 2024-7-29 Mon. #316

Merged
merged 11 commits into from
Jul 29, 2024
5 changes: 2 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -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
55 changes: 26 additions & 29 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -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 ||
Expand All @@ -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
Expand All @@ -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 = {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -300,7 +299,7 @@ const themeConfig: DefaultTheme.Config = {
}

export default withPwa(
defineConfig({
defineConfigWithTheme({
title: "GlobeMC",
lang: "zh-CN",
lastUpdated: true,
Expand All @@ -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)
},
},

Expand Down
135 changes: 135 additions & 0 deletions .vitepress/data/authors.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
15 changes: 9 additions & 6 deletions .vitepress/theme/components/Analyzer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -17,6 +17,7 @@ import {
loadMCLA,
MCLA_GH_DB_PREFIX,
} from "@/analyzers/mcla"
import type { ITarFileInfo } from "@gera2ld/tarjs"

// 类型&接口定义
interface SolutionOkSuccess {
Expand Down Expand Up @@ -343,24 +344,25 @@ async function readFiles(file: MemFile, filename?: string): Promise<MemFile[]> {
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)
}

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),
Expand Down Expand Up @@ -1163,7 +1165,8 @@ onUnmounted(() => {
<div>
<b>解决方案: </b>
<a target="_blank" :href="sol.res.link_to">
打开文档 <OpenTabIcon />
打开文档
<OpenTabIcon />
</a>
</div>
</details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
// }
</script>

<template>
<p class="vp-main-color con">本文贡献者:</p>
<div v-if="isNotEmpty(contributors)" class="flex flex-wrap gap-4">
<div
v-for="contributor of contributors"
:key="contributor"
class="flex gap-2 items-center vp-main-color">
<a
:href="getGitHubLink(contributor)"
rel="noreferrer"
target="_blank"
class="flex items-center gap-2">
<img :src="getAvatarUrl(contributor)" class="w-8 h-8 rounded-full" />
<p class="vp-main-color">{{ contributor }}</p>
<p class="vp-main-color con">本文责任编辑:</p>
<div v-if="editor" class="flex flex-wrap gap-4">
<div class="flex gap-2 items-center vp-main-color">
<a :href="getGitHubLink(editor)" rel="noreferrer" target="_blank" class="flex items-center gap-2">
<img :src="getAvatarUrl(editor)" class="w-8 h-8 rounded-full" />
<p class="vp-main-color">{{ editor }}</p>
</a>
</div>
</div>
<div v-else class="flex gap-2 items-center">
<a
:href="getGitHubLink(defaultAuthor)"
rel="noreferrer"
target="_blank"
class="flex items-center gap-2">
<a :href="getGitHubLink(defaultAuthor)" rel="noreferrer" target="_blank" class="flex items-center gap-2">
<img src="/logo-brand.webp" class="w-8 h-8 rounded-full" />
<p class="vp-main-clolr">{{ "GlobeMC" }}</p>
</a>
Expand Down
Loading
Loading