Skip to content

Commit

Permalink
bump MCLA to v0.6.0 (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
bingling-sama authored Jan 23, 2025
2 parents 07056be + 587a00c commit a8a904c
Show file tree
Hide file tree
Showing 8 changed files with 3,151 additions and 2,427 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"parser": "@typescript-eslint/parser",
"project": [
"./tsconfig.json",
"./tsconfig.worker.json"
"./tsconfig.worker.json",
"./tsconfig.node.json"
],
"sourceType": "module",
"extraFileExtensions": [".vue"]
Expand Down
2 changes: 2 additions & 0 deletions .vitepress/theme/analyzers/mcla.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ interface ErrorDesc {
error: string
message: string
solutions: number[]
data?: { [key: string]: any }
}

interface SolutionPossibility {
Expand All @@ -83,6 +84,7 @@ interface Solution {
tags: string[]
description: string
link_to: string
addition?: string
}

interface MCLAAPI {
Expand Down
7 changes: 5 additions & 2 deletions .vitepress/theme/analyzers/mcla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
} from "./mcla.api"
export * from "./mcla.api"

const VERSION = "v0.5.1"
const VERSION = "v0.6.0"
// const VERSION = "dev"
const RESOURCES_BASE = "https://globemc.github.io/mcla"
const GO_WASM_EXEC_URL = useCDN(`${RESOURCES_BASE}/${VERSION}/wasm_exec.js`)
Expand Down Expand Up @@ -220,7 +220,10 @@ async function loadMCLA(loadProgress?: Ref<number>): Promise<MCLAAPI> {
try {
return loadMCLAWorker(loadProgress)
} catch (e) {
// if cannot load by worker, try load inside the window
console.warn(
"Could not load MCLA inside worker, falling back to use DOM thread.",
e,
)
}
}

Expand Down
32 changes: 29 additions & 3 deletions .vitepress/theme/components/Analyzer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,35 @@ async function mclAnalysis(file: MemFile): Promise<void> {
.filter(({ match }) => match >= 0.5) // >= 50%
.sort((a, b) => b.match - a.match) // x.match 降序排序
.map(({ match, errorDesc }) => {
const matchData = errorDesc.data
return Promise.all(
errorDesc.solutions.map((id) =>
axios
.get<Solution>(`${MCLA_GH_DB_PREFIX}/solutions/${id}.json`)
.then(
(res): SolutionOkSuccess => ({ ok: true, res: res.data }),
)
.then((res): SolutionOkSuccess => {
const data = res.data
let addition: string | undefined
if (matchData && data.addition) {
try {
addition = Function(
'"use strict";return function(data){return(' +
data.addition +
")}",
)()(matchData)
} catch (e) {
console.warn("Could not render addition texts:", e)
}
}
return {
ok: true,
res: {
tags: data.tags,
description: data.description,
link_to: data.link_to,
addition: addition,
},
}
})
.catch(
(err): SolutionOkFailed => ({
ok: false,
Expand Down Expand Up @@ -717,6 +739,10 @@ onUnmounted(() => {
<b>描述: </b>
<span>{{ sol.res.description }}</span>
</div>
<div v-if="sol.res.addition">
<b>补充: </b>
<span v-html="sol.res.addition"></span>
</div>
<div>
<b>解决方案: </b>
<a target="_blank" :href="sol.res.link_to">
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
"@nolebase/vitepress-plugin-enhanced-readabilities": "2.3.0",
"@nolebase/vitepress-plugin-git-changelog": "2.3.0",
"@nolebase/vitepress-plugin-inline-link-preview": "2.3.0",
"@types/node": "^22.10.8",
"@types/pako": "^2.0.3",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/eslint-plugin": "^8.21.0",
"@vite-pwa/assets-generator": "^0.2.4",
"@vite-pwa/vitepress": "^0.5.0",
"@vue/tsconfig": "^0.5.1",
Expand Down Expand Up @@ -55,7 +56,7 @@
"@gera2ld/tarjs": "^0.3.1",
"@types/js-cookie": "^3.0.6",
"@types/umami": "^2.10.0",
"@typescript-eslint/parser": "^7.17.0",
"@typescript-eslint/parser": "^8.21.0",
"axios": "^1.7.2",
"directory-tree": "^3.5.2",
"js-cookie": "^3.0.5",
Expand Down
Loading

0 comments on commit a8a904c

Please sign in to comment.