diff --git a/src/oj/problem/components/EditorWithTest.vue b/src/oj/problem/components/EditorForTest.vue
similarity index 55%
rename from src/oj/problem/components/EditorWithTest.vue
rename to src/oj/problem/components/EditorForTest.vue
index 4a2f6a4..bb99cff 100644
--- a/src/oj/problem/components/EditorWithTest.vue
+++ b/src/oj/problem/components/EditorForTest.vue
@@ -3,10 +3,13 @@ import { code, input, output } from "oj/composables/code"
import { problem } from "oj/composables/problem"
import { SOURCES } from "utils/constants"
import CodeEditor from "shared/components/CodeEditor.vue"
-import { isDesktop } from "shared/composables/breakpoints"
import storage from "utils/storage"
-import Form from "./Form.vue"
+import { createTestSubmission } from "utils/judge"
+import { LANGUAGE_SHOW_VALUE } from "utils/constants"
+import type { DropdownOption } from "naive-ui"
+import { copyToClipboard } from "utils/functions"
+const message = useMessage()
const route = useRoute()
const contestID = !!route.params.contestID ? route.params.contestID : null
@@ -24,10 +27,6 @@ onMounted(() => {
}
})
-const editorHeight = computed(() =>
- isDesktop.value ? "calc(100vh - 133px)" : "calc(100vh - 172px)",
-)
-
function changeCode(v: string) {
storage.set(storageKey.value, v)
}
@@ -43,23 +42,64 @@ function changeLanguage(v: string) {
problem.value!.template[code.language] || SOURCES[code.language]
}
}
+
+const copy = async () => {
+ const success = await copyToClipboard(code.value)
+ message[success ? "success" : "error"](`代码复制${success ? "成功" : "失败"}`)
+}
+
+const reset = () => {
+ code.value = problem.value!.template[code.language] || SOURCES[code.language]
+ storage.remove(storageKey.value)
+ message.success("代码重置成功")
+}
+
+const runCode = async () => {
+ const res = await createTestSubmission(code, input.value)
+ output.value = res.output
+}
+
+const languageOptions: DropdownOption[] = problem.value!.languages.map(
+ (it) => ({
+ label: () =>
+ h("div", { style: "display: flex; align-items: center;" }, [
+ h("img", {
+ src: `/${it}.svg`,
+ style: { width: "16px", height: "16px", marginRight: "8px" },
+ }),
+ LANGUAGE_SHOW_VALUE[it],
+ ]),
+ value: it,
+ }),
+)
-
-
+
-
+
+
+
+
+ 复制代码
+
+ 重置代码
+
+ 运行代码
+
+
+
+
import { copyToClipboard } from "utils/functions"
-import { code, input, output } from "oj/composables/code"
+import { code } from "oj/composables/code"
import { problem } from "oj/composables/problem"
import { injectSyncStatus } from "oj/composables/syncStatus"
import { SYNC_MESSAGES } from "shared/composables/sync"
import { LANGUAGE_SHOW_VALUE, SOURCES, STORAGE_KEY } from "utils/constants"
import { isDesktop, isMobile } from "shared/composables/breakpoints"
import { useUserStore } from "shared/store/user"
-import { createTestSubmission } from "utils/judge"
import storage from "utils/storage"
import { LANGUAGE } from "utils/types"
import Submit from "./Submit.vue"
@@ -16,12 +15,10 @@ import IconButton from "shared/components/IconButton.vue"
interface Props {
storageKey: string
- withTest?: boolean
isConnected?: boolean // WebSocket 实际的连接状态(已建立/未建立)
}
const props = withDefaults(defineProps(), {
- withTest: false,
isConnected: false,
})
@@ -68,7 +65,6 @@ const languageOptions: DropdownOption[] = problem.value!.languages.map(
}),
)
-// 代码操作相关
const copy = async () => {
const success = await copyToClipboard(code.value)
message[success ? "success" : "error"](`代码复制${success ? "成功" : "失败"}`)
@@ -85,12 +81,6 @@ const changeLanguage = (v: LANGUAGE) => {
emit("changeLanguage", v)
}
-const runCode = async () => {
- const res = await createTestSubmission(code, input.value)
- output.value = res.output
-}
-
-// 导航相关
const goTestCat = () => {
window.open(import.meta.env.PUBLIC_CODE_URL, "_blank")
}
@@ -107,7 +97,6 @@ const goEdit = () => {
window.open(router.resolve(url).href, "_blank")
}
-// 菜单处理
const handleMenuSelect = (key: string) => {
const actions: Record void> = {
reset,
@@ -117,7 +106,6 @@ const handleMenuSelect = (key: string) => {
actions[key]?.()
}
-// 协同编辑相关
const toggleSync = () => {
syncEnabled.value = !syncEnabled.value
emit("toggleSync", syncEnabled.value)
@@ -132,83 +120,74 @@ defineExpose({
-
-
- 重置代码
- 运行代码
-
+
-
-
+
+ 提交信息
+
-
- 提交信息
-
+
+ {{ isDesktop ? "统计信息" : "统计" }}
+
-
- {{ isDesktop ? "统计信息" : "统计" }}
-
+ 自测猫
- 自测猫
+
+ 操作
+
-
- 操作
-
+
+
-
-
-
+
+ {{ SYNC_MESSAGES.SYNCING_WITH(syncStatus.otherUser.value.name) }}
+
+
-
-
-
-
- {{ SYNC_MESSAGES.SYNCING_WITH(syncStatus.otherUser.value.name) }}
-
-
- {{ SYNC_MESSAGES.STUDENT_LEFT }}
-
-
+ type="warning"
+ >
+ {{ SYNC_MESSAGES.STUDENT_LEFT }}
+
-
+
-
-
diff --git a/src/oj/problem/detail.vue b/src/oj/problem/detail.vue
index b9e4c58..6b22270 100644
--- a/src/oj/problem/detail.vue
+++ b/src/oj/problem/detail.vue
@@ -15,8 +15,8 @@ const ProblemEditor = defineAsyncComponent(
const ContestEditor = defineAsyncComponent(
() => import("./components/ContestEditor.vue"),
)
-const EditorWithTest = defineAsyncComponent(
- () => import("./components/EditorWithTest.vue"),
+const EditorForTest = defineAsyncComponent(
+ () => import("./components/EditorForTest.vue"),
)
const ProblemContent = defineAsyncComponent(
() => import("./components/ProblemContent.vue"),
@@ -151,7 +151,7 @@ watch(isMobile, (value) => {
-
+