-import { JUDGE_STATUS } from "../../utils/constants"
-import { SUBMISSION_RESULT } from "../../utils/types"
+import { JUDGE_STATUS } from "utils/constants"
+import { SUBMISSION_RESULT } from "utils/types"
interface Props {
result: SUBMISSION_RESULT
diff --git a/src/shared/composables/monaco.ts b/src/shared/composables/monaco.ts
new file mode 100644
index 0000000..4643861
--- /dev/null
+++ b/src/shared/composables/monaco.ts
@@ -0,0 +1,19 @@
+import loader, { Monaco } from "@monaco-editor/loader"
+
+export const monaco = ref()
+
+export async function init() {
+ loader.config({
+ paths: { vs: "https://cdn.staticfile.org/monaco-editor/0.34.1/min/vs" },
+ "vs/nls": { availableLanguages: { "*": "zh-cn" } },
+ })
+
+ const [m, light, dark] = await Promise.all([
+ loader.init(),
+ fetch("/light.json").then((t) => t.json()),
+ fetch("/dark.json").then((t) => t.json()),
+ ])
+ monaco.value = m
+ monaco.value.editor.defineTheme("light", light)
+ monaco.value.editor.defineTheme("dark", dark)
+}
diff --git a/src/shims.d.ts b/src/shims.d.ts
index bfa4c63..8336eec 100644
--- a/src/shims.d.ts
+++ b/src/shims.d.ts
@@ -3,14 +3,3 @@ declare module "*.md" {
const Component: ComponentOptions
export default Component
}
-
-declare global {
- let monaco: Monaco
- interface Window {
- monaco: Monaco
- }
-}
-
-interface Window {
- monaco: Monaco
-}
diff --git a/src/utils/types.ts b/src/utils/types.ts
index 6dba364..99d3c67 100644
--- a/src/utils/types.ts
+++ b/src/utils/types.ts
@@ -90,7 +90,7 @@ export interface Submission {
code: string
result: SUBMISSION_RESULT
info: Info
- language: string
+ language: LANGUAGE
shared: boolean
statistic_info: {
score?: number
diff --git a/vite.config.ts b/vite.config.ts
index bcbf767..2373218 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -7,6 +7,8 @@ import { NaiveUiResolver } from "unplugin-vue-components/resolvers"
import IconsResolver from "unplugin-icons/resolver"
import Icons from "unplugin-icons/vite"
import Markdown from "vite-plugin-vue-markdown"
+import Highlight from "markdown-it-highlightjs"
+import c from "highlight.js/lib/languages/c"
const url = "https://ojtest.hyyz.izhai.net"
const proxyConfig = {
@@ -52,7 +54,15 @@ export default defineConfig({
dts: "./src/components.d.ts",
}),
Icons({ autoInstall: true }),
- Markdown(),
+ Markdown({
+ markdownItSetup(md) {
+ md.use(Highlight, {
+ register: {
+ c,
+ },
+ })
+ },
+ }),
],
server: {
proxy: {