This commit is contained in:
2024-07-04 21:08:35 +08:00
parent 9c6c44e5e7
commit fdf0de9db1
49 changed files with 737 additions and 663 deletions

View File

@@ -1,11 +1,11 @@
<script lang="ts" setup>
import { SOURCES } from "utils/constants"
import { code } from "oj/composables/code"
import { isDesktop } from "~/shared/composables/breakpoints"
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 CodeEditor from "~/shared/components/CodeEditor.vue"
const route = useRoute()
const contestID = !!route.params.contestID ? route.params.contestID : null

View File

@@ -1,117 +1,117 @@
<script lang="ts" setup>
import { SOURCES } from "utils/constants"
import { code, input, output } from "oj/composables/code"
import { isDesktop } from "~/shared/composables/breakpoints"
import { problem } from "oj/composables/problem"
import storage from "~/utils/storage"
import Form from "./Form.vue"
import CodeEditor from "~/shared/components/CodeEditor.vue"
const route = useRoute()
const contestID = !!route.params.contestID ? route.params.contestID : null
const storageKey = computed(
() =>
`problem_${problem.value!._id}_contest_${contestID}_lang_${code.language}`,
)
onMounted(() => {
if (storage.get(storageKey.value)) {
code.value = storage.get(storageKey.value)
} else {
code.value =
problem.value!.template[code.language] || SOURCES[code.language]
}
})
const editorHeight = computed(() =>
isDesktop.value ? "calc(100vh - 133px)" : "calc(100vh - 172px)",
)
function changeCode(v: string) {
storage.set(storageKey.value, v)
}
function changeLanguage(v: string) {
if (
storage.get(storageKey.value) &&
storageKey.value.split("_").pop() === v
) {
code.value = storage.get(storageKey.value)
} else {
code.value =
problem.value!.template[code.language] || SOURCES[code.language]
}
}
</script>
<template>
<n-flex vertical>
<Form
:storage-key="storageKey"
@change-language="changeLanguage"
with-test
/>
<n-split direction="horizontal" :min="1 / 3" :max="4 / 5">
<template #1>
<CodeEditor
v-model:value="code.value"
@update:model-value="changeCode"
:language="code.language"
:height="editorHeight"
/>
</template>
<template #2>
<n-split
direction="vertical"
:default-size="1 / 3"
:min="1 / 5"
:max="3 / 5"
>
<template #1>
<div class="title">输入框</div>
<n-input
v-model:value="input"
type="textarea"
:bordered="false"
:resizable="false"
class="box"
/>
</template>
<template #2>
<div class="title">输出框</div>
<n-input
class="box output"
v-model:value="output"
placeholder=""
type="textarea"
:bordered="false"
:resizable="false"
readonly
/>
</template>
</n-split>
</template>
</n-split>
</n-flex>
</template>
<style scoped>
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
font-size: 16px;
}
.box {
padding-left: 10px;
box-sizing: border-box;
height: calc(100% - 40px);
font-size: 20px;
}
.output {
font-family: "Monaco";
}
</style>
<script lang="ts" setup>
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"
const route = useRoute()
const contestID = !!route.params.contestID ? route.params.contestID : null
const storageKey = computed(
() =>
`problem_${problem.value!._id}_contest_${contestID}_lang_${code.language}`,
)
onMounted(() => {
if (storage.get(storageKey.value)) {
code.value = storage.get(storageKey.value)
} else {
code.value =
problem.value!.template[code.language] || SOURCES[code.language]
}
})
const editorHeight = computed(() =>
isDesktop.value ? "calc(100vh - 133px)" : "calc(100vh - 172px)",
)
function changeCode(v: string) {
storage.set(storageKey.value, v)
}
function changeLanguage(v: string) {
if (
storage.get(storageKey.value) &&
storageKey.value.split("_").pop() === v
) {
code.value = storage.get(storageKey.value)
} else {
code.value =
problem.value!.template[code.language] || SOURCES[code.language]
}
}
</script>
<template>
<n-flex vertical>
<Form
:storage-key="storageKey"
@change-language="changeLanguage"
with-test
/>
<n-split direction="horizontal" :min="1 / 3" :max="4 / 5">
<template #1>
<CodeEditor
v-model:value="code.value"
@update:model-value="changeCode"
:language="code.language"
:height="editorHeight"
/>
</template>
<template #2>
<n-split
direction="vertical"
:default-size="1 / 3"
:min="1 / 5"
:max="3 / 5"
>
<template #1>
<div class="title">输入框</div>
<n-input
v-model:value="input"
type="textarea"
:bordered="false"
:resizable="false"
class="box"
/>
</template>
<template #2>
<div class="title">输出框</div>
<n-input
class="box output"
v-model:value="output"
placeholder=""
type="textarea"
:bordered="false"
:resizable="false"
readonly
/>
</template>
</n-split>
</template>
</n-split>
</n-flex>
</template>
<style scoped>
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
font-size: 16px;
}
.box {
padding-left: 10px;
box-sizing: border-box;
height: calc(100% - 40px);
font-size: 20px;
}
.output {
font-family: "Monaco";
}
</style>

View File

