在题目详情页显示数据统计
This commit is contained in:
@@ -9,6 +9,7 @@ import { createTestSubmission } from "~/utils/judge"
|
||||
import storage from "~/utils/storage"
|
||||
import { LANGUAGE } from "~/utils/types"
|
||||
import Submit from "./Submit.vue"
|
||||
import StatisticsPanel from "~/shared/components/StatisticsPanel.vue"
|
||||
|
||||
interface Props {
|
||||
storageKey: string
|
||||
@@ -26,6 +27,8 @@ const userStore = useUserStore()
|
||||
|
||||
const emit = defineEmits(["changeLanguage"])
|
||||
|
||||
const statisticPanel = ref(false)
|
||||
|
||||
function copy() {
|
||||
copyText(code.value)
|
||||
message.success("代码复制成功")
|
||||
@@ -58,8 +61,7 @@ async function test() {
|
||||
}
|
||||
|
||||
const menu = computed<DropdownOption[]>(() => [
|
||||
{ label: "提交信息", key: "submissions", show: isMobile.value },
|
||||
{ label: "自测猫", key: "test", show: isMobile.value },
|
||||
{ label: "去自测猫", key: "test", show: isMobile.value },
|
||||
{ label: "复制代码", key: "copy" },
|
||||
{ label: "重置代码", key: "reset" },
|
||||
])
|
||||
@@ -82,9 +84,6 @@ const options: DropdownOption[] = problem.value!.languages.map((it) => ({
|
||||
|
||||
async function select(key: string) {
|
||||
switch (key) {
|
||||
case "submissions":
|
||||
goSubmissions()
|
||||
break
|
||||
case "reset":
|
||||
reset()
|
||||
break
|
||||
@@ -106,6 +105,10 @@ function gotoTestCat() {
|
||||
const url = import.meta.env.PUBLIC_CODE_URL
|
||||
window.open(url, "_blank")
|
||||
}
|
||||
|
||||
function showStatisticsPanel() {
|
||||
statisticPanel.value = true
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -124,19 +127,38 @@ function gotoTestCat() {
|
||||
<n-flex align="center" v-if="!withTest">
|
||||
<Submit />
|
||||
<n-button v-if="isDesktop" @click="gotoTestCat">自测猫</n-button>
|
||||
<n-button v-if="isDesktop" @click="goSubmissions">提交信息</n-button>
|
||||
<n-button
|
||||
:size="isDesktop ? 'medium' : 'small'"
|
||||
v-if="!userStore.isSuperAdmin && userStore.showSubmissions"
|
||||
@click="goSubmissions"
|
||||
>
|
||||
提交信息
|
||||
</n-button>
|
||||
<n-button
|
||||
:size="isDesktop ? 'medium' : 'small'"
|
||||
v-if="userStore.isSuperAdmin"
|
||||
@click="showStatisticsPanel"
|
||||
>
|
||||
数据统计
|
||||
</n-button>
|
||||
<n-dropdown size="large" :options="menu" @select="select">
|
||||
<n-button :size="isDesktop ? 'medium' : 'small'">操作</n-button>
|
||||
</n-dropdown>
|
||||
<n-button
|
||||
v-if="isDesktop && userStore.isSuperAdmin"
|
||||
type="warning"
|
||||
@click="goEdit"
|
||||
>
|
||||
<n-button v-if="isDesktop && userStore.isSuperAdmin" @click="goEdit">
|
||||
编辑
|
||||
</n-button>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
<n-modal
|
||||
v-if="userStore.isSuperAdmin"
|
||||
v-model:show="statisticPanel"
|
||||
preset="card"
|
||||
:style="{ maxWidth: isDesktop && '70vw', maxHeight: '80vh' }"
|
||||
:content-style="{ overflow: 'auto' }"
|
||||
title="提交记录的统计"
|
||||
>
|
||||
<StatisticsPanel :problem="problem!._id" username="" />
|
||||
</n-modal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -55,7 +55,7 @@ const numbers = computed(() => {
|
||||
{
|
||||
icon: "streamline-emojis:sparkles",
|
||||
title: parseFloat(beatRate.value),
|
||||
content: "你击败的用户",
|
||||
content: "击败用户",
|
||||
int: false,
|
||||
suffix: "%",
|
||||
},
|
||||
|
||||
@@ -75,16 +75,9 @@ const query = reactive({
|
||||
page: 1,
|
||||
})
|
||||
|
||||
const showList = computed(() => {
|
||||
if (!userStore.isAuthed) return false
|
||||
else if (userStore.isSuperAdmin) return true
|
||||
else return configStore.config.submission_list_show_all
|
||||
})
|
||||
|
||||
const errorMsg = computed(() => {
|
||||
if (!userStore.isAuthed) return "请先登录"
|
||||
else if (!configStore.config.submission_list_show_all)
|
||||
return "提交列表已被管理员关闭"
|
||||
else if (!userStore.showSubmissions) return "提交列表已被管理员关闭"
|
||||
else return ""
|
||||
})
|
||||
|
||||
@@ -102,7 +95,6 @@ async function listSubmissions() {
|
||||
}
|
||||
|
||||
async function getRankOfThisProblem() {
|
||||
|
||||
loading.value = true
|
||||
const res = await getRankOfProblem(<string>route.params.problemID ?? "")
|
||||
loading.value = false
|
||||
@@ -122,7 +114,12 @@ onMounted(() => {
|
||||
watch(query, listSubmissions)
|
||||
</script>
|
||||
<template>
|
||||
<n-alert class="tip" type="error" v-if="!showList" :title="errorMsg" />
|
||||
<n-alert
|
||||
class="tip"
|
||||
type="error"
|
||||
v-if="!userStore.showSubmissions"
|
||||
:title="errorMsg"
|
||||
/>
|
||||
|
||||
<template v-if="!loading && route.name === 'problem' && userStore.isAuthed">
|
||||
<template v-if="class_name">
|
||||
@@ -134,7 +131,7 @@ watch(query, listSubmissions)
|
||||
>,你们班共有 <b>{{ class_ac_count }}</b> 人答案正确
|
||||
</div>
|
||||
<n-button
|
||||
v-if="showList"
|
||||
v-if="userStore.showSubmissions"
|
||||
@click="
|
||||
router.push({
|
||||
name: 'submissions',
|
||||
@@ -153,7 +150,12 @@ watch(query, listSubmissions)
|
||||
</n-flex>
|
||||
</template>
|
||||
</n-alert>
|
||||
<n-alert class="tip" type="error" :show-icon="false" v-if="rank === -1 && class_ac_count > 0">
|
||||
<n-alert
|
||||
class="tip"
|
||||
type="error"
|
||||
:show-icon="false"
|
||||
v-if="rank === -1 && class_ac_count > 0"
|
||||
>
|
||||
<template #header>
|
||||
<n-flex>
|
||||
<div>
|
||||
@@ -162,7 +164,7 @@ watch(query, listSubmissions)
|
||||
共有 <b>{{ class_ac_count }}</b> 人答案正确
|
||||
</div>
|
||||
<n-button
|
||||
v-if="showList"
|
||||
v-if="userStore.showSubmissions"
|
||||
secondary
|
||||
@click="
|
||||
router.push({
|
||||
@@ -194,7 +196,7 @@ watch(query, listSubmissions)
|
||||
<div></div>
|
||||
<n-button
|
||||
secondary
|
||||
v-if="showList"
|
||||
v-if="userStore.showSubmissions"
|
||||
@click="
|
||||
router.push({
|
||||
name: 'submissions',
|
||||
@@ -212,7 +214,12 @@ watch(query, listSubmissions)
|
||||
</n-flex>
|
||||
</template>
|
||||
</n-alert>
|
||||
<n-alert class="tip" type="error" :show-icon="false" v-if="rank === -1 && all_ac_count > 0">
|
||||
<n-alert
|
||||
class="tip"
|
||||
type="error"
|
||||
:show-icon="false"
|
||||
v-if="rank === -1 && all_ac_count > 0"
|
||||
>
|
||||
<template #header>
|
||||
<n-flex align="center">
|
||||
<div>
|
||||
@@ -220,7 +227,7 @@ watch(query, listSubmissions)
|
||||
<b>{{ all_ac_count }}</b> 人答案正确
|
||||
</div>
|
||||
<n-button
|
||||
v-if="showList"
|
||||
v-if="userStore.showSubmissions"
|
||||
secondary
|
||||
@click="
|
||||
router.push({
|
||||
@@ -242,7 +249,7 @@ watch(query, listSubmissions)
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<template v-if="showList">
|
||||
<template v-if="userStore.showSubmissions">
|
||||
<n-data-table striped :columns="columns" :data="submissions" />
|
||||
<Pagination
|
||||
:total="total"
|
||||
|
||||
@@ -51,7 +51,6 @@ const { query, clearQuery } = usePagination<ProblemQuery>({
|
||||
author: useRouteQuery("author", "").value,
|
||||
})
|
||||
|
||||
|
||||
async function listProblems() {
|
||||
if (query.page < 1) query.page = 1
|
||||
const offset = (query.page - 1) * query.limit
|
||||
|
||||
Reference in New Issue
Block a user