Skip to content

Commit

Permalink
🦄 refactor(structure): restruct code
Browse files Browse the repository at this point in the history
  • Loading branch information
bingling-sama committed Jul 29, 2024
1 parent 5351e46 commit 4158ab6
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 137 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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 }

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion .vitepress/theme/components/Analyzer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
// 类型&接口定义
Expand Down
2 changes: 1 addition & 1 deletion .vitepress/theme/components/AuthRedirect.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref, onMounted } from "vue"
import { onAuthDone } from "@/auth/github"
import { onAuthDone } from "@theme/auth/github"
const REDIRECT_TIMEOUT_SEC = 3
Expand Down
7 changes: 5 additions & 2 deletions .vitepress/theme/components/LogViewer.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<script setup lang="ts">
import { type Ref, ref, onMounted, nextTick } from "vue"
import axios from "axios"
import { getAuthToken, expireAuthToken, redirectToAuth } from "@/auth/github"
// import { useCDN } from "@/cdn"
import {
getAuthToken,
expireAuthToken,
redirectToAuth,
} from "@theme/auth/github"
const loading = ref(true)
const errorStr = ref("")
Expand Down
6 changes: 1 addition & 5 deletions .vitepress/theme/components/ResponsibleEditor.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { useData } from "vitepress"
import { computed } from "vue"
import { useCDN } from "@/cdn"
import { useCDN } from "@theme/utils/cdn"
const defaultAuthor = "GlobeMC"
const { frontmatter } = useData()
Expand All @@ -17,10 +17,6 @@ function getAvatarUrl(name: string) {
function getGitHubLink(name: string) {
return `https://github.com/${name}`
}
// function isNotEmpty(arr: string | string[]) {
// return Array.isArray(arr) && arr.length
// }
</script>

<template>
Expand Down
6 changes: 4 additions & 2 deletions .vitepress/theme/configs/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion .vitepress/theme/layouts/Posts.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { data as posts } from "../../data/posts.data"
import { data as posts } from "@data/posts.data"
</script>

<template>
Expand Down
File renamed without changes.
File renamed without changes.
41 changes: 0 additions & 41 deletions .vitepress/utils/progressFetch.ts

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
108 changes: 57 additions & 51 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
58 changes: 28 additions & 30 deletions tsconfig.worker.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 4158ab6

Please sign in to comment.