add auto-imports.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
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 http from "./../utils/http"
|
||||
import { useAxios } from "@vueuse/integrations/useAxios"
|
||||
|
||||
function filterResult(result: Problem) {
|
||||
const newResult: any = {
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { useLoginStore } from "../../shared/stores/login"
|
||||
import { useSignupStore } from "../stores/signup"
|
||||
import { useUserStore } from "../../shared/stores/user"
|
||||
import { onMounted } from "vue"
|
||||
import { logout } from "../../shared/api"
|
||||
import { useRouter } from "vue-router"
|
||||
|
||||
const loginStore = useLoginStore()
|
||||
const signupStore = useSignupStore()
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
|
||||
async function handleLogout() {
|
||||
await logout()
|
||||
userStore.clearMyProfile()
|
||||
router.replace("/")
|
||||
}
|
||||
|
||||
function handleDropdown(command: string) {
|
||||
switch (command) {
|
||||
case "logout":
|
||||
handleLogout()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(userStore.getMyProfile)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-menu router mode="horizontal" :default-active="$route.path">
|
||||
<el-menu-item index="/">题库</el-menu-item>
|
||||
<el-menu-item index="/contest">竞赛</el-menu-item>
|
||||
<el-menu-item index="/status">提交</el-menu-item>
|
||||
<el-menu-item index="/rank">排名</el-menu-item>
|
||||
</el-menu>
|
||||
<div v-if="userStore.isFinished && !userStore.isAuthed" class="actions">
|
||||
<el-button @click="loginStore.show">登录</el-button>
|
||||
<el-button @click="signupStore.show">注册</el-button>
|
||||
</div>
|
||||
<div v-if="userStore.isFinished && userStore.isAuthed" class="actions">
|
||||
<el-dropdown @command="handleDropdown">
|
||||
<el-button>{{ userStore.user.username }}</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item>我的主页</el-dropdown-item>
|
||||
<el-dropdown-item>我的提交</el-dropdown-item>
|
||||
<el-dropdown-item>我的设置</el-dropdown-item>
|
||||
<el-dropdown-item v-if="userStore.isAdminRole">
|
||||
后台管理
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item divided command="logout">退出</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.el-menu {
|
||||
flex: 1;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: solid 1px var(--el-menu-border-color);
|
||||
}
|
||||
</style>
|
||||
@@ -1,16 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { useSignupStore } from "../stores/signup"
|
||||
const store = useSignupStore()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
v-model="store.visible"
|
||||
title="注册"
|
||||
>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -9,7 +9,7 @@ defineProps<Props>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-tag :type="JUDGE_STATUS[result]['type']" disable-transitions>
|
||||
<el-tag :type="(JUDGE_STATUS[result]['type'] as any)" disable-transitions>
|
||||
{{ JUDGE_STATUS[result]["name"] }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import Login from "../shared/user/login.vue"
|
||||
import Signup from "./components/signup.vue"
|
||||
import Header from "./components/header.vue"
|
||||
import Signup from "../shared/user/signup.vue"
|
||||
import Header from "../shared/layout/header.vue"
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<el-header class="header">
|
||||
<Header />
|
||||
</el-header>
|
||||
<el-main><router-view></router-view></el-main>
|
||||
@@ -16,7 +16,7 @@ import Header from "./components/header.vue"
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.el-header {
|
||||
.header {
|
||||
display: flex;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { useToggle } from "@vueuse/core"
|
||||
import { TabsPaneContext } from "element-plus"
|
||||
import { inject, onMounted, Ref, ref } from "vue"
|
||||
import { Problem } from "../../../utils/types"
|
||||
import { submissionExists } from "../../api"
|
||||
import SubmitPanel from "./submit-panel.vue"
|
||||
|
||||
const tab = ref("testcase")
|
||||
const submitPanelRef = ref<{ submit: Function }>()
|
||||
const problem = inject<Ref<Problem>>("problem")
|
||||
const problem = inject("problem") as Problem
|
||||
const id = ref(problem.id)
|
||||
const [tried] = useToggle()
|
||||
|
||||
onMounted(() => {
|
||||
@@ -16,7 +15,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
async function checkIfTried() {
|
||||
const res = await submissionExists(problem!.value.id)
|
||||
const res = await submissionExists(id.value)
|
||||
tried.value = res.data
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import loader, { Monaco } from "@monaco-editor/loader"
|
||||
import { ref, onBeforeUnmount, onMounted, watch, reactive, provide } from "vue"
|
||||
import {
|
||||
LANGUAGE_LABEL,
|
||||
LANGUAGE_VALUE,
|
||||
|
||||
@@ -29,7 +29,10 @@ defineProps<Props>()
|
||||
{{ problem.memory_limit }}MB
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="难度">
|
||||
<el-tag disable-transitions :type="getTagColor(problem.difficulty)">
|
||||
<el-tag
|
||||
disable-transitions
|
||||
:type="(getTagColor(problem.difficulty) as any)"
|
||||
>
|
||||
{{ DIFFICULTY[problem.difficulty] }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { useTimeout, useTimeoutFn, useToggle } from "@vueuse/core"
|
||||
import { computed, inject, Ref, ref, watch } from "vue"
|
||||
import party from "party-js"
|
||||
import { useRoute } from "vue-router"
|
||||
import {
|
||||
SOURCES,
|
||||
JUDGE_STATUS,
|
||||
@@ -19,12 +16,16 @@ import {
|
||||
SubmitCodePayload,
|
||||
} from "../../../utils/types"
|
||||
import { getSubmission, submitCode } from "../../api"
|
||||
|
||||
import SubmissionResultTag from "../../components/submission-result-tag.vue"
|
||||
|
||||
const code = inject<{ value: string; language: LANGUAGE }>("code", {
|
||||
value: "",
|
||||
language: "C",
|
||||
})
|
||||
const problem = inject<Ref<Problem>>("problem")
|
||||
const problem = inject("problem") as Problem
|
||||
const template = ref(problem.template)
|
||||
const id = ref(problem.id)
|
||||
|
||||
const route = useRoute()
|
||||
const contestID = <string>route.params.contestID || ""
|
||||
@@ -79,7 +80,7 @@ const submitDisabled = computed(() => {
|
||||
const value = code.value
|
||||
if (
|
||||
value.trim() === "" ||
|
||||
value === problem!.value.template[code.language] ||
|
||||
value === template.value[code.language] ||
|
||||
value === SOURCES[code.language]
|
||||
) {
|
||||
return true
|
||||
@@ -151,7 +152,7 @@ const infoTable = computed(() => {
|
||||
|
||||
async function submit() {
|
||||
const data: SubmitCodePayload = {
|
||||
problem_id: problem!.value.id,
|
||||
problem_id: id.value,
|
||||
language: code.language,
|
||||
code: code.value,
|
||||
}
|
||||
@@ -198,7 +199,7 @@ defineExpose({ submit })
|
||||
<el-alert
|
||||
v-if="submission"
|
||||
:closable="false"
|
||||
:type="JUDGE_STATUS[submission.result]['alertType']"
|
||||
:type="(JUDGE_STATUS[submission.result]['alertType'] as any)"
|
||||
:title="JUDGE_STATUS[submission.result]['name']"
|
||||
>
|
||||
</el-alert>
|
||||
|
||||
@@ -4,7 +4,6 @@ import ProblemContent from "./components/problem-content.vue"
|
||||
import ProblemInfo from "./components/problem-info.vue"
|
||||
import { getProblem } from "../api"
|
||||
import { isDesktop, isMobile } from "../../utils/breakpoints"
|
||||
import { provide, readonly } from "vue"
|
||||
|
||||
interface Props {
|
||||
problemID: string
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, reactive, watch } from "vue"
|
||||
import { useRoute, useRouter } from "vue-router"
|
||||
import { useUserStore } from "../../shared/stores/user"
|
||||
import { filterEmptyValue, getTagColor } from "../../utils/functions"
|
||||
import { isDesktop } from "../../utils/breakpoints"
|
||||
@@ -22,7 +20,7 @@ const total = ref(0)
|
||||
const { data: tags } = getProblemTagList()
|
||||
|
||||
const query = reactive({
|
||||
keyword: route.query.keyword || "",
|
||||
keyword: (route.query.keyword as string) || "",
|
||||
difficulty: route.query.difficulty || "",
|
||||
tag: route.query.tag || "",
|
||||
page: parseInt(<string>route.query.page) || 1,
|
||||
@@ -30,7 +28,7 @@ const query = reactive({
|
||||
})
|
||||
|
||||
async function listProblems() {
|
||||
query.keyword = route.query.keyword || ""
|
||||
query.keyword = (route.query.keyword as string) || ""
|
||||
query.difficulty = route.query.difficulty || ""
|
||||
query.tag = route.query.tag || ""
|
||||
query.page = parseInt(<string>route.query.page) || 1
|
||||
@@ -155,7 +153,10 @@ 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)">
|
||||
<el-tag
|
||||
disable-transitions
|
||||
:type="(getTagColor(scope.row.difficulty) as any)"
|
||||
>
|
||||
{{ scope.row.difficulty }}
|
||||
</el-tag>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<template>status detail</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import { useToggle } from "@vueuse/core"
|
||||
import { defineStore } from "pinia"
|
||||
|
||||
export const useSignupStore = defineStore("signup", () => {
|
||||
const [visible] = useToggle()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user