add submissions.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
"start": "vite",
|
||||
"build": "vue-tsc && vite build",
|
||||
"preview": "vite preview",
|
||||
"fmt": "prettier --write src *.d.ts *.ts"
|
||||
"fmt": "prettier --write src *.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.0.10",
|
||||
|
||||
1
src/components.d.ts
vendored
1
src/components.d.ts
vendored
@@ -8,7 +8,6 @@ export {}
|
||||
declare module '@vue/runtime-core' {
|
||||
export interface GlobalComponents {
|
||||
ElAlert: typeof import('element-plus/es')['ElAlert']
|
||||
ElAside: typeof import('element-plus/es')['ElAside']
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
ElCard: typeof import('element-plus/es')['ElCard']
|
||||
ElCol: typeof import('element-plus/es')['ElCol']
|
||||
|
||||
@@ -1 +1 @@
|
||||
<template>loading...</template>
|
||||
<template>loading...</template>
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import Loading from "./components/Loading.vue"
|
||||
import Monaco from "../shared/monaco/index.vue"
|
||||
|
||||
const route = useRoute()
|
||||
const step = route.hash.replace("#step-", "") || "1"
|
||||
|
||||
const Md = defineAsyncComponent({
|
||||
loader: () => import(`./step-${step}/index.md`),
|
||||
loadingComponent: Loading,
|
||||
})
|
||||
|
||||
const code = ref("")
|
||||
|
||||
function change(value: string) {
|
||||
code.value = value
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<Md />
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<Monaco :value="code" @change="change" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
<script setup lang="ts">
|
||||
import Loading from "./components/Loading.vue"
|
||||
import Monaco from "../shared/monaco/index.vue"
|
||||
|
||||
const route = useRoute()
|
||||
const step = route.hash.replace("#step-", "") || "1"
|
||||
|
||||
const Md = defineAsyncComponent({
|
||||
loader: () => import(`./step-${step}/index.md`),
|
||||
loadingComponent: Loading,
|
||||
})
|
||||
|
||||
const code = ref("")
|
||||
|
||||
function change(value: string) {
|
||||
code.value = value
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<Md />
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<Monaco :value="code" @change="change" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# 我的是第一步骤
|
||||
|
||||
```c
|
||||
#include<stdio.h>
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
# 我的是第一步骤
|
||||
|
||||
```c
|
||||
#include<stdio.h>
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -2,7 +2,12 @@ import { useAxios } from "@vueuse/integrations/useAxios"
|
||||
import http from "utils/http"
|
||||
import { getACRate } from "utils/functions"
|
||||
import { DIFFICULTY } from "utils/constants"
|
||||
import { Problem, SubmitCodePayload, Submission } from "utils/types"
|
||||
import {
|
||||
Problem,
|
||||
SubmitCodePayload,
|
||||
Submission,
|
||||
SubmissionListPayload,
|
||||
} from "utils/types"
|
||||
|
||||
function filterResult(result: Problem) {
|
||||
const newResult: any = {
|
||||
@@ -14,11 +19,11 @@ function filterResult(result: Problem) {
|
||||
rate: getACRate(result.accepted_number, result.submission_number),
|
||||
}
|
||||
if (result.my_status === null || result.my_status === undefined) {
|
||||
newResult.status = "none"
|
||||
newResult.status = "not_test"
|
||||
} else if (result.my_status === 0) {
|
||||
newResult.status = "done"
|
||||
newResult.status = "passed"
|
||||
} else {
|
||||
newResult.status = "tried"
|
||||
newResult.status = "failed"
|
||||
}
|
||||
return newResult
|
||||
}
|
||||
@@ -78,15 +83,6 @@ export function submitCode(data: SubmitCodePayload) {
|
||||
return http.post("submission", data)
|
||||
}
|
||||
|
||||
export function listSubmissions(params: {
|
||||
myself: "1" | "0"
|
||||
result: string
|
||||
username: string
|
||||
page: number
|
||||
contest_id: string
|
||||
problem_id: string
|
||||
limit: number
|
||||
offset: number
|
||||
}) {
|
||||
return useAxios("submissions", { params }, http)
|
||||
export function listSubmissions(params: SubmissionListPayload) {
|
||||
return useAxios("submissions", { params }, http, { immediate: false })
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { JUDGE_STATUS } from "../../utils/constants"
|
||||
import { SUBMISSION_RESULT } from "../../utils/types"
|
||||
|
||||
interface Props {
|
||||
result: SUBMISSION_RESULT
|
||||
}
|
||||
defineProps<Props>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-tag :type="(JUDGE_STATUS[result]['type'] as any)" disable-transitions>
|
||||
{{ JUDGE_STATUS[result]["name"] }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
<script setup lang="ts">
|
||||
import { JUDGE_STATUS } from "../../utils/constants"
|
||||
import { SUBMISSION_RESULT } from "../../utils/types"
|
||||
|
||||
interface Props {
|
||||
result: SUBMISSION_RESULT
|
||||
}
|
||||
defineProps<Props>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-tag :type="JUDGE_STATUS[result]['type']" disable-transitions>
|
||||
{{ JUDGE_STATUS[result]["name"] }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<template>contest detail</template>
|
||||
|
||||
<style scoped></style>
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<template>contest detail</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,84 +1,84 @@
|
||||
<script lang="ts" setup>
|
||||
import { TabsPaneContext } from "element-plus"
|
||||
import { SOURCES } from "utils/constants"
|
||||
import { Problem } from "utils/types"
|
||||
import Monaco from "~/shared/Monaco/index.vue"
|
||||
import { useCodeStore } from "oj/store/code"
|
||||
|
||||
import SubmitPanel from "./SubmitPanel.vue"
|
||||
import TestcasePanel from "./TestcasePanel.vue"
|
||||
|
||||
interface Props {
|
||||
problem: Problem
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const { code } = useCodeStore()
|
||||
|
||||
code.language = props.problem.languages[0] || "C"
|
||||
code.value = props.problem.template[code.language] || SOURCES[code.language]
|
||||
|
||||
const tab = ref("test")
|
||||
const submitPanelRef = ref<{ submit: Function }>()
|
||||
|
||||
watch(() => code.language, reset)
|
||||
|
||||
function reset() {
|
||||
code.value = props.problem.template[code.language] || SOURCES[code.language]
|
||||
}
|
||||
|
||||
function change(value: string) {
|
||||
code.value = value
|
||||
}
|
||||
|
||||
function onTab(pane: TabsPaneContext) {
|
||||
if (pane.paneName === "submit") {
|
||||
submitPanelRef && submitPanelRef.value!.submit()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-form inline>
|
||||
<el-form-item label="语言" label-width="60">
|
||||
<el-select v-model="code.language" class="language">
|
||||
<el-option v-for="item in problem.languages" :key="item" :value="item">
|
||||
<img class="logo" :src="`/${item}.svg`" alt="logo" />
|
||||
<span>{{ item }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
<el-button @click="$router.push(`/status?problem=${problem.id}`)">
|
||||
提交信息
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<Monaco
|
||||
class="editor"
|
||||
:language="code.language"
|
||||
:value="code.value"
|
||||
@change="change"
|
||||
height="calc(100vh - 621px)"
|
||||
/>
|
||||
<el-tabs type="border-card" @tab-click="onTab" v-model="tab">
|
||||
<TestcasePanel />
|
||||
<SubmitPanel ref="submitPanelRef" />
|
||||
</el-tabs>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.language {
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
.editor {
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 12px;
|
||||
}
|
||||
</style>
|
||||
<script lang="ts" setup>
|
||||
import { TabsPaneContext } from "element-plus"
|
||||
import { SOURCES } from "utils/constants"
|
||||
import { Problem } from "utils/types"
|
||||
import Monaco from "~/shared/Monaco/index.vue"
|
||||
import { useCodeStore } from "oj/store/code"
|
||||
|
||||
const SubmitPanel = defineAsyncComponent(() => import("./SubmitPanel.vue"))
|
||||
const TestcasePanel = defineAsyncComponent(() => import("./TestcasePanel.vue"))
|
||||
|
||||
interface Props {
|
||||
problem: Problem
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const { code } = useCodeStore()
|
||||
|
||||
code.language = props.problem.languages[0] || "C"
|
||||
code.value = props.problem.template[code.language] || SOURCES[code.language]
|
||||
|
||||
const tab = ref("test")
|
||||
const submitPanelRef = ref<{ submit: Function }>()
|
||||
|
||||
watch(() => code.language, reset)
|
||||
|
||||
function reset() {
|
||||
code.value = props.problem.template[code.language] || SOURCES[code.language]
|
||||
}
|
||||
|
||||
function change(value: string) {
|
||||
code.value = value
|
||||
}
|
||||
|
||||
function onTab(pane: TabsPaneContext) {
|
||||
if (pane.paneName === "submit") {
|
||||
submitPanelRef && submitPanelRef.value!.submit()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-form inline>
|
||||
<el-form-item label="语言" label-width="60">
|
||||
<el-select v-model="code.language" class="language">
|
||||
<el-option v-for="item in problem.languages" :key="item" :value="item">
|
||||
<img class="logo" :src="`/${item}.svg`" alt="logo" />
|
||||
<span>{{ item }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
<el-button @click="$router.push(`/status?problem=${problem._id}`)">
|
||||
提交信息
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<Monaco
|
||||
class="editor"
|
||||
:language="code.language"
|
||||
:value="code.value"
|
||||
@change="change"
|
||||
height="calc(100vh - 621px)"
|
||||
/>
|
||||
<el-tabs type="border-card" @tab-click="onTab" v-model="tab">
|
||||
<TestcasePanel />
|
||||
<SubmitPanel ref="submitPanelRef" />
|
||||
</el-tabs>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.language {
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
.editor {
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,180 +1,180 @@
|
||||
<script setup lang="ts">
|
||||
import { Flag, CloseBold, Select, CopyDocument } from "@element-plus/icons-vue"
|
||||
import copy from "copy-text-to-clipboard"
|
||||
import { useCodeStore } from "oj/store/code"
|
||||
import { SOURCES } from "utils/constants"
|
||||
import { Problem } from "utils/types"
|
||||
import { createTestSubmission } from "utils/judge"
|
||||
import { submissionExists } from "oj/api"
|
||||
|
||||
interface Props {
|
||||
problem: Problem
|
||||
}
|
||||
type Sample = Problem["samples"][number] & {
|
||||
id: number
|
||||
msg: string
|
||||
status: "passed" | "failed" | "not_test"
|
||||
loading: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const route = useRoute()
|
||||
const contestID = <string>route.params.contestID
|
||||
const { data: hasSolved, execute } = submissionExists(props.problem.id)
|
||||
if (contestID) {
|
||||
execute()
|
||||
}
|
||||
const samples = ref<Sample[]>(
|
||||
props.problem.samples.map((sample, index) => ({
|
||||
...sample,
|
||||
id: index,
|
||||
msg: "",
|
||||
status: "not_test",
|
||||
loading: false,
|
||||
}))
|
||||
)
|
||||
const { code } = useCodeStore()
|
||||
|
||||
const disabled = computed(
|
||||
() =>
|
||||
!!(
|
||||
code.value.trim() === "" ||
|
||||
code.value === props.problem.template[code.language] ||
|
||||
code.value === SOURCES[code.language]
|
||||
)
|
||||
)
|
||||
async function test(sample: Sample, index: number) {
|
||||
samples.value = samples.value.map((sample) => {
|
||||
if (sample.id === index) {
|
||||
sample.loading = true
|
||||
}
|
||||
return sample
|
||||
})
|
||||
const res = await createTestSubmission(code, sample.input)
|
||||
samples.value = samples.value.map((sample) => {
|
||||
if (sample.id === index) {
|
||||
const status =
|
||||
res.status === 3 && res.output.trim() === sample.output
|
||||
? "passed"
|
||||
: "failed"
|
||||
return {
|
||||
...sample,
|
||||
msg: res.output,
|
||||
status: status,
|
||||
loading: false,
|
||||
}
|
||||
} else {
|
||||
return sample
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const icon = (status: Sample["status"]) =>
|
||||
({
|
||||
not_test: Flag,
|
||||
failed: CloseBold,
|
||||
passed: Select,
|
||||
}[status])
|
||||
const type = (status: Sample["status"]) =>
|
||||
({
|
||||
not_test: "warning",
|
||||
failed: "danger",
|
||||
passed: "success",
|
||||
}[status])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-alert
|
||||
v-if="problem.my_status === 0 || (contestID && hasSolved)"
|
||||
type="success"
|
||||
:closable="false"
|
||||
center
|
||||
title="🎉 本 题 已 经 被 你 解 决 啦"
|
||||
effect="dark"
|
||||
>
|
||||
</el-alert>
|
||||
|
||||
<h1>{{ problem.title }}</h1>
|
||||
<p class="title">描述</p>
|
||||
<div class="content" v-html="problem.description"></div>
|
||||
|
||||
<p class="title">输入</p>
|
||||
<div class="content" v-html="problem.input_description"></div>
|
||||
|
||||
<p class="title">输出</p>
|
||||
<div class="content" v-html="problem.output_description"></div>
|
||||
|
||||
<div v-if="problem.hint">
|
||||
<p class="title">提示</p>
|
||||
<el-card shadow="never">
|
||||
<div class="content" v-html="problem.hint"></div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<div v-for="(sample, index) of samples" :key="index">
|
||||
<el-space>
|
||||
<p class="title testcaseTitle">测试用例 {{ index + 1 }}</p>
|
||||
<el-button
|
||||
:icon="icon(sample.status)"
|
||||
:type="type(sample.status)"
|
||||
:disabled="disabled"
|
||||
:loading="sample.loading"
|
||||
circle
|
||||
@click="test(sample, index)"
|
||||
></el-button>
|
||||
</el-space>
|
||||
<el-descriptions border direction="vertical" :column="2">
|
||||
<el-descriptions-item width="50%">
|
||||
<template #label>
|
||||
<el-space>
|
||||
<span>输入</span>
|
||||
<el-icon @click="copy(sample.input)"><CopyDocument /> </el-icon>
|
||||
</el-space>
|
||||
</template>
|
||||
<div class="testcase">{{ sample.input }}</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item width="50%">
|
||||
<template #label>
|
||||
<el-space>
|
||||
<span>输出</span>
|
||||
<el-icon @click="copy(sample.output)"><CopyDocument /> </el-icon>
|
||||
</el-space>
|
||||
</template>
|
||||
<div class="testcase">{{ sample.output }}</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="运行结果" v-if="sample.status === 'failed'">
|
||||
<div class="testcase">{{ sample.msg }}</div>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
<div v-if="problem.source">
|
||||
<p class="title">来源</p>
|
||||
<div class="content" v-html="problem.source"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.title {
|
||||
font-size: 20px;
|
||||
margin: 24px 0 16px 0;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.testcaseTitle {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.content {
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.testcase {
|
||||
white-space: pre;
|
||||
}
|
||||
</style>
|
||||
<script setup lang="ts">
|
||||
import { Flag, CloseBold, Select, CopyDocument } from "@element-plus/icons-vue"
|
||||
import copy from "copy-text-to-clipboard"
|
||||
import { useCodeStore } from "oj/store/code"
|
||||
import { SOURCES } from "utils/constants"
|
||||
import { Problem, ProblemStatus } from "utils/types"
|
||||
import { createTestSubmission } from "utils/judge"
|
||||
import { submissionExists } from "oj/api"
|
||||
|
||||
interface Props {
|
||||
problem: Problem
|
||||
}
|
||||
type Sample = Problem["samples"][number] & {
|
||||
id: number
|
||||
msg: string
|
||||
status: ProblemStatus
|
||||
loading: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const route = useRoute()
|
||||
const contestID = <string>route.params.contestID
|
||||
const { data: hasSolved, execute } = submissionExists(props.problem.id)
|
||||
if (contestID) {
|
||||
execute()
|
||||
}
|
||||
const samples = ref<Sample[]>(
|
||||
props.problem.samples.map((sample, index) => ({
|
||||
...sample,
|
||||
id: index,
|
||||
msg: "",
|
||||
status: "not_test",
|
||||
loading: false,
|
||||
}))
|
||||
)
|
||||
const { code } = useCodeStore()
|
||||
|
||||
const disabled = computed(
|
||||
() =>
|
||||
!!(
|
||||
code.value.trim() === "" ||
|
||||
code.value === props.problem.template[code.language] ||
|
||||
code.value === SOURCES[code.language]
|
||||
)
|
||||
)
|
||||
async function test(sample: Sample, index: number) {
|
||||
samples.value = samples.value.map((sample) => {
|
||||
if (sample.id === index) {
|
||||
sample.loading = true
|
||||
}
|
||||
return sample
|
||||
})
|
||||
const res = await createTestSubmission(code, sample.input)
|
||||
samples.value = samples.value.map((sample) => {
|
||||
if (sample.id === index) {
|
||||
const status =
|
||||
res.status === 3 && res.output.trim() === sample.output
|
||||
? "passed"
|
||||
: "failed"
|
||||
return {
|
||||
...sample,
|
||||
msg: res.output,
|
||||
status: status,
|
||||
loading: false,
|
||||
}
|
||||
} else {
|
||||
return sample
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const icon = (status: Sample["status"]) =>
|
||||
({
|
||||
not_test: Flag,
|
||||
failed: CloseBold,
|
||||
passed: Select,
|
||||
}[status])
|
||||
const type = (status: Sample["status"]) =>
|
||||
({
|
||||
not_test: "warning",
|
||||
failed: "danger",
|
||||
passed: "success",
|
||||
}[status])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-alert
|
||||
v-if="problem.my_status === 0 || (contestID && hasSolved)"
|
||||
type="success"
|
||||
:closable="false"
|
||||
center
|
||||
title="🎉 本 题 已 经 被 你 解 决 啦"
|
||||
effect="dark"
|
||||
>
|
||||
</el-alert>
|
||||
|
||||
<h1>{{ problem.title }}</h1>
|
||||
<p class="title">描述</p>
|
||||
<div class="content" v-html="problem.description"></div>
|
||||
|
||||
<p class="title">输入</p>
|
||||
<div class="content" v-html="problem.input_description"></div>
|
||||
|
||||
<p class="title">输出</p>
|
||||
<div class="content" v-html="problem.output_description"></div>
|
||||
|
||||
<div v-if="problem.hint">
|
||||
<p class="title">提示</p>
|
||||
<el-card shadow="never">
|
||||
<div class="content" v-html="problem.hint"></div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<div v-for="(sample, index) of samples" :key="index">
|
||||
<el-space>
|
||||
<p class="title testcaseTitle">测试用例 {{ index + 1 }}</p>
|
||||
<el-button
|
||||
:icon="icon(sample.status)"
|
||||
:type="type(sample.status)"
|
||||
:disabled="disabled"
|
||||
:loading="sample.loading"
|
||||
circle
|
||||
@click="test(sample, index)"
|
||||
></el-button>
|
||||
</el-space>
|
||||
<el-descriptions border direction="vertical" :column="2">
|
||||
<el-descriptions-item width="50%">
|
||||
<template #label>
|
||||
<el-space>
|
||||
<span>输入</span>
|
||||
<el-icon @click="copy(sample.input)"><CopyDocument /> </el-icon>
|
||||
</el-space>
|
||||
</template>
|
||||
<div class="testcase">{{ sample.input }}</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item width="50%">
|
||||
<template #label>
|
||||
<el-space>
|
||||
<span>输出</span>
|
||||
<el-icon @click="copy(sample.output)"><CopyDocument /> </el-icon>
|
||||
</el-space>
|
||||
</template>
|
||||
<div class="testcase">{{ sample.output }}</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="运行结果" v-if="sample.status === 'failed'">
|
||||
<div class="testcase">{{ sample.msg }}</div>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
<div v-if="problem.source">
|
||||
<p class="title">来源</p>
|
||||
<div class="content" v-html="problem.source"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.title {
|
||||
font-size: 20px;
|
||||
margin: 24px 0 16px 0;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.testcaseTitle {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.content {
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.testcase {
|
||||
white-space: pre;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,63 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
import { DIFFICULTY } from "utils/constants"
|
||||
import { getACRate, getTagColor, parseTime } from "utils/functions"
|
||||
import { isDesktop } from "~/shared/composables/breakpoints"
|
||||
import { Problem } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
problem: Problem
|
||||
}
|
||||
defineProps<Props>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-descriptions border :column="isDesktop ? 3 : 1">
|
||||
<el-descriptions-item label="编号">
|
||||
{{ problem._id }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="出题人">
|
||||
{{ problem.created_by.username }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ parseTime(problem.create_time) }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="时间限制">
|
||||
{{ problem.time_limit }}毫秒
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="内存限制">
|
||||
{{ problem.memory_limit }}MB
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="难度">
|
||||
<el-tag
|
||||
disable-transitions
|
||||
:type="(getTagColor(problem.difficulty) as any)"
|
||||
>
|
||||
{{ DIFFICULTY[problem.difficulty] }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="提交正确">
|
||||
{{ problem.accepted_number }}次
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="提交错误">
|
||||
{{ problem.submission_number - problem.accepted_number }}次
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="正确率">
|
||||
{{ getACRate(problem.accepted_number, problem.submission_number) }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item :span="3" label="标签">
|
||||
<el-space>
|
||||
<el-tag
|
||||
disable-transitions
|
||||
type="info"
|
||||
v-for="tag in problem.tags"
|
||||
:key="tag"
|
||||
>
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</el-space>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { DIFFICULTY } from "utils/constants"
|
||||
import { getACRate, getTagColor, parseTime } from "utils/functions"
|
||||
import { isDesktop } from "~/shared/composables/breakpoints"
|
||||
import { Problem } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
problem: Problem
|
||||
}
|
||||
defineProps<Props>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-descriptions border :column="isDesktop ? 3 : 1">
|
||||
<el-descriptions-item label="编号">
|
||||
{{ problem._id }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="出题人">
|
||||
{{ problem.created_by.username }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ parseTime(problem.create_time) }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="时间限制">
|
||||
{{ problem.time_limit }}毫秒
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="内存限制">
|
||||
{{ problem.memory_limit }}MB
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="难度">
|
||||
<el-tag disable-transitions :type="getTagColor(problem.difficulty)">
|
||||
{{ DIFFICULTY[problem.difficulty] }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="提交正确">
|
||||
{{ problem.accepted_number }}次
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="提交错误">
|
||||
{{ problem.submission_number - problem.accepted_number }}次
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="正确率">
|
||||
{{ getACRate(problem.accepted_number, problem.submission_number) }}
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item :span="3" label="标签">
|
||||
<el-space>
|
||||
<el-tag
|
||||
disable-transitions
|
||||
type="info"
|
||||
v-for="tag in problem.tags"
|
||||
:key="tag"
|
||||
>
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</el-space>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</template>
|
||||
|
||||
@@ -1,231 +1,231 @@
|
||||
<script setup lang="ts">
|
||||
import party from "party-js"
|
||||
import { Ref } from "vue"
|
||||
import { SOURCES, JUDGE_STATUS, SubmissionStatus } from "utils/constants"
|
||||
import { submissionMemoryFormat, submissionTimeFormat } from "utils/functions"
|
||||
import { Problem, Submission, SubmitCodePayload } from "utils/types"
|
||||
import { getSubmission, submitCode } from "oj/api"
|
||||
import { useCodeStore } from "oj/store/code"
|
||||
|
||||
import SubmissionResultTag from "../../components/SubmissionResultTag.vue"
|
||||
|
||||
const problem = inject<Ref<Problem>>("problem")
|
||||
const { code } = useCodeStore()
|
||||
|
||||
const route = useRoute()
|
||||
const contestID = <string>route.params.contestID ?? ""
|
||||
|
||||
const submissionId = ref("")
|
||||
const submission = ref<Submission | null>(null)
|
||||
|
||||
const [submitted] = useToggle()
|
||||
|
||||
const { start: submitPending, isPending } = useTimeout(5000, {
|
||||
controls: true,
|
||||
immediate: false,
|
||||
})
|
||||
|
||||
const { start: fetchSubmission } = useTimeoutFn(
|
||||
async () => {
|
||||
const res = await getSubmission(submissionId.value)
|
||||
submission.value = res.data
|
||||
const result = submission.value.result
|
||||
if (
|
||||
result === SubmissionStatus.judging ||
|
||||
result === SubmissionStatus.pending
|
||||
) {
|
||||
fetchSubmission()
|
||||
} else {
|
||||
submitted.value = false
|
||||
}
|
||||
},
|
||||
2000,
|
||||
{ immediate: false }
|
||||
)
|
||||
|
||||
const judging = computed(
|
||||
() =>
|
||||
!!(submission.value && submission.value.result === SubmissionStatus.judging)
|
||||
)
|
||||
|
||||
const pending = computed(
|
||||
() =>
|
||||
!!(submission.value && submission.value.result === SubmissionStatus.pending)
|
||||
)
|
||||
|
||||
const submitting = computed(
|
||||
() =>
|
||||
!!(
|
||||
submission.value &&
|
||||
submission.value.result === SubmissionStatus.submitting
|
||||
)
|
||||
)
|
||||
|
||||
const submitDisabled = computed(() => {
|
||||
const value = code.value
|
||||
if (
|
||||
value.trim() === "" ||
|
||||
value === problem!.value.template[code.language] ||
|
||||
value === SOURCES[code.language]
|
||||
) {
|
||||
return true
|
||||
}
|
||||
if (judging.value || pending.value || submitting.value) {
|
||||
return true
|
||||
}
|
||||
if (submitted.value) {
|
||||
return true
|
||||
}
|
||||
if (isPending.value) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
const submitLabel = computed(() => {
|
||||
if (submitting.value) {
|
||||
return "正在提交"
|
||||
}
|
||||
if (judging.value || pending.value) {
|
||||
return "正在评分"
|
||||
}
|
||||
if (isPending.value) {
|
||||
return "运行结果"
|
||||
}
|
||||
return "点击提交"
|
||||
})
|
||||
|
||||
const msg = computed(() => {
|
||||
let msg = ""
|
||||
const result = submission.value && submission.value.result
|
||||
if (
|
||||
result === SubmissionStatus.compile_error ||
|
||||
result === SubmissionStatus.runtime_error
|
||||
) {
|
||||
msg += "请仔细检查,看看代码的格式是不是写错了!\n\n"
|
||||
}
|
||||
if (
|
||||
submission.value &&
|
||||
submission.value.statistic_info &&
|
||||
submission.value.statistic_info.err_info
|
||||
) {
|
||||
msg += submission.value.statistic_info.err_info
|
||||
}
|
||||
return msg
|
||||
})
|
||||
|
||||
const infoTable = computed(() => {
|
||||
if (
|
||||
submission.value &&
|
||||
submission.value.result !== SubmissionStatus.accepted &&
|
||||
submission.value.result !== SubmissionStatus.compile_error &&
|
||||
submission.value.result !== SubmissionStatus.runtime_error &&
|
||||
submission.value.info &&
|
||||
submission.value.info.data &&
|
||||
submission.value.info.data.length
|
||||
) {
|
||||
const data = submission.value.info.data
|
||||
if (data.some((item) => item.result === 0)) {
|
||||
return submission.value.info.data
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
})
|
||||
|
||||
async function submit() {
|
||||
const data: SubmitCodePayload = {
|
||||
problem_id: problem!.value.id,
|
||||
language: code.language,
|
||||
code: code.value,
|
||||
}
|
||||
if (contestID) {
|
||||
data.contest_id = parseInt(contestID)
|
||||
}
|
||||
submission.value = { result: 9 } as Submission
|
||||
const res = await submitCode(data)
|
||||
submissionId.value = res.data.submission_id
|
||||
// 防止重复提交
|
||||
submitPending()
|
||||
submitted.value = true
|
||||
// 查询结果
|
||||
fetchSubmission()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => submission?.value?.result,
|
||||
(result) => {
|
||||
if (result === SubmissionStatus.accepted) {
|
||||
party.confetti(document.body, {
|
||||
count: party.variation.range(200, 400),
|
||||
size: party.variation.skew(2, 0.3),
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
defineExpose({ submit })
|
||||
</script>
|
||||
<template>
|
||||
<el-tab-pane :disabled="submitDisabled" name="submit">
|
||||
<template #label>
|
||||
<el-space :size="2">
|
||||
<el-icon>
|
||||
<i-ep-loading v-if="judging || pending || submitting" />
|
||||
<i-ep-bell v-else-if="isPending" />
|
||||
<i-ep-caret-right v-else />
|
||||
</el-icon>
|
||||
<span>{{ submitLabel }}</span>
|
||||
</el-space>
|
||||
</template>
|
||||
<div class="panel">
|
||||
<el-alert
|
||||
v-if="submission"
|
||||
:closable="false"
|
||||
:type="(JUDGE_STATUS[submission.result]['alertType'] as any)"
|
||||
:title="JUDGE_STATUS[submission.result]['name']"
|
||||
>
|
||||
</el-alert>
|
||||
<el-scrollbar v-if="msg" height="354" class="result">
|
||||
<div>{{ msg }}</div>
|
||||
</el-scrollbar>
|
||||
<el-table
|
||||
v-if="infoTable.length"
|
||||
max-height="354"
|
||||
:data="infoTable"
|
||||
stripe
|
||||
>
|
||||
<el-table-column prop="test_case" label="测试用例" align="center" />
|
||||
<el-table-column label="测试状态" width="120" align="center">
|
||||
<template #default="scope">
|
||||
<SubmissionResultTag v-if="scope.row" :result="scope.row.result" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="占用内存" align="center">
|
||||
<template #default="scope">
|
||||
{{ submissionMemoryFormat(scope.row.memory) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="执行耗时" align="center">
|
||||
<template #default="scope">
|
||||
{{ submissionTimeFormat(scope.row.real_time) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="signal" label="信号" align="center" />
|
||||
</el-table>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</template>
|
||||
<style scoped>
|
||||
.panel {
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
.result {
|
||||
margin-top: 12px;
|
||||
white-space: pre;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
<script setup lang="ts">
|
||||
import party from "party-js"
|
||||
import { Ref } from "vue"
|
||||
import { SOURCES, JUDGE_STATUS, SubmissionStatus } from "utils/constants"
|
||||
import { submissionMemoryFormat, submissionTimeFormat } from "utils/functions"
|
||||
import { Problem, Submission, SubmitCodePayload } from "utils/types"
|
||||
import { getSubmission, submitCode } from "oj/api"
|
||||
import { useCodeStore } from "oj/store/code"
|
||||
|
||||
import SubmissionResultTag from "../../components/SubmissionResultTag.vue"
|
||||
|
||||
const problem = inject<Ref<Problem>>("problem")
|
||||
const { code } = useCodeStore()
|
||||
|
||||
const route = useRoute()
|
||||
const contestID = <string>route.params.contestID ?? ""
|
||||
|
||||
const submissionId = ref("")
|
||||
const submission = ref<Submission | null>(null)
|
||||
|
||||
const [submitted] = useToggle()
|
||||
|
||||
const { start: submitPending, isPending } = useTimeout(5000, {
|
||||
controls: true,
|
||||
immediate: false,
|
||||
})
|
||||
|
||||
const { start: fetchSubmission } = useTimeoutFn(
|
||||
async () => {
|
||||
const res = await getSubmission(submissionId.value)
|
||||
submission.value = res.data
|
||||
const result = submission.value.result
|
||||
if (
|
||||
result === SubmissionStatus.judging ||
|
||||
result === SubmissionStatus.pending
|
||||
) {
|
||||
fetchSubmission()
|
||||
} else {
|
||||
submitted.value = false
|
||||
}
|
||||
},
|
||||
2000,
|
||||
{ immediate: false }
|
||||
)
|
||||
|
||||
const judging = computed(
|
||||
() =>
|
||||
!!(submission.value && submission.value.result === SubmissionStatus.judging)
|
||||
)
|
||||
|
||||
const pending = computed(
|
||||
() =>
|
||||
!!(submission.value && submission.value.result === SubmissionStatus.pending)
|
||||
)
|
||||
|
||||
const submitting = computed(
|
||||
() =>
|
||||
!!(
|
||||
submission.value &&
|
||||
submission.value.result === SubmissionStatus.submitting
|
||||
)
|
||||
)
|
||||
|
||||
const submitDisabled = computed(() => {
|
||||
const value = code.value
|
||||
if (
|
||||
value.trim() === "" ||
|
||||
value === problem!.value.template[code.language] ||
|
||||
value === SOURCES[code.language]
|
||||
) {
|
||||
return true
|
||||
}
|
||||
if (judging.value || pending.value || submitting.value) {
|
||||
return true
|
||||
}
|
||||
if (submitted.value) {
|
||||
return true
|
||||
}
|
||||
if (isPending.value) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
const submitLabel = computed(() => {
|
||||
if (submitting.value) {
|
||||
return "正在提交"
|
||||
}
|
||||
if (judging.value || pending.value) {
|
||||
return "正在评分"
|
||||
}
|
||||
if (isPending.value) {
|
||||
return "运行结果"
|
||||
}
|
||||
return "点击提交"
|
||||
})
|
||||
|
||||
const msg = computed(() => {
|
||||
let msg = ""
|
||||
const result = submission.value && submission.value.result
|
||||
if (
|
||||
result === SubmissionStatus.compile_error ||
|
||||
result === SubmissionStatus.runtime_error
|
||||
) {
|
||||
msg += "请仔细检查,看看代码的格式是不是写错了!\n\n"
|
||||
}
|
||||
if (
|
||||
submission.value &&
|
||||
submission.value.statistic_info &&
|
||||
submission.value.statistic_info.err_info
|
||||
) {
|
||||
msg += submission.value.statistic_info.err_info
|
||||
}
|
||||
return msg
|
||||
})
|
||||
|
||||
const infoTable = computed(() => {
|
||||
if (
|
||||
submission.value &&
|
||||
submission.value.result !== SubmissionStatus.accepted &&
|
||||
submission.value.result !== SubmissionStatus.compile_error &&
|
||||
submission.value.result !== SubmissionStatus.runtime_error &&
|
||||
submission.value.info &&
|
||||
submission.value.info.data &&
|
||||
submission.value.info.data.length
|
||||
) {
|
||||
const data = submission.value.info.data
|
||||
if (data.some((item) => item.result === 0)) {
|
||||
return submission.value.info.data
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
})
|
||||
|
||||
async function submit() {
|
||||
const data: SubmitCodePayload = {
|
||||
problem_id: problem!.value.id,
|
||||
language: code.language,
|
||||
code: code.value,
|
||||
}
|
||||
if (contestID) {
|
||||
data.contest_id = parseInt(contestID)
|
||||
}
|
||||
submission.value = { result: 9 } as Submission
|
||||
const res = await submitCode(data)
|
||||
submissionId.value = res.data.submission_id
|
||||
// 防止重复提交
|
||||
submitPending()
|
||||
submitted.value = true
|
||||
// 查询结果
|
||||
fetchSubmission()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => submission?.value?.result,
|
||||
(result) => {
|
||||
if (result === SubmissionStatus.accepted) {
|
||||
party.confetti(document.body, {
|
||||
count: party.variation.range(200, 400),
|
||||
size: party.variation.skew(2, 0.3),
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
defineExpose({ submit })
|
||||
</script>
|
||||
<template>
|
||||
<el-tab-pane :disabled="submitDisabled" name="submit">
|
||||
<template #label>
|
||||
<el-space :size="2">
|
||||
<el-icon>
|
||||
<i-ep-loading v-if="judging || pending || submitting" />
|
||||
<i-ep-bell v-else-if="isPending" />
|
||||
<i-ep-caret-right v-else />
|
||||
</el-icon>
|
||||
<span>{{ submitLabel }}</span>
|
||||
</el-space>
|
||||
</template>
|
||||
<div class="panel">
|
||||
<el-alert
|
||||
v-if="submission"
|
||||
:closable="false"
|
||||
:type="JUDGE_STATUS[submission.result]['alertType']"
|
||||
:title="JUDGE_STATUS[submission.result]['name']"
|
||||
>
|
||||
</el-alert>
|
||||
<el-scrollbar v-if="msg" height="354" class="result">
|
||||
<div>{{ msg }}</div>
|
||||
</el-scrollbar>
|
||||
<el-table
|
||||
v-if="infoTable.length"
|
||||
max-height="354"
|
||||
:data="infoTable"
|
||||
stripe
|
||||
>
|
||||
<el-table-column prop="test_case" label="测试用例" align="center" />
|
||||
<el-table-column label="测试状态" width="120" align="center">
|
||||
<template #default="scope">
|
||||
<SubmissionResultTag v-if="scope.row" :result="scope.row.result" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="占用内存" align="center">
|
||||
<template #default="scope">
|
||||
{{ submissionMemoryFormat(scope.row.memory) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="执行耗时" align="center">
|
||||
<template #default="scope">
|
||||
{{ submissionTimeFormat(scope.row.real_time) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="signal" label="信号" align="center" />
|
||||
</el-table>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</template>
|
||||
<style scoped>
|
||||
.panel {
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
.result {
|
||||
margin-top: 12px;
|
||||
white-space: pre;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
<script setup lang="ts">
|
||||
import { createTestSubmission } from "utils/judge"
|
||||
import { useCodeStore } from "oj/store/code"
|
||||
|
||||
const input = ref("")
|
||||
const result = ref("")
|
||||
const { code } = useCodeStore()
|
||||
|
||||
async function submit() {
|
||||
const res = await createTestSubmission(code, input.value)
|
||||
result.value = res.output
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-tab-pane label="测试面板" name="test">
|
||||
<div class="panel">
|
||||
<el-form inline>
|
||||
<el-form-item label="输入">
|
||||
<el-input type="textarea" autosize v-model="input" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="submit">运行</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-scrollbar height="345">
|
||||
<div class="msg">{{ result }}</div>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.panel {
|
||||
height: 400px;
|
||||
}
|
||||
.msg {
|
||||
white-space: pre;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
<script setup lang="ts">
|
||||
import { createTestSubmission } from "utils/judge"
|
||||
import { useCodeStore } from "oj/store/code"
|
||||
|
||||
const input = ref("")
|
||||
const result = ref("")
|
||||
const { code } = useCodeStore()
|
||||
|
||||
async function submit() {
|
||||
const res = await createTestSubmission(code, input.value)
|
||||
result.value = res.output
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-tab-pane label="测试面板" name="test">
|
||||
<div class="panel">
|
||||
<el-form inline>
|
||||
<el-form-item label="输入">
|
||||
<el-input type="textarea" autosize v-model="input" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="submit">运行</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-scrollbar height="345">
|
||||
<div class="msg">{{ result }}</div>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.panel {
|
||||
height: 400px;
|
||||
}
|
||||
.msg {
|
||||
white-space: pre;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import Editor from "./components/Editor.vue"
|
||||
import ProblemContent from "./components/ProblemContent.vue"
|
||||
import ProblemInfo from "./components/ProblemInfo.vue"
|
||||
import { getProblem } from "oj/api"
|
||||
import { isDesktop, isMobile } from "~/shared/composables/breakpoints"
|
||||
import { TabsPaneContext } from "element-plus"
|
||||
|
||||
const Editor = defineAsyncComponent(() => import("./components/Editor.vue"))
|
||||
const ProblemContent = defineAsyncComponent(
|
||||
() => import("./components/ProblemContent.vue")
|
||||
)
|
||||
const ProblemInfo = defineAsyncComponent(
|
||||
() => import("./components/ProblemInfo.vue")
|
||||
)
|
||||
|
||||
interface Props {
|
||||
problemID: string
|
||||
|
||||
@@ -140,12 +140,12 @@ onMounted(listProblems)
|
||||
<el-table-column v-if="isDesktop" label="状态" :width="80">
|
||||
<template #default="scope">
|
||||
<el-icon
|
||||
v-if="scope.row.status === 'done'"
|
||||
v-if="scope.row.status === 'passed'"
|
||||
color="var(--el-color-success)"
|
||||
><i-ep-select
|
||||
/></el-icon>
|
||||
<el-icon
|
||||
v-if="scope.row.status === 'tried'"
|
||||
v-if="scope.row.status === 'failed'"
|
||||
color="var(--el-color-error)"
|
||||
><i-ep-semi-select
|
||||
/></el-icon>
|
||||
@@ -155,10 +155,7 @@ onMounted(listProblems)
|
||||
<el-table-column prop="title" label="标题" />
|
||||
<el-table-column label="难度" width="100">
|
||||
<template #default="scope">
|
||||
<el-tag
|
||||
disable-transitions
|
||||
:type="(getTagColor(scope.row.difficulty) as any)"
|
||||
>
|
||||
<el-tag disable-transitions :type="getTagColor(scope.row.difficulty)">
|
||||
{{ scope.row.difficulty }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<template>status detail</template>
|
||||
|
||||
<style scoped></style>
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<template>status detail</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,16 +1,67 @@
|
||||
<script setup lang="ts">
|
||||
import Pagination from "~/shared/Pagination/index.vue"
|
||||
import { SubmissionListPayload } from "utils/types"
|
||||
import {
|
||||
submissionMemoryFormat,
|
||||
submissionTimeFormat,
|
||||
parseTime,
|
||||
} from "utils/functions"
|
||||
import { listSubmissions } from "oj/api"
|
||||
import SubmissionResultTag from "oj/components/SubmissionResultTag.vue"
|
||||
|
||||
const query = reactive({
|
||||
const route = useRoute()
|
||||
const problemID = <string>route.query.problem
|
||||
const contestID = <string>route.query.contest
|
||||
const query = reactive<SubmissionListPayload>({
|
||||
page: 1,
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
username: "",
|
||||
myself: "0",
|
||||
problem_id: problemID,
|
||||
contest_id: contestID,
|
||||
})
|
||||
|
||||
const { data, isLoading, isFinished, execute } = listSubmissions(query)
|
||||
|
||||
onMounted(() => {
|
||||
execute()
|
||||
})
|
||||
const total = ref(100)
|
||||
</script>
|
||||
<template>
|
||||
<el-table max-height="calc(100vh - 171px)"></el-table>
|
||||
<el-table v-if="isFinished" :loading="isLoading" :data="data.results">
|
||||
<el-table-column label="提交时间" prop="create_time">
|
||||
<template #default="scope">
|
||||
{{ parseTime(scope.row.create_time, "YYYY-M-D hh:mm:ss") }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="编号">
|
||||
<template #default="scope">
|
||||
{{ scope.row.id.slice(0, 12) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" prop="result">
|
||||
<template #default="scope">
|
||||
<SubmissionResultTag :result="scope.row.result" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="题目" prop="problem"></el-table-column>
|
||||
<el-table-column label="执行耗时">
|
||||
<template #default="scope">
|
||||
{{ submissionTimeFormat(scope.row.statistic_info.time_cost) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="占用内存">
|
||||
<template #default="scope">
|
||||
{{ submissionMemoryFormat(scope.row.statistic_info.memory_cost) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="语言" prop="language"></el-table-column>
|
||||
<el-table-column label="提交者" prop="username"></el-table-column>
|
||||
</el-table>
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-if="isFinished"
|
||||
:total="data.total"
|
||||
v-model:limit="query.limit"
|
||||
v-model:page="query.page"
|
||||
/>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Code } from "utils/types"
|
||||
|
||||
export const useCodeStore = defineStore("code", () => {
|
||||
const code = reactive<Code>({
|
||||
value: "",
|
||||
language: "C",
|
||||
})
|
||||
|
||||
return { code }
|
||||
})
|
||||
import { Code } from "utils/types"
|
||||
|
||||
export const useCodeStore = defineStore("code", () => {
|
||||
const code = reactive<Code>({
|
||||
value: "",
|
||||
language: "C",
|
||||
})
|
||||
|
||||
return { code }
|
||||
})
|
||||
|
||||
108
src/routes.ts
108
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") }],
|
||||
},
|
||||
]
|
||||
|
||||
@@ -1,98 +1,98 @@
|
||||
<script setup lang="ts">
|
||||
import type * as Monaco from "monaco-editor"
|
||||
import { LANGUAGE_VALUE } from "utils/constants"
|
||||
import { LANGUAGE } from "utils/types"
|
||||
import { isMobile } from "~/shared/composables/breakpoints"
|
||||
import { isDark } from "../composables/dark"
|
||||
|
||||
interface Props {
|
||||
value: string
|
||||
language?: LANGUAGE
|
||||
height?: string
|
||||
fontSize?: number
|
||||
class?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
language: "C",
|
||||
height: "calc(100vh - 100px)",
|
||||
fontSize: 20,
|
||||
class: "",
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "change", value: string): void
|
||||
}>()
|
||||
|
||||
const monacoEditorRef = ref()
|
||||
let editor: Monaco.editor.IStandaloneCodeEditor
|
||||
|
||||
onMounted(function () {
|
||||
const model = window.monaco.editor.createModel(
|
||||
props.value,
|
||||
LANGUAGE_VALUE[props.language]
|
||||
)
|
||||
|
||||
editor = window.monaco.editor.create(monacoEditorRef.value, {
|
||||
model,
|
||||
theme: isDark.value ? "dark" : "light", // 官方自带三种主题vs, hc-black, or vs-dark
|
||||
minimap: {
|
||||
enabled: false,
|
||||
},
|
||||
lineNumbersMinChars: 3,
|
||||
automaticLayout: true, // 自适应布局
|
||||
tabSize: 4,
|
||||
fontSize: isMobile.value ? 20 : 24, // 字体大小
|
||||
scrollBeyondLastLine: false,
|
||||
lineDecorationsWidth: 0,
|
||||
scrollBeyondLastColumn: 0,
|
||||
glyphMargin: false,
|
||||
scrollbar: {
|
||||
useShadows: false,
|
||||
vertical: "hidden",
|
||||
horizontal: "hidden",
|
||||
},
|
||||
overviewRulerLanes: 0,
|
||||
})
|
||||
|
||||
model.onDidChangeContent(() => {
|
||||
const value = model.getValue().toString()
|
||||
emit("change", value)
|
||||
})
|
||||
|
||||
editor.onKeyDown((e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.code === "KeyS") {
|
||||
e.preventDefault()
|
||||
}
|
||||
if ((e.ctrlKey || e.metaKey) && e.code === "KeyR") {
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
window.monaco.editor.setModelLanguage(model, LANGUAGE_VALUE[props.language])
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
if (props.value !== model.getValue()) {
|
||||
model.setValue(props.value)
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
window.monaco.editor.setTheme(isDark.value ? "dark" : "light")
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
editor && editor.dispose()
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
ref="monacoEditorRef"
|
||||
:class="props.class"
|
||||
:style="{ height: props.height }"
|
||||
></div>
|
||||
</template>
|
||||
<style scoped></style>
|
||||
<script setup lang="ts">
|
||||
import type * as Monaco from "monaco-editor"
|
||||
import { LANGUAGE_VALUE } from "utils/constants"
|
||||
import { LANGUAGE } from "utils/types"
|
||||
import { isMobile } from "~/shared/composables/breakpoints"
|
||||
import { isDark } from "../composables/dark"
|
||||
|
||||
interface Props {
|
||||
value: string
|
||||
language?: LANGUAGE
|
||||
height?: string
|
||||
fontSize?: number
|
||||
class?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
language: "C",
|
||||
height: "calc(100vh - 100px)",
|
||||
fontSize: 20,
|
||||
class: "",
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "change", value: string): void
|
||||
}>()
|
||||
|
||||
const monacoEditorRef = ref()
|
||||
let editor: Monaco.editor.IStandaloneCodeEditor
|
||||
|
||||
onMounted(function () {
|
||||
const model = window.monaco.editor.createModel(
|
||||
props.value,
|
||||
LANGUAGE_VALUE[props.language]
|
||||
)
|
||||
|
||||
editor = window.monaco.editor.create(monacoEditorRef.value, {
|
||||
model,
|
||||
theme: isDark.value ? "dark" : "light", // 官方自带三种主题vs, hc-black, or vs-dark
|
||||
minimap: {
|
||||
enabled: false,
|
||||
},
|
||||
lineNumbersMinChars: 3,
|
||||
automaticLayout: true, // 自适应布局
|
||||
tabSize: 4,
|
||||
fontSize: isMobile.value ? 20 : 24, // 字体大小
|
||||
scrollBeyondLastLine: false,
|
||||
lineDecorationsWidth: 0,
|
||||
scrollBeyondLastColumn: 0,
|
||||
glyphMargin: false,
|
||||
scrollbar: {
|
||||
useShadows: false,
|
||||
vertical: "hidden",
|
||||
horizontal: "hidden",
|
||||
},
|
||||
overviewRulerLanes: 0,
|
||||
})
|
||||
|
||||
model.onDidChangeContent(() => {
|
||||
const value = model.getValue().toString()
|
||||
emit("change", value)
|
||||
})
|
||||
|
||||
editor.onKeyDown((e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.code === "KeyS") {
|
||||
e.preventDefault()
|
||||
}
|
||||
if ((e.ctrlKey || e.metaKey) && e.code === "KeyR") {
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
window.monaco.editor.setModelLanguage(model, LANGUAGE_VALUE[props.language])
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
if (props.value !== model.getValue()) {
|
||||
model.setValue(props.value)
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
window.monaco.editor.setTheme(isDark.value ? "dark" : "light")
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
editor && editor.dispose()
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
ref="monacoEditorRef"
|
||||
:class="props.class"
|
||||
:style="{ height: props.height }"
|
||||
></div>
|
||||
</template>
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
<script setup lang="ts">
|
||||
import { isDesktop } from "~/shared/composables/breakpoints"
|
||||
interface Props {
|
||||
total: number
|
||||
limit: number
|
||||
page: number
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
limit: 10,
|
||||
page: 1,
|
||||
})
|
||||
|
||||
const emit = defineEmits(["update:limit", "update:page"])
|
||||
|
||||
const limit = ref(props.limit)
|
||||
const page = ref(props.page)
|
||||
|
||||
watch(limit, () => emit("update:limit", limit))
|
||||
watch(page, () => emit("update:page", page))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-pagination
|
||||
class="right margin"
|
||||
:layout="isDesktop ? 'prev,pager,next,sizes' : 'prev,next,sizes'"
|
||||
background
|
||||
:total="props.total"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
:pager-count="5"
|
||||
v-model:page-size="limit"
|
||||
v-model:current-page="page"
|
||||
/>
|
||||
</template>
|
||||
<style scoped>
|
||||
.margin {
|
||||
margin-top: 24px;
|
||||
}
|
||||
.right {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
<script setup lang="ts">
|
||||
import { isDesktop } from "~/shared/composables/breakpoints"
|
||||
interface Props {
|
||||
total: number
|
||||
limit: number
|
||||
page: number
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
limit: 10,
|
||||
page: 1,
|
||||
})
|
||||
|
||||
const emit = defineEmits(["update:limit", "update:page"])
|
||||
|
||||
const limit = ref(props.limit)
|
||||
const page = ref(props.page)
|
||||
|
||||
watch(limit, () => emit("update:limit", limit))
|
||||
watch(page, () => emit("update:page", page))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-pagination
|
||||
class="right margin"
|
||||
:layout="isDesktop ? 'prev,pager,next,sizes' : 'prev,next,sizes'"
|
||||
background
|
||||
:total="props.total"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
:pager-count="5"
|
||||
v-model:page-size="limit"
|
||||
v-model:current-page="page"
|
||||
/>
|
||||
</template>
|
||||
<style scoped>
|
||||
.margin {
|
||||
margin-top: 24px;
|
||||
}
|
||||
.right {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
<template>
|
||||
<div :class="classes">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue"
|
||||
|
||||
interface Props {
|
||||
split: "horizontal" | "vertical"
|
||||
className?: string
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
split: "horizontal",
|
||||
className: "",
|
||||
})
|
||||
|
||||
const classes = computed(() => [props.split, props.className].join(" "))
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.splitter-pane.vertical.splitter-paneL {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
height: 100%;
|
||||
padding-right: 3px;
|
||||
}
|
||||
.splitter-pane.vertical.splitter-paneR {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
height: 100%;
|
||||
padding-left: 3px;
|
||||
}
|
||||
.splitter-pane.horizontal.splitter-paneL {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
}
|
||||
.splitter-pane.horizontal.splitter-paneR {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
padding-top: 3px;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div :class="classes">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue"
|
||||
|
||||
interface Props {
|
||||
split: "horizontal" | "vertical"
|
||||
className?: string
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
split: "horizontal",
|
||||
className: "",
|
||||
})
|
||||
|
||||
const classes = computed(() => [props.split, props.className].join(" "))
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.splitter-pane.vertical.splitter-paneL {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
height: 100%;
|
||||
padding-right: 3px;
|
||||
}
|
||||
.splitter-pane.vertical.splitter-paneR {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
height: 100%;
|
||||
padding-left: 3px;
|
||||
}
|
||||
.splitter-pane.horizontal.splitter-paneL {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
}
|
||||
.splitter-pane.horizontal.splitter-paneR {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
padding-top: 3px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
<template>
|
||||
<div :class="classes"></div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue"
|
||||
|
||||
interface Props {
|
||||
split: "horizontal" | "vertical"
|
||||
className?: string
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
split: "horizontal",
|
||||
className: "",
|
||||
})
|
||||
|
||||
const classes = computed(() =>
|
||||
["splitter-pane-resizer", props.split, props.className].join(" ")
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.splitter-pane-resizer {
|
||||
box-sizing: border-box;
|
||||
background: #000;
|
||||
position: absolute;
|
||||
opacity: 0.2;
|
||||
z-index: 1;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
.splitter-pane-resizer.horizontal {
|
||||
height: 11px;
|
||||
margin: -5px 0;
|
||||
border-top: 5px solid rgba(255, 255, 255, 0);
|
||||
border-bottom: 5px solid rgba(255, 255, 255, 0);
|
||||
cursor: row-resize;
|
||||
width: 100%;
|
||||
}
|
||||
.splitter-pane-resizer.vertical {
|
||||
width: 11px;
|
||||
height: 100%;
|
||||
margin-left: -5px;
|
||||
border-left: 5px solid rgba(255, 255, 255, 0);
|
||||
border-right: 5px solid rgba(255, 255, 255, 0);
|
||||
cursor: col-resize;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div :class="classes"></div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue"
|
||||
|
||||
interface Props {
|
||||
split: "horizontal" | "vertical"
|
||||
className?: string
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
split: "horizontal",
|
||||
className: "",
|
||||
})
|
||||
|
||||
const classes = computed(() =>
|
||||
["splitter-pane-resizer", props.split, props.className].join(" ")
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.splitter-pane-resizer {
|
||||
box-sizing: border-box;
|
||||
background: #000;
|
||||
position: absolute;
|
||||
opacity: 0.2;
|
||||
z-index: 1;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
.splitter-pane-resizer.horizontal {
|
||||
height: 11px;
|
||||
margin: -5px 0;
|
||||
border-top: 5px solid rgba(255, 255, 255, 0);
|
||||
border-bottom: 5px solid rgba(255, 255, 255, 0);
|
||||
cursor: row-resize;
|
||||
width: 100%;
|
||||
}
|
||||
.splitter-pane-resizer.vertical {
|
||||
width: 11px;
|
||||
height: 100%;
|
||||
margin-left: -5px;
|
||||
border-left: 5px solid rgba(255, 255, 255, 0);
|
||||
border-right: 5px solid rgba(255, 255, 255, 0);
|
||||
cursor: col-resize;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,141 +1,141 @@
|
||||
<template>
|
||||
<div
|
||||
:style="{ cursor, userSelect }"
|
||||
class="vue-splitter-container clearfix"
|
||||
@mouseup="onMouseUp"
|
||||
@mousemove="onMouseMove"
|
||||
>
|
||||
<Pane
|
||||
class="splitter-pane splitter-paneL"
|
||||
:split="split"
|
||||
:style="{ [type]: percent + '%' }"
|
||||
>
|
||||
<slot name="panel"></slot>
|
||||
</Pane>
|
||||
|
||||
<Resizer
|
||||
:className="className"
|
||||
:style="{ [resizeType]: percent + '%' }"
|
||||
:split="split"
|
||||
@mousedown.native="onMouseDown"
|
||||
@click.native="onClick"
|
||||
></Resizer>
|
||||
|
||||
<Pane
|
||||
class="splitter-pane splitter-paneR"
|
||||
:split="split"
|
||||
:style="{ [type]: 100 - percent + '%' }"
|
||||
>
|
||||
<slot name="paner"></slot>
|
||||
</Pane>
|
||||
<div class="vue-splitter-container-mask" v-if="active"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Resizer from "./Resizer.vue"
|
||||
import Pane from "./Pane.vue"
|
||||
import { computed, ref } from "vue"
|
||||
|
||||
interface Props {
|
||||
minPercent?: number
|
||||
defaultPercent?: number
|
||||
split: "vertical" | "horizontal"
|
||||
className?: string
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
minPercent: 10,
|
||||
defaultPercent: 50,
|
||||
split: "horizontal",
|
||||
className: "",
|
||||
})
|
||||
|
||||
const emit = defineEmits(["resize"])
|
||||
|
||||
const active = ref(false)
|
||||
const hasMoved = ref(false)
|
||||
const percent = ref(props.defaultPercent)
|
||||
const type = ref(props.split === "vertical" ? "width" : "height")
|
||||
const resizeType = ref(props.split === "vertical" ? "left" : "top")
|
||||
|
||||
const userSelect = computed(() => (active.value ? "none" : "auto"))
|
||||
const cursor = computed(() =>
|
||||
active.value ? (props.split === "vertical" ? "col-resize" : "row-resize") : ""
|
||||
)
|
||||
|
||||
// watch(
|
||||
// () => defaultPercent,
|
||||
// (newValue) => {
|
||||
// percent.value = newValue
|
||||
// }
|
||||
// )
|
||||
|
||||
function onClick() {
|
||||
if (!hasMoved.value) {
|
||||
percent.value = 50
|
||||
emit("resize", percent.value)
|
||||
}
|
||||
}
|
||||
function onMouseDown() {
|
||||
active.value = true
|
||||
hasMoved.value = false
|
||||
}
|
||||
function onMouseUp() {
|
||||
active.value = false
|
||||
}
|
||||
function onMouseMove(e: any) {
|
||||
if (e.buttons === 0) {
|
||||
active.value = false
|
||||
}
|
||||
if (active.value) {
|
||||
let offset = 0
|
||||
let target = e.currentTarget
|
||||
if (props.split === "vertical") {
|
||||
while (target) {
|
||||
offset += target.offsetLeft
|
||||
target = target.offsetParent
|
||||
}
|
||||
} else {
|
||||
while (target) {
|
||||
offset += target.offsetTop
|
||||
target = target.offsetParent
|
||||
}
|
||||
}
|
||||
const currentPage = props.split === "vertical" ? e.pageX : e.pageY
|
||||
const targetOffset =
|
||||
props.split === "vertical"
|
||||
? e.currentTarget.offsetWidth
|
||||
: e.currentTarget.offsetHeight
|
||||
const newPercent =
|
||||
Math.floor(((currentPage - offset) / targetOffset) * 10000) / 100
|
||||
if (newPercent > props.minPercent && newPercent < 100 - props.minPercent) {
|
||||
percent.value = newPercent
|
||||
}
|
||||
emit("resize", newPercent)
|
||||
hasMoved.value = true
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.clearfix:after {
|
||||
visibility: hidden;
|
||||
display: block;
|
||||
font-size: 0;
|
||||
content: " ";
|
||||
clear: both;
|
||||
height: 0;
|
||||
}
|
||||
.vue-splitter-container {
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
.vue-splitter-container-mask {
|
||||
z-index: 9999;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div
|
||||
:style="{ cursor, userSelect }"
|
||||
class="vue-splitter-container clearfix"
|
||||
@mouseup="onMouseUp"
|
||||
@mousemove="onMouseMove"
|
||||
>
|
||||
<Pane
|
||||
class="splitter-pane splitter-paneL"
|
||||
:split="split"
|
||||
:style="{ [type]: percent + '%' }"
|
||||
>
|
||||
<slot name="panel"></slot>
|
||||
</Pane>
|
||||
|
||||
<Resizer
|
||||
:className="className"
|
||||
:style="{ [resizeType]: percent + '%' }"
|
||||
:split="split"
|
||||
@mousedown.native="onMouseDown"
|
||||
@click.native="onClick"
|
||||
></Resizer>
|
||||
|
||||
<Pane
|
||||
class="splitter-pane splitter-paneR"
|
||||
:split="split"
|
||||
:style="{ [type]: 100 - percent + '%' }"
|
||||
>
|
||||
<slot name="paner"></slot>
|
||||
</Pane>
|
||||
<div class="vue-splitter-container-mask" v-if="active"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Resizer from "./Resizer.vue"
|
||||
import Pane from "./Pane.vue"
|
||||
import { computed, ref } from "vue"
|
||||
|
||||
interface Props {
|
||||
minPercent?: number
|
||||
defaultPercent?: number
|
||||
split: "vertical" | "horizontal"
|
||||
className?: string
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
minPercent: 10,
|
||||
defaultPercent: 50,
|
||||
split: "horizontal",
|
||||
className: "",
|
||||
})
|
||||
|
||||
const emit = defineEmits(["resize"])
|
||||
|
||||
const active = ref(false)
|
||||
const hasMoved = ref(false)
|
||||
const percent = ref(props.defaultPercent)
|
||||
const type = ref(props.split === "vertical" ? "width" : "height")
|
||||
const resizeType = ref(props.split === "vertical" ? "left" : "top")
|
||||
|
||||
const userSelect = computed(() => (active.value ? "none" : "auto"))
|
||||
const cursor = computed(() =>
|
||||
active.value ? (props.split === "vertical" ? "col-resize" : "row-resize") : ""
|
||||
)
|
||||
|
||||
// watch(
|
||||
// () => defaultPercent,
|
||||
// (newValue) => {
|
||||
// percent.value = newValue
|
||||
// }
|
||||
// )
|
||||
|
||||
function onClick() {
|
||||
if (!hasMoved.value) {
|
||||
percent.value = 50
|
||||
emit("resize", percent.value)
|
||||
}
|
||||
}
|
||||
function onMouseDown() {
|
||||
active.value = true
|
||||
hasMoved.value = false
|
||||
}
|
||||
function onMouseUp() {
|
||||
active.value = false
|
||||
}
|
||||
function onMouseMove(e: any) {
|
||||
if (e.buttons === 0) {
|
||||
active.value = false
|
||||
}
|
||||
if (active.value) {
|
||||
let offset = 0
|
||||
let target = e.currentTarget
|
||||
if (props.split === "vertical") {
|
||||
while (target) {
|
||||
offset += target.offsetLeft
|
||||
target = target.offsetParent
|
||||
}
|
||||
} else {
|
||||
while (target) {
|
||||
offset += target.offsetTop
|
||||
target = target.offsetParent
|
||||
}
|
||||
}
|
||||
const currentPage = props.split === "vertical" ? e.pageX : e.pageY
|
||||
const targetOffset =
|
||||
props.split === "vertical"
|
||||
? e.currentTarget.offsetWidth
|
||||
: e.currentTarget.offsetHeight
|
||||
const newPercent =
|
||||
Math.floor(((currentPage - offset) / targetOffset) * 10000) / 100
|
||||
if (newPercent > props.minPercent && newPercent < 100 - props.minPercent) {
|
||||
percent.value = newPercent
|
||||
}
|
||||
emit("resize", newPercent)
|
||||
hasMoved.value = true
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.clearfix:after {
|
||||
visibility: hidden;
|
||||
display: block;
|
||||
font-size: 0;
|
||||
content: " ";
|
||||
clear: both;
|
||||
height: 0;
|
||||
}
|
||||
.vue-splitter-container {
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
.vue-splitter-container-mask {
|
||||
z-index: 9999;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export const [loginModal, toggleLogin] = useToggle()
|
||||
export const [signupModal, toggleSignup] = useToggle()
|
||||
export const [loginModal, toggleLogin] = useToggle()
|
||||
export const [signupModal, toggleSignup] = useToggle()
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<template>
|
||||
<el-container>
|
||||
<el-main>
|
||||
<router-view></router-view>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<template>
|
||||
<el-container>
|
||||
<el-main>
|
||||
<router-view></router-view>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import Login from "../Login/index.vue"
|
||||
import Signup from "../Signup/index.vue"
|
||||
import Header from "../Header/index.vue"
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-container>
|
||||
<el-header class="header">
|
||||
<Header />
|
||||
</el-header>
|
||||
<el-main>
|
||||
<router-view></router-view>
|
||||
</el-main>
|
||||
<Login />
|
||||
<Signup />
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.header {
|
||||
display: flex;
|
||||
}
|
||||
</style>
|
||||
<script setup lang="ts">
|
||||
import Login from "../Login/index.vue"
|
||||
import Signup from "../Signup/index.vue"
|
||||
import Header from "../Header/index.vue"
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-container>
|
||||
<el-header class="header">
|
||||
<Header />
|
||||
</el-header>
|
||||
<el-main>
|
||||
<router-view></router-view>
|
||||
</el-main>
|
||||
<Login />
|
||||
<Signup />
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.header {
|
||||
display: flex;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,98 +1,98 @@
|
||||
<script setup lang="ts">
|
||||
import type * as Monaco from "monaco-editor"
|
||||
import { LANGUAGE_VALUE } from "utils/constants"
|
||||
import { LANGUAGE } from "utils/types"
|
||||
import { isMobile } from "~/shared/composables/breakpoints"
|
||||
import { isDark } from "../composables/dark"
|
||||
|
||||
interface Props {
|
||||
value: string
|
||||
language?: LANGUAGE
|
||||
height?: string
|
||||
fontSize?: number
|
||||
class?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
language: "C",
|
||||
height: "calc(100vh - 100px)",
|
||||
fontSize: 20,
|
||||
class: "",
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "change", value: string): void
|
||||
}>()
|
||||
|
||||
const monacoEditorRef = ref()
|
||||
let editor: Monaco.editor.IStandaloneCodeEditor
|
||||
|
||||
onMounted(function () {
|
||||
const model = window.monaco.editor.createModel(
|
||||
props.value,
|
||||
LANGUAGE_VALUE[props.language]
|
||||
)
|
||||
|
||||
editor = window.monaco.editor.create(monacoEditorRef.value, {
|
||||
model,
|
||||
theme: isDark.value ? "dark" : "light", // 官方自带三种主题vs, hc-black, or vs-dark
|
||||
minimap: {
|
||||
enabled: false,
|
||||
},
|
||||
lineNumbersMinChars: 3,
|
||||
automaticLayout: true, // 自适应布局
|
||||
tabSize: 4,
|
||||
fontSize: isMobile.value ? 20 : 24, // 字体大小
|
||||
scrollBeyondLastLine: false,
|
||||
lineDecorationsWidth: 0,
|
||||
scrollBeyondLastColumn: 0,
|
||||
glyphMargin: false,
|
||||
scrollbar: {
|
||||
useShadows: false,
|
||||
vertical: "hidden",
|
||||
horizontal: "hidden",
|
||||
},
|
||||
overviewRulerLanes: 0,
|
||||
})
|
||||
|
||||
model.onDidChangeContent(() => {
|
||||
const value = model.getValue().toString()
|
||||
emit("change", value)
|
||||
})
|
||||
|
||||
editor.onKeyDown((e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.code === "KeyS") {
|
||||
e.preventDefault()
|
||||
}
|
||||
if ((e.ctrlKey || e.metaKey) && e.code === "KeyR") {
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
window.monaco.editor.setModelLanguage(model, LANGUAGE_VALUE[props.language])
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
if (props.value !== model.getValue()) {
|
||||
model.setValue(props.value)
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
window.monaco.editor.setTheme(isDark.value ? "dark" : "light")
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
editor && editor.dispose()
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
ref="monacoEditorRef"
|
||||
:class="props.class"
|
||||
:style="{ height: props.height }"
|
||||
></div>
|
||||
</template>
|
||||
<style scoped></style>
|
||||
<script setup lang="ts">
|
||||
import type * as Monaco from "monaco-editor"
|
||||
import { LANGUAGE_VALUE } from "utils/constants"
|
||||
import { LANGUAGE } from "utils/types"
|
||||
import { isMobile } from "~/shared/composables/breakpoints"
|
||||
import { isDark } from "../composables/dark"
|
||||
|
||||
interface Props {
|
||||
value: string
|
||||
language?: LANGUAGE
|
||||
height?: string
|
||||
fontSize?: number
|
||||
class?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
language: "C",
|
||||
height: "calc(100vh - 100px)",
|
||||
fontSize: 20,
|
||||
class: "",
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "change", value: string): void
|
||||
}>()
|
||||
|
||||
const monacoEditorRef = ref()
|
||||
let editor: Monaco.editor.IStandaloneCodeEditor
|
||||
|
||||
onMounted(function () {
|
||||
const model = window.monaco.editor.createModel(
|
||||
props.value,
|
||||
LANGUAGE_VALUE[props.language]
|
||||
)
|
||||
|
||||
editor = window.monaco.editor.create(monacoEditorRef.value, {
|
||||
model,
|
||||
theme: isDark.value ? "dark" : "light", // 官方自带三种主题vs, hc-black, or vs-dark
|
||||
minimap: {
|
||||
enabled: false,
|
||||
},
|
||||
lineNumbersMinChars: 3,
|
||||
automaticLayout: true, // 自适应布局
|
||||
tabSize: 4,
|
||||
fontSize: isMobile.value ? 20 : 24, // 字体大小
|
||||
scrollBeyondLastLine: false,
|
||||
lineDecorationsWidth: 0,
|
||||
scrollBeyondLastColumn: 0,
|
||||
glyphMargin: false,
|
||||
scrollbar: {
|
||||
useShadows: false,
|
||||
vertical: "hidden",
|
||||
horizontal: "hidden",
|
||||
},
|
||||
overviewRulerLanes: 0,
|
||||
})
|
||||
|
||||
model.onDidChangeContent(() => {
|
||||
const value = model.getValue().toString()
|
||||
emit("change", value)
|
||||
})
|
||||
|
||||
editor.onKeyDown((e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.code === "KeyS") {
|
||||
e.preventDefault()
|
||||
}
|
||||
if ((e.ctrlKey || e.metaKey) && e.code === "KeyR") {
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
window.monaco.editor.setModelLanguage(model, LANGUAGE_VALUE[props.language])
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
if (props.value !== model.getValue()) {
|
||||
model.setValue(props.value)
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
window.monaco.editor.setTheme(isDark.value ? "dark" : "light")
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
editor && editor.dispose()
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
ref="monacoEditorRef"
|
||||
:class="props.class"
|
||||
:style="{ height: props.height }"
|
||||
></div>
|
||||
</template>
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,141 +1,141 @@
|
||||
<template>
|
||||
<div
|
||||
:style="{ cursor, userSelect }"
|
||||
class="vue-splitter-container clearfix"
|
||||
@mouseup="onMouseUp"
|
||||
@mousemove="onMouseMove"
|
||||
>
|
||||
<Pane
|
||||
class="splitter-pane splitter-paneL"
|
||||
:split="split"
|
||||
:style="{ [type]: percent + '%' }"
|
||||
>
|
||||
<slot name="panel"></slot>
|
||||
</Pane>
|
||||
|
||||
<Resizer
|
||||
:className="className"
|
||||
:style="{ [resizeType]: percent + '%' }"
|
||||
:split="split"
|
||||
@mousedown.native="onMouseDown"
|
||||
@click.native="onClick"
|
||||
></Resizer>
|
||||
|
||||
<Pane
|
||||
class="splitter-pane splitter-paneR"
|
||||
:split="split"
|
||||
:style="{ [type]: 100 - percent + '%' }"
|
||||
>
|
||||
<slot name="paner"></slot>
|
||||
</Pane>
|
||||
<div class="vue-splitter-container-mask" v-if="active"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Resizer from "./Resizer.vue"
|
||||
import Pane from "./Pane.vue"
|
||||
import { computed, ref } from "vue"
|
||||
|
||||
interface Props {
|
||||
minPercent?: number
|
||||
defaultPercent?: number
|
||||
split: "vertical" | "horizontal"
|
||||
className?: string
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
minPercent: 10,
|
||||
defaultPercent: 50,
|
||||
split: "horizontal",
|
||||
className: "",
|
||||
})
|
||||
|
||||
const emit = defineEmits(["resize"])
|
||||
|
||||
const active = ref(false)
|
||||
const hasMoved = ref(false)
|
||||
const percent = ref(props.defaultPercent)
|
||||
const type = ref(props.split === "vertical" ? "width" : "height")
|
||||
const resizeType = ref(props.split === "vertical" ? "left" : "top")
|
||||
|
||||
const userSelect = computed(() => (active.value ? "none" : "auto"))
|
||||
const cursor = computed(() =>
|
||||
active.value ? (props.split === "vertical" ? "col-resize" : "row-resize") : ""
|
||||
)
|
||||
|
||||
// watch(
|
||||
// () => defaultPercent,
|
||||
// (newValue) => {
|
||||
// percent.value = newValue
|
||||
// }
|
||||
// )
|
||||
|
||||
function onClick() {
|
||||
if (!hasMoved.value) {
|
||||
percent.value = 50
|
||||
emit("resize", percent.value)
|
||||
}
|
||||
}
|
||||
function onMouseDown() {
|
||||
active.value = true
|
||||
hasMoved.value = false
|
||||
}
|
||||
function onMouseUp() {
|
||||
active.value = false
|
||||
}
|
||||
function onMouseMove(e: any) {
|
||||
if (e.buttons === 0) {
|
||||
active.value = false
|
||||
}
|
||||
if (active.value) {
|
||||
let offset = 0
|
||||
let target = e.currentTarget
|
||||
if (props.split === "vertical") {
|
||||
while (target) {
|
||||
offset += target.offsetLeft
|
||||
target = target.offsetParent
|
||||
}
|
||||
} else {
|
||||
while (target) {
|
||||
offset += target.offsetTop
|
||||
target = target.offsetParent
|
||||
}
|
||||
}
|
||||
const currentPage = props.split === "vertical" ? e.pageX : e.pageY
|
||||
const targetOffset =
|
||||
props.split === "vertical"
|
||||
? e.currentTarget.offsetWidth
|
||||
: e.currentTarget.offsetHeight
|
||||
const newPercent =
|
||||
Math.floor(((currentPage - offset) / targetOffset) * 10000) / 100
|
||||
if (newPercent > props.minPercent && newPercent < 100 - props.minPercent) {
|
||||
percent.value = newPercent
|
||||
}
|
||||
emit("resize", newPercent)
|
||||
hasMoved.value = true
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.clearfix:after {
|
||||
visibility: hidden;
|
||||
display: block;
|
||||
font-size: 0;
|
||||
content: " ";
|
||||
clear: both;
|
||||
height: 0;
|
||||
}
|
||||
.vue-splitter-container {
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
.vue-splitter-container-mask {
|
||||
z-index: 9999;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div
|
||||
:style="{ cursor, userSelect }"
|
||||
class="vue-splitter-container clearfix"
|
||||
@mouseup="onMouseUp"
|
||||
@mousemove="onMouseMove"
|
||||
>
|
||||
<Pane
|
||||
class="splitter-pane splitter-paneL"
|
||||
:split="split"
|
||||
:style="{ [type]: percent + '%' }"
|
||||
>
|
||||
<slot name="panel"></slot>
|
||||
</Pane>
|
||||
|
||||
<Resizer
|
||||
:className="className"
|
||||
:style="{ [resizeType]: percent + '%' }"
|
||||
:split="split"
|
||||
@mousedown.native="onMouseDown"
|
||||
@click.native="onClick"
|
||||
></Resizer>
|
||||
|
||||
<Pane
|
||||
class="splitter-pane splitter-paneR"
|
||||
:split="split"
|
||||
:style="{ [type]: 100 - percent + '%' }"
|
||||
>
|
||||
<slot name="paner"></slot>
|
||||
</Pane>
|
||||
<div class="vue-splitter-container-mask" v-if="active"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import Resizer from "./Resizer.vue"
|
||||
import Pane from "./Pane.vue"
|
||||
import { computed, ref } from "vue"
|
||||
|
||||
interface Props {
|
||||
minPercent?: number
|
||||
defaultPercent?: number
|
||||
split: "vertical" | "horizontal"
|
||||
className?: string
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
minPercent: 10,
|
||||
defaultPercent: 50,
|
||||
split: "horizontal",
|
||||
className: "",
|
||||
})
|
||||
|
||||
const emit = defineEmits(["resize"])
|
||||
|
||||
const active = ref(false)
|
||||
const hasMoved = ref(false)
|
||||
const percent = ref(props.defaultPercent)
|
||||
const type = ref(props.split === "vertical" ? "width" : "height")
|
||||
const resizeType = ref(props.split === "vertical" ? "left" : "top")
|
||||
|
||||
const userSelect = computed(() => (active.value ? "none" : "auto"))
|
||||
const cursor = computed(() =>
|
||||
active.value ? (props.split === "vertical" ? "col-resize" : "row-resize") : ""
|
||||
)
|
||||
|
||||
// watch(
|
||||
// () => defaultPercent,
|
||||
// (newValue) => {
|
||||
// percent.value = newValue
|
||||
// }
|
||||
// )
|
||||
|
||||
function onClick() {
|
||||
if (!hasMoved.value) {
|
||||
percent.value = 50
|
||||
emit("resize", percent.value)
|
||||
}
|
||||
}
|
||||
function onMouseDown() {
|
||||
active.value = true
|
||||
hasMoved.value = false
|
||||
}
|
||||
function onMouseUp() {
|
||||
active.value = false
|
||||
}
|
||||
function onMouseMove(e: any) {
|
||||
if (e.buttons === 0) {
|
||||
active.value = false
|
||||
}
|
||||
if (active.value) {
|
||||
let offset = 0
|
||||
let target = e.currentTarget
|
||||
if (props.split === "vertical") {
|
||||
while (target) {
|
||||
offset += target.offsetLeft
|
||||
target = target.offsetParent
|
||||
}
|
||||
} else {
|
||||
while (target) {
|
||||
offset += target.offsetTop
|
||||
target = target.offsetParent
|
||||
}
|
||||
}
|
||||
const currentPage = props.split === "vertical" ? e.pageX : e.pageY
|
||||
const targetOffset =
|
||||
props.split === "vertical"
|
||||
? e.currentTarget.offsetWidth
|
||||
: e.currentTarget.offsetHeight
|
||||
const newPercent =
|
||||
Math.floor(((currentPage - offset) / targetOffset) * 10000) / 100
|
||||
if (newPercent > props.minPercent && newPercent < 100 - props.minPercent) {
|
||||
percent.value = newPercent
|
||||
}
|
||||
emit("resize", newPercent)
|
||||
hasMoved.value = true
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.clearfix:after {
|
||||
visibility: hidden;
|
||||
display: block;
|
||||
font-size: 0;
|
||||
content: " ";
|
||||
clear: both;
|
||||
height: 0;
|
||||
}
|
||||
.vue-splitter-container {
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
.vue-splitter-container-mask {
|
||||
z-index: 9999;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
33
src/shims.d.ts
vendored
33
src/shims.d.ts
vendored
@@ -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
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<LANGUAGE>
|
||||
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<LANGUAGE>
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user