@@ -1,15 +1,14 @@
<script setup lang="ts">
import copyText from "copy-text-to-clipboard"
import { LANGUAGE_SHOW_VALUE, SOURCES } from "utils/constants"
import { code, input, output } from "oj/composables/code"
import { problem } from "oj/composables/problem"
import { LANGUAGE_SHOW_VALUE, SOURCES, STORAGE_KEY } from "utils/constants"
import { isDesktop, isMobile } from "~/shared/composables/breakpoints"
import { useUserStore } from "~/shared/store/user"
import Submit from "./Submit.vue"
import storage from "~/utils/storage"
import { STORAGE_KEY } from "utils/constants"
import { LANGUAGE } from "~/utils/types"
import { createTestSubmission } from "~/utils/judge"
import storage from "~/utils/storage"
import { LANGUAGE } from "~/utils/types"
import Submit from "./Submit.vue"
interface Props {
storageKey: string
@@ -114,7 +113,9 @@ function gotoTestCat() {
:options="options"
/>
<n-button v-if="withTest" @click="reset">重置代码</n-button>
<n-button v-if="withTest" type="primary" secondary @click="test">运行代码</n-button>
<n-button v-if="withTest" type="primary" secondary @click="test"
>运行代码</n-button
>
<n-flex align="center" v-if="!withTest">
<Submit />
<n-button v-if="isDesktop" @click="gotoTestCat">自测猫</n-button>

View File

@@ -112,11 +112,11 @@
</div>
</template>
<script lang="ts" setup>
import { problem } from "oj/composables/problem"
import { createComment, getComment, getCommentStatistics } from "~/oj/api"
import { DIFFICULTY } from "utils/constants"
import { useUserStore } from "~/shared/store/user"
import { Icon } from "@iconify/vue"
import { problem } from "oj/composables/problem"
import { DIFFICULTY } from "utils/constants"
import { createComment, getComment, getCommentStatistics } from "~/oj/api"
import { useUserStore } from "~/shared/store/user"
interface Props {
showStatistics?: boolean

View File

@@ -1,11 +1,11 @@
<script setup lang="ts">
import Copy from "~/shared/components/Copy.vue"
import { Icon } from "@iconify/vue"
import { useThemeVars } from "naive-ui"
import { code } from "oj/composables/code"
import { problem } from "oj/composables/problem"
import { Problem, ProblemStatus } from "utils/types"
import { createTestSubmission } from "utils/judge"
import { useThemeVars } from "naive-ui"
import { Icon } from "@iconify/vue"
import { Problem, ProblemStatus } from "utils/types"
import Copy from "~/shared/components/Copy.vue"
type Sample = Problem["samples"][number] & {
id: number

View File

@@ -1,8 +1,8 @@
<script setup lang="ts">
import { Pie } from "vue-chartjs"
import { problem } from "oj/composables/problem"
import { DIFFICULTY, JUDGE_STATUS } from "utils/constants"
import { getACRate, getTagColor, parseTime } from "utils/functions"
import { problem } from "oj/composables/problem"
import { Pie } from "vue-chartjs"
import { isDesktop } from "~/shared/composables/breakpoints"
const data = computed(() => {
@@ -16,7 +16,9 @@ const data = computed(() => {
}
return {
labels,
datasets: [{ data: Object.values(status), hoverOffset: 5, borderRadius: 10 }],
datasets: [
{ data: Object.values(status), hoverOffset: 5, borderRadius: 10 },
],
}
})

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useThemeVars } from "naive-ui"
import { Icon } from "@iconify/vue"
import { useThemeVars } from "naive-ui"
const theme = useThemeVars()
const props = defineProps<{

View File

@@ -1,13 +1,13 @@
<script lang="ts" setup>
import { useUserStore } from "~/shared/store/user"
import { Submission } from "~/utils/types"
import { parseTime } from "~/utils/functions"
import { LANGUAGE_SHOW_VALUE } from "~/utils/constants"
import { getSubmissions } from "~/oj/api"
import SubmissionResultTag from "~/shared/components/SubmissionResultTag.vue"
import Pagination from "~/shared/components/Pagination.vue"
import { NButton } from "naive-ui"
import { getSubmissions } from "~/oj/api"
import Pagination from "~/shared/components/Pagination.vue"
import SubmissionResultTag from "~/shared/components/SubmissionResultTag.vue"
import { useUserStore } from "~/shared/store/user"
import { LANGUAGE_SHOW_VALUE } from "~/utils/constants"
import { parseTime } from "~/utils/functions"
import { renderTableTitle } from "~/utils/renders"
import { Submission } from "~/utils/types"
const userStore = useUserStore()
const route = useRoute()

View File

@@ -1,16 +1,15 @@
<script setup lang="ts">
import { Icon } from "@iconify/vue"
import confetti from "canvas-confetti"
import { getComment, getSubmission, submitCode } from "oj/api"
import { code } from "oj/composables/code"
import { problem } from "oj/composables/problem"
import { isDesktop } from "~/shared/composables/breakpoints"
import { JUDGE_STATUS, SubmissionStatus } from "utils/constants"
import { submissionMemoryFormat, submissionTimeFormat } from "utils/functions"
import { Submission, SubmitCodePayload } from "utils/types"
import { getComment, getSubmission, submitCode } from "oj/api"
import SubmissionResultTag from "~/shared/components/SubmissionResultTag.vue"
import { isDesktop } from "~/shared/composables/breakpoints"
import { useUserStore } from "~/shared/store/user"
// @ts-ignore
import confetti from "canvas-confetti"
import { Icon } from "@iconify/vue"
const ProblemComment = defineAsyncComponent(
() => import("./ProblemComment.vue"),