From df3b4f0dfdf353805729b5c0c78471202c140cd7 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Tue, 13 Oct 2026 19:49:20 +0800 Subject: [PATCH] =?UTF-8?q?style(=E4=BB=A3=E7=A0=81=E9=85=8D=E8=89=B2):=20?= =?UTF-8?q?=E5=85=A8=E7=AB=99=E4=BB=A3=E7=A0=81=E6=8D=A2=E6=88=90=20Dracul?= =?UTF-8?q?a=20=E9=85=8D=E8=89=B2=EF=BC=88=E4=BA=AE=E8=89=B2=E7=94=A8?= =?UTF-8?q?=E5=AE=98=E6=96=B9=E6=B5=85=E8=89=B2=E7=89=88=20Alucard?= =?UTF-8?q?=EF=BC=89=EF=BC=9B=E7=BC=96=E8=BE=91=E5=99=A8=E3=80=81=E9=A2=98?= =?UTF-8?q?=E9=9D=A2=E5=92=8C=E6=95=99=E7=A8=8B=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=9D=97=E3=80=81=E7=BB=83=E4=B8=80=E7=BB=83=E3=80=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E8=AF=A6=E6=83=85=E7=9A=84=E9=A2=9C=E8=89=B2=E4=B8=80?= =?UTF-8?q?=E6=A8=A1=E4=B8=80=E6=A0=B7=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原来三套配色各管一块:编辑器是 smoothy / One Dark,正文代码块和练一练是仿 GitHub, 提交详情是 Naive 自带的,同一段 printf 在一课里就有两种颜色。现在静态代码也走编辑器 那套 lezer 解析器,颜色只在 shared/highlight.css 写一份,highlight.js 删掉。 填空题顺手修好:空会把语法搅乱,(humidity ____ 40) 被认成类型声明、humidity 染成类型色, 现在空里先填上答案再解析,答案不输出。 Co-Authored-By: Claude Opus 5.5 --- apps/web/package.json | 1 - apps/web/src/App.vue | 4 +- .../src/oj/learn/components/ExerciseDebug.vue | 1 - .../src/oj/learn/components/ExerciseFill.vue | 38 ++-- .../oj/learn/components/ExercisePredict.vue | 1 - .../src/oj/learn/components/ExerciseSort.vue | 1 - .../src/oj/submission/components/CodeView.vue | 2 +- apps/web/src/shared/components/CodeEditor.vue | 5 +- apps/web/src/shared/components/Markdown.vue | 1 - .../src/shared/components/MarkdownEditor.vue | 5 +- .../src/shared/components/SyncCodeEditor.vue | 5 +- apps/web/src/shared/highlight.css | 108 ++++++---- apps/web/src/shared/highlight.ts | 187 +++++++++++++----- apps/web/src/shared/themes/codeTheme.ts | 107 ++++++++++ apps/web/src/shared/themes/createTheme.ts | 101 ---------- apps/web/src/shared/themes/oneDark.ts | 139 ------------- apps/web/src/shared/themes/smoothy.ts | 100 ---------- bun.lock | 1 - 18 files changed, 345 insertions(+), 462 deletions(-) create mode 100644 apps/web/src/shared/themes/codeTheme.ts delete mode 100644 apps/web/src/shared/themes/createTheme.ts delete mode 100644 apps/web/src/shared/themes/oneDark.ts delete mode 100644 apps/web/src/shared/themes/smoothy.ts diff --git a/apps/web/package.json b/apps/web/package.json index a4eefbe..2a87982 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -34,7 +34,6 @@ "copy-text-to-clipboard": "^3.2.2", "date-fns": "^4.4.0", "fflate": "^0.8.3", - "highlight.js": "^11.12.0", "lib0": "0.2.119", "markdown-it": "^14.3.0", "mermaid": "^12.1.0", diff --git a/apps/web/src/App.vue b/apps/web/src/App.vue index ce96930..71207c6 100644 --- a/apps/web/src/App.vue +++ b/apps/web/src/App.vue @@ -2,6 +2,7 @@ import { darkTheme, dateZhCN, zhCN } from "naive-ui" import "normalize.css" import "./index.css" +import "shared/highlight.css" import { useConfigStore } from "shared/store/config" import { useConfigUpdate } from "shared/composables/configUpdate" import { useUserStore } from "shared/store/user" @@ -40,7 +41,8 @@ watch( { immediate: true }, ) -// n-code(提交详情、看代码的弹框)用的 highlight.js,空闲时再加载,不挡首屏 +// n-code(提交详情、看代码的弹框)的高亮,空闲时再加载,不挡首屏。 +// 它只认 highlight.js 的接口,shared/highlight 给了一个同名的壳,里面是和编辑器同一套解析器 const hljsInstance = shallowRef() onMounted(() => { const load = async () => { diff --git a/apps/web/src/oj/learn/components/ExerciseDebug.vue b/apps/web/src/oj/learn/components/ExerciseDebug.vue index a1bac3f..c553500 100644 --- a/apps/web/src/oj/learn/components/ExerciseDebug.vue +++ b/apps/web/src/oj/learn/components/ExerciseDebug.vue @@ -2,7 +2,6 @@ import ExerciseResult from "./ExerciseResult.vue" import type { Exercise, ExerciseDebugData } from "utils/types" import { highlightLines } from "shared/highlight" -import "shared/highlight.css" const props = defineProps<{ exercise: Exercise; lang?: string }>() const emit = defineEmits<{ diff --git a/apps/web/src/oj/learn/components/ExerciseFill.vue b/apps/web/src/oj/learn/components/ExerciseFill.vue index 18f39db..1b8d305 100644 --- a/apps/web/src/oj/learn/components/ExerciseFill.vue +++ b/apps/web/src/oj/learn/components/ExerciseFill.vue @@ -1,8 +1,7 @@ diff --git a/apps/web/src/shared/components/Markdown.vue b/apps/web/src/shared/components/Markdown.vue index 7d9e315..1040768 100644 --- a/apps/web/src/shared/components/Markdown.vue +++ b/apps/web/src/shared/components/Markdown.vue @@ -1,7 +1,6 @@