remove contest helper.

This commit is contained in:
2023-02-10 11:01:21 +08:00
parent 951b4c768e
commit c106f4bb5f
4 changed files with 58 additions and 74 deletions

View File

@@ -0,0 +1,54 @@
<script setup lang="ts">
import { DropdownOption } from "naive-ui"
import { useContestStore } from "oj/store/contest"
import { isDesktop } from "~/shared/composables/breakpoints"
const route = useRoute()
const router = useRouter()
const contestStore = useContestStore()
const contestMenuVisible = computed(() => {
if (contestStore.isContestAdmin) return true
if (!contestStore.isPrivate) {
// TODO:这里没有完成
}
return contestStore.access
})
function goto(name: string) {
router.push({ name: "contest " + name })
}
function getCurrentType(name: string): "primary" | "default" {
if (route.name === "contest " + name) return "primary"
return "default"
}
const options: DropdownOption[] = [
{ label: "比赛题目", key: "problems" },
{ label: "提交信息", key: "submissions" },
{ label: "比赛排名", key: "rank" },
]
</script>
<template>
<div v-if="contestMenuVisible">
<n-space v-if="isDesktop">
<n-button :type="getCurrentType('problems')" @click="goto('problems')">
比赛题目
</n-button>
<n-button
:type="getCurrentType('submissions')"
@click="goto('submissions')"
>
提交信息
</n-button>
<n-button :type="getCurrentType('rank')" @click="goto('rank')">
比赛排名
</n-button>
</n-space>
<n-dropdown v-else :options="options" trigger="click" @select="goto">
<n-button>菜单</n-button>
</n-dropdown>
</div>
</template>
<style scoped></style>