diff --git a/.vitepress/analyzers/mcla.api.ts b/.vitepress/theme/analyzers/mcla.api.ts
similarity index 100%
rename from .vitepress/analyzers/mcla.api.ts
rename to .vitepress/theme/analyzers/mcla.api.ts
diff --git a/.vitepress/analyzers/mcla.ts b/.vitepress/theme/analyzers/mcla.ts
similarity index 99%
rename from .vitepress/analyzers/mcla.ts
rename to .vitepress/theme/analyzers/mcla.ts
index 00e2011f..104ce932 100644
--- a/.vitepress/analyzers/mcla.ts
+++ b/.vitepress/theme/analyzers/mcla.ts
@@ -1,5 +1,5 @@
import type { Ref } from "vue"
-import { useCDN } from "@/cdn"
+import { useCDN } from "@theme/utils/cdn"
export { VERSION, MCLA_GH_DB_PREFIX, loadMCLA }
diff --git a/.vitepress/auth/github.ts b/.vitepress/theme/auth/github.ts
similarity index 100%
rename from .vitepress/auth/github.ts
rename to .vitepress/theme/auth/github.ts
diff --git a/.vitepress/theme/components/Analyzer.vue b/.vitepress/theme/components/Analyzer.vue
index 6219beab..d23d8713 100644
--- a/.vitepress/theme/components/Analyzer.vue
+++ b/.vitepress/theme/components/Analyzer.vue
@@ -16,7 +16,7 @@ import {
type Solution,
loadMCLA,
MCLA_GH_DB_PREFIX,
-} from "@/analyzers/mcla"
+} from "@/theme/analyzers/mcla"
import type { ITarFileInfo } from "@gera2ld/tarjs"
// 类型&接口定义
diff --git a/.vitepress/theme/components/AuthRedirect.vue b/.vitepress/theme/components/AuthRedirect.vue
index 16e927cb..d527c804 100644
--- a/.vitepress/theme/components/AuthRedirect.vue
+++ b/.vitepress/theme/components/AuthRedirect.vue
@@ -1,6 +1,6 @@
diff --git a/.vitepress/theme/configs/vite.ts b/.vitepress/theme/configs/vite.ts
index bf726c3d..ac16dd65 100644
--- a/.vitepress/theme/configs/vite.ts
+++ b/.vitepress/theme/configs/vite.ts
@@ -4,7 +4,7 @@ import {
GitChangelogMarkdownSection,
} from "@nolebase/vitepress-plugin-git-changelog"
-import authors from "../../data/authors.json"
+import authors from "@data/authors.json"
function generateAvatarUrl(username: string) {
return `https://cdn.crashmc.com/https://github.com/${username}.png`
@@ -13,7 +13,9 @@ function generateAvatarUrl(username: string) {
const viteConfig = {
resolve: {
alias: {
- "@": fileURLToPath(new URL(".", import.meta.url)),
+ "@": fileURLToPath(new URL("../../", import.meta.url)),
+ "@theme": fileURLToPath(new URL("../", import.meta.url)),
+ "@data": fileURLToPath(new URL("../../data", import.meta.url)),
},
},
plugins: [
diff --git a/.vitepress/theme/layouts/Posts.vue b/.vitepress/theme/layouts/Posts.vue
index 3ef96741..935adfc6 100644
--- a/.vitepress/theme/layouts/Posts.vue
+++ b/.vitepress/theme/layouts/Posts.vue
@@ -1,5 +1,5 @@
diff --git a/.vitepress/cdn.ts b/.vitepress/theme/utils/cdn.ts
similarity index 100%
rename from .vitepress/cdn.ts
rename to .vitepress/theme/utils/cdn.ts
diff --git a/.vitepress/workers/mcla.worker.ts b/.vitepress/theme/workers/mcla.worker.ts
similarity index 100%
rename from .vitepress/workers/mcla.worker.ts
rename to .vitepress/theme/workers/mcla.worker.ts
diff --git a/.vitepress/utils/progressFetch.ts b/.vitepress/utils/progressFetch.ts
deleted file mode 100644
index ef8664f1..00000000
--- a/.vitepress/utils/progressFetch.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-type ProgressCallback = (
- percent: number,
- downloaded: number,
- chunk: number,
-) => void
-
-export async function progressFetch(
- url: string,
- callback: ProgressCallback,
-): Promise {
- const resp = await fetch(url)
- const contentLength =
- Number.parseInt(resp.headers.get("Content-Length") || "") * 2 || 1024 * 1024
- callback(0, 0, 0)
-
- if (!resp.body) {
- return resp
- }
- const reader = resp.body.getReader()
- const stream = new ReadableStream({
- async start(controller) {
- try {
- var downloaded = 0
- var chunk: Uint8Array | undefined
- while (!({ value: chunk } = await reader.read()).done) {
- chunk = chunk as Uint8Array
- downloaded += chunk.byteLength
- const percent = Math.min(downloaded / contentLength, 0.95)
- callback(percent, downloaded, chunk.byteLength)
- controller.enqueue(chunk)
- }
- callback(1, downloaded, 0)
- controller.close()
- } catch (err) {
- controller.error(err)
- }
- },
- })
-
- return new Response(stream, { headers: resp.headers })
-}
diff --git a/package.json b/package.json
index 025fdbae..1513082e 100644
--- a/package.json
+++ b/package.json
@@ -1,13 +1,13 @@
{
"scripts": {
+ "prepare": "husky",
"docs:dev": "vitepress dev .",
"docs:build": "vitepress build .",
"docs:preview": "vitepress preview .",
+ "docs:check": "pnpm run docs:tsc && pnpm run docs:format",
"docs:format": "eslint --ignore-path .gitignore --ext .ts,.vue \".vitepress/**/*.{ts,vue}\" --fix",
- "docs:eslint": "eslint --ignore-path .gitignore --ext .ts,.vue \".vitepress/**/*.{ts,vue}\"",
"docs:zhlint": "zhlint 'docs/**/*.md' --fix",
"docs:tsc": "tsc --build && vue-tsc --noEmit",
- "prepare": "husky",
"generate-pwa-assets": "pwa-assets-generator --preset minimal-2023 docs/public/logo-new.webp"
},
"name": "mccrash-docs",
diff --git a/tsconfig.json b/tsconfig.json
index 6a967f1e..18a570ea 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,53 +1,59 @@
{
- "extends": "@vue/tsconfig/tsconfig.dom.json",
- "include": [
- ".vitepress/**/*.ts",
- ".vitepress/**/*.vue",
- "pwa-assets.config.ts"
- ],
- "exclude": [
- ".vitepress/workers",
- "node_modules",
- "./.vitepress/analyzers/mcla.api.ts",
- "./node_modules/@types/node/index.d.ts",
- ],
- "compilerOptions": {
- "baseUrl": ".",
- "outDir": "out",
- "jsx": "preserve",
- "module": "ESNext",
- "moduleResolution": "Bundler",
- "resolveJsonModule": true,
- "strict": true,
- "strictNullChecks": true,
- "noFallthroughCasesInSwitch": true,
- "noImplicitAny": true,
- "noUnusedLocals": true,
- "noUnusedParameters": true,
- "noEmit": true,
- "removeComments": false,
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
- "isolatedModules": true,
- "verbatimModuleSyntax": true,
- "skipLibCheck": true,
- "ignoreDeprecations": "5.0",
- "lib": [
- "DOM",
- "ESNext"
- ],
- "paths": {
- "@/*": [
- "./.vitepress/*"
- ],
- },
- "types": [
- "vite-plugin-pwa/pwa-assets",
- ],
- },
- "references": [
- {
- "path": "./tsconfig.worker.json"
- }
- ]
+ "extends": "@vue/tsconfig/tsconfig.dom.json",
+ "include": [
+ ".vitepress/**/*.ts",
+ ".vitepress/**/*.vue",
+ "pwa-assets.config.ts"
+ ],
+ "exclude": [
+ ".vitepress/theme/workers",
+ "node_modules",
+ ".vitepress/theme/analyzers/mcla.api.ts",
+ "./node_modules/@types/node/index.d.ts",
+ ],
+ "compilerOptions": {
+ "baseUrl": ".",
+ "outDir": "out",
+ "jsx": "preserve",
+ "module": "ESNext",
+ "moduleResolution": "Bundler",
+ "resolveJsonModule": true,
+ "strict": true,
+ "strictNullChecks": true,
+ "noFallthroughCasesInSwitch": true,
+ "noImplicitAny": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noEmit": true,
+ "removeComments": false,
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "isolatedModules": true,
+ "verbatimModuleSyntax": true,
+ "skipLibCheck": true,
+ "ignoreDeprecations": "5.0",
+ "lib": [
+ "DOM",
+ "ESNext"
+ ],
+ "paths": {
+ "@/*": [
+ "./.vitepress/*"
+ ],
+ "@theme/*": [
+ "./.vitepress/theme/*"
+ ],
+ "@data/*": [
+ "./.vitepress/data/*"
+ ]
+ },
+ "types": [
+ "vite-plugin-pwa/pwa-assets",
+ ],
+ },
+ "references": [
+ {
+ "path": "./tsconfig.worker.json"
+ }
+ ]
}
\ No newline at end of file
diff --git a/tsconfig.worker.json b/tsconfig.worker.json
index c9136db8..588b05fe 100644
--- a/tsconfig.worker.json
+++ b/tsconfig.worker.json
@@ -1,32 +1,30 @@
{
- "include": [".vitepress/workers/*", ".vitepress/**/*.api.ts"],
- "compilerOptions": {
- "composite": true,
-
- "lib": [
- "es2020",
- "webworker",
- ],
-
- "module": "ESNext",
- "moduleResolution": "bundler",
- "resolveJsonModule": true,
-
- "noImplicitThis": true,
- "strict": true,
-
- "verbatimModuleSyntax": true,
-
- "target": "ESNext",
-
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
- "skipLibCheck": true,
-
- "baseUrl": ".",
- "paths": {
- "@/*": ["./.vitepress/*"],
- },
- "outDir": "out"
- }
+ "include": [
+ ".vitepress/theme/workers/*",
+ ".vitepress/**/*.api.ts"
+ ],
+ "compilerOptions": {
+ "composite": true,
+ "lib": [
+ "es2020",
+ "webworker",
+ ],
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "resolveJsonModule": true,
+ "noImplicitThis": true,
+ "strict": true,
+ "verbatimModuleSyntax": true,
+ "target": "ESNext",
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "skipLibCheck": true,
+ "baseUrl": ".",
+ "paths": {
+ "@/*": [
+ "./.vitepress/*"
+ ],
+ },
+ "outDir": "out"
+ }
}
\ No newline at end of file