add countdown.

This commit is contained in:
2023-03-03 12:46:58 +08:00
parent b07489723c
commit 18a20c04c5
10 changed files with 414 additions and 368 deletions

View File

@@ -2,6 +2,7 @@
import { DropdownOption } from "naive-ui"
import { useContestStore } from "oj/store/contest"
import { isDesktop } from "~/shared/composables/breakpoints"
import { ContestStatus } from "~/utils/constants"
const route = useRoute()
const router = useRouter()
@@ -10,7 +11,7 @@ const contestStore = useContestStore()
const contestMenuVisible = computed(() => {
if (contestStore.isContestAdmin) return true
if (!contestStore.isPrivate) {
// TODO:这里没有完成
return contestStore.contestStatus !== ContestStatus.not_started
}
return contestStore.access
})

View File

@@ -1,6 +1,6 @@
<script setup lang="ts">
import { Contest } from "~/utils/types"
import { ContestType } from "~/utils/constants"
import { Contest } from "utils/types"
import { ContestType } from "utils/constants"
defineProps<{ contest: Contest }>()
</script>
@@ -8,6 +8,7 @@ defineProps<{ contest: Contest }>()
<n-space>
<span>{{ contest.title }}</span>
<n-icon
size="medium"
class="lockIcon"
v-if="contest.contest_type === ContestType.private"
>

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { CONTEST_STATUS } from "utils/constants"
import { CONTEST_STATUS, ContestStatus } from "utils/constants"
import { isDesktop } from "~/shared/composables/breakpoints"
import { useContestStore } from "../store/contest"
import ContestInfo from "./components/ContestInfo.vue"
@@ -12,7 +12,13 @@ const contestStore = useContestStore()
const password = ref("")
onMounted(() => contestStore.init(props.contestID))
onMounted(() => {
contestStore.init(props.contestID)
})
onBeforeUnmount(() => {
contestStore.clear()
})
const passwordFormVisible = computed(
() =>
@@ -26,15 +32,15 @@ const passwordFormVisible = computed(
<div v-if="contestStore.contest">
<n-space class="title" align="center" justify="space-between">
<n-space align="center">
<n-tag :type="CONTEST_STATUS[contestStore.contest.status]['type']">
{{ CONTEST_STATUS[contestStore.contest.status]["name"] }}
</n-tag>
<h2 class="contestTitle">{{ contestStore.contest.title }}</h2>
<n-icon v-if="contestStore.isPrivate" class="lockIcon">
<n-icon size="large" v-if="contestStore.isPrivate" class="lockIcon">
<i-ep-lock />
</n-icon>
<n-tag :type="CONTEST_STATUS[contestStore.contestStatus]['type']">
{{ contestStore.countdown }}
</n-tag>
</n-space>
<n-space>
<n-space align="center">
<ContestInfo />
<ContestMenu />
</n-space>

View File

@@ -35,11 +35,9 @@ function rowProps(row: ProblemFiltered) {
<n-data-table
striped
size="small"
class="problems"
:data="contestStore.problems"
:columns="problemsColumns"
:row-props="rowProps"
v-if="contestStore.problems?.length"
/>
</template>