描述
- - -输入
- - -输出
- - -提示
-测试用例 {{ index + 1 }}
-来源
- -描述
+ + +输入
+ + +输出
+ + +提示
+测试用例 {{ index + 1 }}
+来源
+ +({
- value: "",
- language: "C",
- })
-
- return { code }
-})
+import { Code } from "utils/types"
+
+export const useCodeStore = defineStore("code", () => {
+ const code = reactive({
+ value: "",
+ language: "C",
+ })
+
+ return { code }
+})
diff --git a/src/routes.ts b/src/routes.ts
index 5c8c814..2f7d48d 100644
--- a/src/routes.ts
+++ b/src/routes.ts
@@ -1,54 +1,54 @@
-export const routes = [
- {
- path: "/",
- component: () => import("~/shared/layout/default.vue"),
- children: [
- { path: "", component: () => import("oj/problem/list.vue") },
- {
- path: "problem/:problemID",
- component: () => import("oj/problem/detail.vue"),
- props: true,
- name: "ProblemDetail",
- },
- {
- path: "status",
- component: () => import("oj/status/list.vue"),
- meta: { requiresAuth: true },
- },
- {
- path: "status/:statusID",
- component: () => import("oj/status/detail.vue"),
- props: true,
- },
- {
- path: "contest",
- component: () => import("oj/contest/list.vue"),
- meta: { requiresAuth: true },
- },
- {
- path: "contest/:contestID",
- component: () => import("oj/contest/detail.vue"),
- props: true,
- },
- {
- path: "contest/:contestID/problem/:problemID",
- component: () => import("oj/problem/detail.vue"),
- props: true,
- name: "ContestProblemDetail",
- },
- {
- path: "rank",
- component: () => import("oj/rank/list.vue"),
- },
- {
- path: "learn",
- component: () => import("learn/index.vue"),
- },
- ],
- },
- {
- path: "/admin",
- component: () => import("~/shared/layout/admin.vue"),
- children: [{ path: "", component: () => import("admin/index.vue") }],
- },
-]
+export const routes = [
+ {
+ path: "/",
+ component: () => import("~/shared/layout/default.vue"),
+ children: [
+ { path: "", component: () => import("oj/problem/list.vue") },
+ {
+ path: "problem/:problemID",
+ component: () => import("oj/problem/detail.vue"),
+ props: true,
+ name: "ProblemDetail",
+ },
+ {
+ path: "status",
+ component: () => import("oj/status/list.vue"),
+ meta: { requiresAuth: true },
+ },
+ {
+ path: "status/:statusID",
+ component: () => import("oj/status/detail.vue"),
+ props: true,
+ },
+ {
+ path: "contest",
+ component: () => import("oj/contest/list.vue"),
+ meta: { requiresAuth: true },
+ },
+ {
+ path: "contest/:contestID",
+ component: () => import("oj/contest/detail.vue"),
+ props: true,
+ },
+ {
+ path: "contest/:contestID/problem/:problemID",
+ component: () => import("oj/problem/detail.vue"),
+ props: true,
+ name: "ContestProblemDetail",
+ },
+ {
+ path: "rank",
+ component: () => import("oj/rank/list.vue"),
+ },
+ {
+ path: "learn",
+ component: () => import("learn/index.vue"),
+ },
+ ],
+ },
+ {
+ path: "/admin",
+ component: () => import("~/shared/layout/admin.vue"),
+ children: [{ path: "", component: () => import("admin/index.vue") }],
+ },
+]
diff --git a/src/shared/Monaco/index.vue b/src/shared/Monaco/index.vue
index 20226d0..988291e 100644
--- a/src/shared/Monaco/index.vue
+++ b/src/shared/Monaco/index.vue
@@ -1,98 +1,98 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/src/shared/Pagination/index.vue b/src/shared/Pagination/index.vue
index 786c58e..f9c6e99 100644
--- a/src/shared/Pagination/index.vue
+++ b/src/shared/Pagination/index.vue
@@ -1,42 +1,42 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/src/shared/Split/Pane.vue b/src/shared/Split/Pane.vue
index e30c74a..2163098 100644
--- a/src/shared/Split/Pane.vue
+++ b/src/shared/Split/Pane.vue
@@ -1,46 +1,46 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/src/shared/Split/Resizer.vue b/src/shared/Split/Resizer.vue
index 49dab7a..e7702f8 100644
--- a/src/shared/Split/Resizer.vue
+++ b/src/shared/Split/Resizer.vue
@@ -1,47 +1,47 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/shared/Split/index.vue b/src/shared/Split/index.vue
index e3819b6..1456ce3 100644
--- a/src/shared/Split/index.vue
+++ b/src/shared/Split/index.vue
@@ -1,141 +1,141 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/shared/composables/breakpoints.ts b/src/shared/composables/breakpoints.ts
index c598f32..0de1007 100644
--- a/src/shared/composables/breakpoints.ts
+++ b/src/shared/composables/breakpoints.ts
@@ -1,6 +1,6 @@
-import { breakpointsTailwind } from "@vueuse/core"
-
-const breakpoints = useBreakpoints(breakpointsTailwind)
-
-export const isMobile = breakpoints.smallerOrEqual("md")
-export const isDesktop = breakpoints.greater("md")
+import { breakpointsTailwind } from "@vueuse/core"
+
+const breakpoints = useBreakpoints(breakpointsTailwind)
+
+export const isMobile = breakpoints.smallerOrEqual("md")
+export const isDesktop = breakpoints.greater("md")
diff --git a/src/shared/composables/dark.ts b/src/shared/composables/dark.ts
index 61e0f50..1697ac4 100644
--- a/src/shared/composables/dark.ts
+++ b/src/shared/composables/dark.ts
@@ -1,2 +1,2 @@
-export const isDark = useDark({ storageKey: "theme-appearance" })
-export const toggleDark = useToggle(isDark)
+export const isDark = useDark({ storageKey: "theme-appearance" })
+export const toggleDark = useToggle(isDark)
diff --git a/src/shared/composables/modal.ts b/src/shared/composables/modal.ts
index b824451..29f739d 100644
--- a/src/shared/composables/modal.ts
+++ b/src/shared/composables/modal.ts
@@ -1,2 +1,2 @@
-export const [loginModal, toggleLogin] = useToggle()
-export const [signupModal, toggleSignup] = useToggle()
+export const [loginModal, toggleLogin] = useToggle()
+export const [signupModal, toggleSignup] = useToggle()
diff --git a/src/shared/layout/admin.vue b/src/shared/layout/admin.vue
index 7caa234..bdcbda3 100644
--- a/src/shared/layout/admin.vue
+++ b/src/shared/layout/admin.vue
@@ -1,11 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/shared/layout/default.vue b/src/shared/layout/default.vue
index 170ebaa..ebad828 100644
--- a/src/shared/layout/default.vue
+++ b/src/shared/layout/default.vue
@@ -1,24 +1,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/shared/monaco/index.vue b/src/shared/monaco/index.vue
index 20226d0..988291e 100644
--- a/src/shared/monaco/index.vue
+++ b/src/shared/monaco/index.vue
@@ -1,98 +1,98 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/src/shared/split/index.vue b/src/shared/split/index.vue
index e3819b6..1456ce3 100644
--- a/src/shared/split/index.vue
+++ b/src/shared/split/index.vue
@@ -1,141 +1,141 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/shims.d.ts b/src/shims.d.ts
index e7f10f1..0ed2b41 100644
--- a/src/shims.d.ts
+++ b/src/shims.d.ts
@@ -1,15 +1,18 @@
-import type * as Monaco from "monaco-editor"
-
-declare module "element-plus/dist/locale/zh-cn.mjs"
-
-declare module "*.md" {
- import type { ComponentOptions } from "vue"
- const Component: ComponentOptions
- export default Component
-}
-
-declare global {
- interface Window {
- monaco: Monaco
- }
-}
+declare module "element-plus/dist/locale/zh-cn.mjs"
+
+declare module "*.md" {
+ import type { ComponentOptions } from "vue"
+ const Component: ComponentOptions
+ export default Component
+}
+
+declare global {
+ let monaco: Monaco
+ interface Window {
+ monaco: Monaco
+ }
+}
+
+interface Window {
+ monaco: Monaco
+}
diff --git a/src/utils/judge.ts b/src/utils/judge.ts
index a952849..6aebfda 100644
--- a/src/utils/judge.ts
+++ b/src/utils/judge.ts
@@ -1,55 +1,55 @@
-import axios from "axios"
-import { DEAD_RESULTS } from "./constants"
-import { Code } from "./types"
-
-const http = axios.create({ baseURL: "https://judge0api.hyyz.izhai.net" })
-
-function encode(str: string) {
- return btoa(unescape(encodeURIComponent(str ?? "")))
-}
-
-function decode(bytes: string) {
- let escaped = escape(atob(bytes ?? ""))
- try {
- return decodeURIComponent(escaped)
- } catch (e) {
- return unescape(escaped)
- }
-}
-
-export async function createTestSubmission(code: Code, input: string) {
- const encodedCode = encode(code.value)
-
- if (encodedCode === DEAD_RESULTS[code.language].encoded) {
- return DEAD_RESULTS[code.language].result
- } else {
- const id = {
- C: 50,
- "C++": 54,
- Java: 62,
- Golang: 60,
- JavaScript: 63,
- Python2: 70,
- Python3: 71,
- }[code.language]
- let compilerOptions = ""
- if (id === 50) compilerOptions = "-lm" // 解决 GCC 的链接问题
- const payload = {
- source_code: encodedCode,
- language_id: id,
- stdin: encode(input),
- redirect_stderr_to_stdout: true,
- compiler_options: compilerOptions,
- }
- const response = await http.post("/submissions", payload, {
- params: { base64_encoded: true, wait: true },
- })
- const data = response.data
- return {
- status: data.status && data.status.id,
- output: [decode(data.compile_output), decode(data.stdout)]
- .join("\n")
- .trim(),
- }
- }
-}
+import axios from "axios"
+import { DEAD_RESULTS } from "./constants"
+import { Code } from "./types"
+
+const http = axios.create({ baseURL: "https://judge0api.hyyz.izhai.net" })
+
+function encode(str: string) {
+ return btoa(unescape(encodeURIComponent(str ?? "")))
+}
+
+function decode(bytes: string) {
+ let escaped = escape(atob(bytes ?? ""))
+ try {
+ return decodeURIComponent(escaped)
+ } catch (e) {
+ return unescape(escaped)
+ }
+}
+
+export async function createTestSubmission(code: Code, input: string) {
+ const encodedCode = encode(code.value)
+
+ if (encodedCode === DEAD_RESULTS[code.language].encoded) {
+ return DEAD_RESULTS[code.language].result
+ } else {
+ const id = {
+ C: 50,
+ "C++": 54,
+ Java: 62,
+ Golang: 60,
+ JavaScript: 63,
+ Python2: 70,
+ Python3: 71,
+ }[code.language]
+ let compilerOptions = ""
+ if (id === 50) compilerOptions = "-lm" // 解决 GCC 的链接问题
+ const payload = {
+ source_code: encodedCode,
+ language_id: id,
+ stdin: encode(input),
+ redirect_stderr_to_stdout: true,
+ compiler_options: compilerOptions,
+ }
+ const response = await http.post("/submissions", payload, {
+ params: { base64_encoded: true, wait: true },
+ })
+ const data = response.data
+ return {
+ status: data.status && data.status.id,
+ output: [decode(data.compile_output), decode(data.stdout)]
+ .join("\n")
+ .trim(),
+ }
+ }
+}
diff --git a/src/utils/types.ts b/src/utils/types.ts
index 18fa35d..93bdbb8 100644
--- a/src/utils/types.ts
+++ b/src/utils/types.ts
@@ -1,102 +1,115 @@
-export type LANGUAGE =
- | "C"
- | "C++"
- | "Python2"
- | "Python3"
- | "Java"
- | "JavaScript"
- | "Golang"
-
-export type SUBMISSION_RESULT = -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
-
-export interface Problem {
- _id: string
- id: number
- tags: string[]
- created_by: {
- id: number
- username: string
- real_name: null
- }
- template: { [key in LANGUAGE]?: string }
- title: string
- description: string
- input_description: string
- output_description: string
- samples: {
- input: string
- output: string
- }[]
- hint: string
- languages: Array
- create_time: Date
- last_update_time: null
- time_limit: number
- memory_limit: number
- io_mode: {
- input: string
- output: string
- io_mode: string
- }
- spj: boolean
- spj_language: null
- rule_type: string
- difficulty: "Low" | "Mid" | "High"
- source: string
- total_score: number
- submission_number: number
- accepted_number: number
- statistic_info: {}
- share_submission: boolean
- contest: null
- my_status: number
-}
-
-export interface Code {
- language: LANGUAGE
- value: string
-}
-
-export interface SubmitCodePayload {
- problem_id: number
- language: LANGUAGE
- code: string
- contest_id?: number
-}
-
-interface Info {
- err: string | null
- data: {
- error: number
- memory: number
- output: null
- result: SUBMISSION_RESULT
- signal: number
- cpu_time: number
- exit_code: number
- real_time: number
- test_case: string
- output_md5: string
- }[]
-}
-
-export interface Submission {
- id: string
- create_time: Date
- user_id: number
- username: string
- code: string
- result: SUBMISSION_RESULT
- info: Info
- language: string
- shared: boolean
- statistic_info: {
- score: number
- err_info: string
- }
- ip: string
- // TODO: 这里不知道是什么
- contest: null
- problem: number
- can_unshare: boolean
-}
+export type LANGUAGE =
+ | "C"
+ | "C++"
+ | "Python2"
+ | "Python3"
+ | "Java"
+ | "JavaScript"
+ | "Golang"
+
+export type SUBMISSION_RESULT = -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
+
+export type ProblemStatus = "passed" | "failed" | "not_test"
+
+export interface Problem {
+ _id: string
+ id: number
+ tags: string[]
+ created_by: {
+ id: number
+ username: string
+ real_name: null
+ }
+ template: { [key in LANGUAGE]?: string }
+ title: string
+ description: string
+ input_description: string
+ output_description: string
+ samples: {
+ input: string
+ output: string
+ }[]
+ hint: string
+ languages: Array
+ create_time: Date
+ last_update_time: null
+ time_limit: number
+ memory_limit: number
+ io_mode: {
+ input: string
+ output: string
+ io_mode: string
+ }
+ spj: boolean
+ spj_language: null
+ rule_type: string
+ difficulty: "Low" | "Mid" | "High"
+ source: string
+ total_score: number
+ submission_number: number
+ accepted_number: number
+ statistic_info: {}
+ share_submission: boolean
+ contest: null
+ my_status: number
+}
+
+export interface Code {
+ language: LANGUAGE
+ value: string
+}
+
+export interface SubmitCodePayload {
+ problem_id: number
+ language: LANGUAGE
+ code: string
+ contest_id?: number
+}
+
+interface Info {
+ err: string | null
+ data: {
+ error: number
+ memory: number
+ output: null
+ result: SUBMISSION_RESULT
+ signal: number
+ cpu_time: number
+ exit_code: number
+ real_time: number
+ test_case: string
+ output_md5: string
+ }[]
+}
+
+export interface Submission {
+ id: string
+ create_time: Date
+ user_id: number
+ username: string
+ code: string
+ result: SUBMISSION_RESULT
+ info: Info
+ language: string
+ shared: boolean
+ statistic_info: {
+ score: number
+ err_info: string
+ }
+ ip: string
+ // TODO: 这里不知道是什么
+ contest: null
+ problem: number
+ can_unshare: boolean
+}
+
+export interface SubmissionListPayload {
+ myself?: "1" | "0"
+ result?: SUBMISSION_RESULT
+ username?: string
+ contest_id?: string
+ problem_id?: string
+ page: number
+ limit: number
+ offset: number
+}