This commit is contained in:
2024-06-29 18:11:26 +08:00
parent 00e0719ca7
commit 238b1ff416
3 changed files with 6 additions and 82 deletions

View File

@@ -6,7 +6,6 @@ import { problem } from "oj/composables/problem"
import { isDesktop, isMobile } from "~/shared/composables/breakpoints"
import { useUserStore } from "~/shared/store/user"
import Submit from "./Submit.vue"
import TestCat from "./TestCat2.vue"
import storage from "~/utils/storage"
import { STORAGE_KEY } from "utils/constants"
import { LANGUAGE } from "~/utils/types"
@@ -80,6 +79,11 @@ function changeLanguage(v: LANGUAGE) {
storage.set(STORAGE_KEY.LANGUAGE, v)
emit("changeLanguage", v)
}
function gotoTestCat() {
const url = "https://code.xuyue.cc"
window.open(url, "_blank")
}
</script>
<template>
@@ -92,11 +96,7 @@ function changeLanguage(v: LANGUAGE) {
:options="options"
/>
<Submit />
<TestCat
v-if="isDesktop"
:lang="code.language"
:input="problem?.samples[0].input"
/>
<n-button v-if="isDesktop" @click="gotoTestCat">自测猫</n-button>
<n-button v-if="isDesktop" @click="goSubmissions">提交信息</n-button>
<n-dropdown :options="menu" @select="select">
<n-button :size="isDesktop ? 'medium' : 'small'">操作</n-button>

View File

@@ -1,46 +0,0 @@
<script setup lang="ts">
import { code } from "oj/composables/code"
import { createTestSubmission } from "~/utils/judge"
const input = ref("")
const output = ref("")
async function test() {
output.value = "运行中..."
const res = await createTestSubmission(code, input.value)
output.value = res.output
}
function clear() {
const id = setTimeout(() => {
clearTimeout(id)
output.value = ""
}, 200)
}
</script>
<template>
<n-popover
placement="bottom-end"
scrollable
:show-arrow="false"
style="max-height: 600px; max-width: 800px"
@clickoutside="clear"
>
<template #trigger>
<n-button>快速测试</n-button>
</template>
<n-space vertical>
<n-input type="textarea" v-model:value="input" />
<n-space justify="end">
<n-button @click="test">运行</n-button>
</n-space>
<div class="testcase">{{ output }}</div>
</n-space>
</n-popover>
</template>
<style scoped>
.testcase {
white-space: pre;
font-size: 16px;
font-family: "Monaco";
}
</style>

View File

@@ -1,30 +0,0 @@
<script lang="ts" setup>
// import { LANGUAGE } from "~/utils/types"
// interface Props {
// lang: LANGUAGE
// input: string
// }
// const props = withDefaults(defineProps<Props>(), {
// lang: "C",
// input: "",
// })
function gotoTestCat() {
const url = "https://code.xuyue.cc"
// let id = 50
// const lang = props.lang
// if (lang === "Python3") id = 71
// if (lang === "Java") id = 62
// const payload = { input: props.input || "", id }
// try {
// const encoded = window.btoa(encodeURIComponent(JSON.stringify(payload)))
// window.open(`${url}?stdin=${encoded}`, "_blank")
// } catch (e) {
// window.open(url, "_blank")
// }
window.open(url, "_blank")
}
</script>
<template>
<n-button @click="gotoTestCat">自测猫</n-button>
</template>