@@ -1,16 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
NModal,
|
||||
NForm,
|
||||
NFormItem,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NSelect,
|
||||
NButton,
|
||||
NFlex,
|
||||
NImage,
|
||||
} from "naive-ui"
|
||||
|
||||
interface Props {
|
||||
show: boolean
|
||||
}
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
NModal,
|
||||
NForm,
|
||||
NFormItem,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NSwitch,
|
||||
NButton,
|
||||
NFlex,
|
||||
} from "naive-ui"
|
||||
|
||||
interface Props {
|
||||
show: boolean
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { h } from "vue"
|
||||
import { NDataTable, NButton, NFlex, NImage } from "naive-ui"
|
||||
import { ProblemSetBadge } from "utils/types"
|
||||
import { NButton, NImage } from "naive-ui"
|
||||
|
||||
interface Props {
|
||||
badges: ProblemSetBadge[]
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
NModal,
|
||||
NForm,
|
||||
NFormItem,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NSelect,
|
||||
NButton,
|
||||
NFlex,
|
||||
NImage,
|
||||
} from "naive-ui"
|
||||
import { ProblemSetBadge } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -1,14 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
NModal,
|
||||
NForm,
|
||||
NFormItem,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NSwitch,
|
||||
NButton,
|
||||
NFlex,
|
||||
} from "naive-ui"
|
||||
import { ProblemSetProblem } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { NCard, NTag, NButton, NFlex } from "naive-ui"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { ProblemSet } from "utils/types"
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ const progressColumns = [
|
||||
title: "进度",
|
||||
key: "progress_percentage",
|
||||
width: 100,
|
||||
render: (row: ProblemSetProgress) => `${row.progress_percentage}%`,
|
||||
render: (row: ProblemSetProgress) => `${row.progress_percentage.toFixed(0)}%`,
|
||||
},
|
||||
{
|
||||
title: "是否完成",
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { NSwitch, NSelect, NTag } from "naive-ui"
|
||||
import Pagination from "shared/components/Pagination.vue"
|
||||
import { usePagination } from "shared/composables/pagination"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { ProblemSetList } from "utils/types"
|
||||
import {
|
||||
getProblemSetList,
|
||||
toggleProblemSetVisible,
|
||||
updateProblemSetStatus,
|
||||
deleteProblemSet,
|
||||
} from "../api"
|
||||
import { getProblemSetList, toggleProblemSetVisible } from "../api"
|
||||
import Actions from "./components/Actions.vue"
|
||||
import { NTag, NSwitch } from "naive-ui"
|
||||
|
||||
const total = ref(0)
|
||||
const problemSets = ref<ProblemSetList[]>([])
|
||||
|
||||
@@ -359,3 +359,8 @@ export function getUserBadges() {
|
||||
export function getProblemSetBadges(problemSetId: number) {
|
||||
return http.get(`problemset/${problemSetId}/badges`)
|
||||
}
|
||||
|
||||
// 获取题单用户进度列表
|
||||
export function getProblemSetUserProgress(problemSetId: number) {
|
||||
return http.get(`problemset/${problemSetId}/users_progress`)
|
||||
}
|
||||
|
||||
@@ -18,10 +18,13 @@ type Sample = Problem["samples"][number] & {
|
||||
const theme = useThemeVars()
|
||||
const style = computed(() => "color: " + theme.value.primaryColor)
|
||||
|
||||
const route = useRoute()
|
||||
const codeStore = useCodeStore()
|
||||
const problemStore = useProblemStore()
|
||||
const { problem } = storeToRefs(problemStore)
|
||||
|
||||
const problemSetId = computed(() => route.params.problemSetId)
|
||||
|
||||
// 判断用户是否尝试过但未通过
|
||||
// my_status === 0: 已通过
|
||||
// my_status !== 0 && my_status !== null: 尝试过但未通过
|
||||
@@ -106,6 +109,7 @@ function type(status: ProblemStatus) {
|
||||
|
||||
<template>
|
||||
<div v-if="problem" class="problemContent">
|
||||
<template v-if="!problemSetId">
|
||||
<!-- 已通过 -->
|
||||
<n-alert
|
||||
class="status-alert"
|
||||
@@ -124,6 +128,8 @@ function type(status: ProblemStatus) {
|
||||
>
|
||||
不要放弃!仔细检查代码逻辑,或者寻求 AI 的帮助获取灵感。
|
||||
</n-alert>
|
||||
</template>
|
||||
|
||||
<n-flex align="center">
|
||||
<n-tag>{{ problem._id }}</n-tag>
|
||||
<h2 class="problemTitle">{{ problem.title }}</h2>
|
||||
|
||||
@@ -130,13 +130,26 @@ watch(isMobile, (value) => {
|
||||
>
|
||||
<ProblemFlowchart />
|
||||
</n-tab-pane>
|
||||
<n-tab-pane name="info" tab="题目统计">
|
||||
<n-tab-pane
|
||||
name="info"
|
||||
tab="题目统计"
|
||||
:disabled="!!props.problemSetId"
|
||||
>
|
||||
<ProblemInfo />
|
||||
</n-tab-pane>
|
||||
<n-tab-pane v-if="!props.contestID" name="comment" tab="题目点评">
|
||||
<n-tab-pane
|
||||
v-if="!props.contestID"
|
||||
name="comment"
|
||||
tab="题目点评"
|
||||
:disabled="!!props.problemSetId"
|
||||
>
|
||||
<ProblemComment />
|
||||
</n-tab-pane>
|
||||
<n-tab-pane name="submission" tab="我的提交">
|
||||
<n-tab-pane
|
||||
name="submission"
|
||||
tab="我的提交"
|
||||
:disabled="!!props.problemSetId"
|
||||
>
|
||||
<ProblemSubmission />
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
@@ -151,13 +164,22 @@ watch(isMobile, (value) => {
|
||||
<n-tab-pane name="editor" tab="代码">
|
||||
<component :is="inProblem ? ProblemEditor : ContestEditor" />
|
||||
</n-tab-pane>
|
||||
<n-tab-pane name="info" tab="统计">
|
||||
<n-tab-pane name="info" tab="统计" :disabled="!!props.problemSetId">
|
||||
<ProblemInfo />
|
||||
</n-tab-pane>
|
||||
<n-tab-pane v-if="!props.contestID" name="comment" tab="点评">
|
||||
<n-tab-pane
|
||||
v-if="!props.contestID"
|
||||
name="comment"
|
||||
tab="点评"
|
||||
:disabled="!!props.problemSetId"
|
||||
>
|
||||
<ProblemComment />
|
||||
</n-tab-pane>
|
||||
<n-tab-pane name="submission" tab="提交">
|
||||
<n-tab-pane
|
||||
name="submission"
|
||||
tab="提交"
|
||||
:disabled="!!props.problemSetId"
|
||||
>
|
||||
<ProblemSubmission />
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
|
||||
106
src/oj/problemset/components/ProblemSetHeader.vue
Normal file
106
src/oj/problemset/components/ProblemSetHeader.vue
Normal file
@@ -0,0 +1,106 @@
|
||||
<script setup lang="ts">
|
||||
import { Icon } from "@iconify/vue"
|
||||
import { ProblemSet, UserBadge as UserBadgeType } from "utils/types"
|
||||
import UserBadge from "shared/components/UserBadge.vue"
|
||||
|
||||
interface Props {
|
||||
problemSet: ProblemSet
|
||||
isJoined: boolean
|
||||
isJoining: boolean
|
||||
userBadges: UserBadgeType[]
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'join'): void
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
function getDifficultyTag(difficulty: string) {
|
||||
const difficultyMap: Record<
|
||||
string,
|
||||
{ type: "success" | "warning" | "error" | "default"; text: string }
|
||||
> = {
|
||||
Easy: { type: "success", text: "简单" },
|
||||
Medium: { type: "warning", text: "中等" },
|
||||
Hard: { type: "error", text: "困难" },
|
||||
}
|
||||
return difficultyMap[difficulty] || { type: "default", text: "未知" }
|
||||
}
|
||||
|
||||
function getProgressPercentage() {
|
||||
if (!props.problemSet) return 0
|
||||
return Math.round(
|
||||
(props.problemSet.completed_count / props.problemSet.problems_count) * 100,
|
||||
)
|
||||
}
|
||||
|
||||
function handleJoin() {
|
||||
emit('join')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<n-card style="margin-bottom: 24px;">
|
||||
<n-flex justify="space-between" align="center">
|
||||
<n-flex align="center">
|
||||
<n-tag type="warning" v-if="problemSet.status === 'archived'">
|
||||
已归档
|
||||
</n-tag>
|
||||
<n-tag :type="getDifficultyTag(problemSet.difficulty).type">
|
||||
{{ getDifficultyTag(problemSet.difficulty).text }}
|
||||
</n-tag>
|
||||
<n-h2 style="margin: 0">{{ problemSet.title }}</n-h2>
|
||||
<n-tooltip trigger="hover" v-if="problemSet.description">
|
||||
<template #trigger>
|
||||
<Icon width="20" icon="emojione:information" />
|
||||
</template>
|
||||
{{ problemSet.description }}
|
||||
</n-tooltip>
|
||||
</n-flex>
|
||||
|
||||
<n-flex align="center">
|
||||
<!-- 用户徽章显示区域 - 只在已加入且有徽章时显示 -->
|
||||
<n-flex v-if="isJoined && userBadges.length > 0" align="center">
|
||||
<n-text>已获徽章</n-text>
|
||||
<UserBadge
|
||||
v-for="badge in userBadges"
|
||||
:key="badge.id"
|
||||
:badge="badge"
|
||||
/>
|
||||
</n-flex>
|
||||
|
||||
<!-- 完成进度 - 只在已加入时显示 -->
|
||||
<n-flex align="center" v-if="isJoined">
|
||||
<n-text strong>完成进度</n-text>
|
||||
<n-text>
|
||||
{{ problemSet.completed_count }} / {{ problemSet.problems_count }}
|
||||
</n-text>
|
||||
</n-flex>
|
||||
<n-progress
|
||||
v-if="isJoined"
|
||||
:percentage="getProgressPercentage()"
|
||||
:height="8"
|
||||
:border-radius="4"
|
||||
style="width: 200px"
|
||||
/>
|
||||
<n-button
|
||||
v-if="!isJoined"
|
||||
type="primary"
|
||||
size="large"
|
||||
:loading="isJoining"
|
||||
@click="handleJoin"
|
||||
>
|
||||
加入题单
|
||||
</n-button>
|
||||
<n-tag v-else type="success" size="large">
|
||||
<template #icon>
|
||||
<Icon icon="material-symbols:check-circle" />
|
||||
</template>
|
||||
已加入
|
||||
</n-tag>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
</n-card>
|
||||
</template>
|
||||
81
src/oj/problemset/components/ProblemSetProblemsList.vue
Normal file
81
src/oj/problemset/components/ProblemSetProblemsList.vue
Normal file
@@ -0,0 +1,81 @@
|
||||
<script setup lang="ts">
|
||||
import { Icon } from "@iconify/vue"
|
||||
import { ProblemSetProblem } from "utils/types"
|
||||
import { DIFFICULTY } from "utils/constants"
|
||||
import { getTagColor } from "utils/functions"
|
||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||
|
||||
interface Props {
|
||||
problems: ProblemSetProblem[]
|
||||
isJoined: boolean
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'problem-click', problemId: string): void
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const { isDesktop } = useBreakpoints()
|
||||
|
||||
function handleProblemClick(problemId: string) {
|
||||
emit('problem-click', problemId)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<n-grid :cols="isDesktop ? 4 : 1" :x-gap="16" :y-gap="16">
|
||||
<n-grid-item
|
||||
v-for="(problemSetProblem, index) in problems"
|
||||
:key="problemSetProblem.id"
|
||||
>
|
||||
<n-card
|
||||
hoverable
|
||||
@click="handleProblemClick(problemSetProblem.problem._id)"
|
||||
style="cursor: pointer"
|
||||
>
|
||||
<n-flex align="center">
|
||||
<Icon
|
||||
style="margin-right: 10px"
|
||||
width="48"
|
||||
icon="noto:check-mark-button"
|
||||
v-if="problemSetProblem.is_completed"
|
||||
/>
|
||||
|
||||
<n-flex vertical style="flex: 1">
|
||||
<n-flex align="center">
|
||||
<n-h4 style="margin: 0">#{{ index + 1 }}</n-h4>
|
||||
<n-h4 style="margin: 0">
|
||||
{{ problemSetProblem.problem.title }}
|
||||
</n-h4>
|
||||
</n-flex>
|
||||
|
||||
<n-flex align="center" size="small">
|
||||
<n-tag
|
||||
:type="getTagColor(problemSetProblem.problem.difficulty)"
|
||||
size="small"
|
||||
>
|
||||
{{ DIFFICULTY[problemSetProblem.problem.difficulty] }}
|
||||
</n-tag>
|
||||
<n-text type="info">分数:{{ problemSetProblem.score }}</n-text>
|
||||
<n-text v-if="!problemSetProblem.is_required">(选做)</n-text>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</n-grid>
|
||||
<div class="tip">
|
||||
<n-text depth="3">题目完成后会自动返回题单页面</n-text>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tip {
|
||||
padding-top: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
157
src/oj/problemset/components/UserProgressView.vue
Normal file
157
src/oj/problemset/components/UserProgressView.vue
Normal file
@@ -0,0 +1,157 @@
|
||||
<script setup lang="ts">
|
||||
import { h, computed, ref, onMounted } from "vue"
|
||||
import { Icon } from "@iconify/vue"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { ProblemSetProgress } from "utils/types"
|
||||
import { getProblemSetUserProgress } from "../../api"
|
||||
import { NP, NProgress, NTag, useMessage } from "naive-ui"
|
||||
|
||||
const message = useMessage()
|
||||
|
||||
const route = useRoute()
|
||||
const problemSetId = computed(() => Number(route.params.problemSetId))
|
||||
const progress = ref<ProblemSetProgress[]>([])
|
||||
const loading = ref(false)
|
||||
|
||||
// 加载用户进度数据
|
||||
async function loadUserProgress() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await getProblemSetUserProgress(problemSetId.value)
|
||||
progress.value = res.data
|
||||
} catch (err: any) {
|
||||
message.error("加载用户进度失败:" + (err.data || "未知错误"))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 计算统计数据
|
||||
const stats = computed(() => {
|
||||
const total = progress.value.length
|
||||
const completed = progress.value.filter((p) => p.is_completed).length
|
||||
const avgProgress =
|
||||
total > 0
|
||||
? progress.value.reduce((sum, p) => sum + p.progress_percentage, 0) /
|
||||
total
|
||||
: 0
|
||||
|
||||
return {
|
||||
total,
|
||||
completed,
|
||||
avgProgress: Math.round(avgProgress),
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(loadUserProgress)
|
||||
|
||||
// 定义表格列
|
||||
const progressColumns = [
|
||||
{
|
||||
title: "排名",
|
||||
key: "rank",
|
||||
width: 80,
|
||||
render: (row: ProblemSetProgress, index: number) => index + 1,
|
||||
},
|
||||
{
|
||||
title: "用户",
|
||||
key: "user.username",
|
||||
width: 120,
|
||||
render: (row: ProblemSetProgress) => row.user.username,
|
||||
},
|
||||
{
|
||||
title: "加入时间",
|
||||
key: "join_time",
|
||||
width: 180,
|
||||
render: (row: ProblemSetProgress) =>
|
||||
parseTime(row.join_time, "YYYY-MM-DD HH:mm:ss"),
|
||||
},
|
||||
{
|
||||
title: "已完成数量",
|
||||
key: "completed_problems_count",
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: "已完成题目",
|
||||
key: "completed_problems",
|
||||
width: 300,
|
||||
render: (row: ProblemSetProgress) => {
|
||||
return h("div", { style: "max-height: 120px; overflow-y: auto" }, [
|
||||
h(
|
||||
"div",
|
||||
{ style: "display: flex; flex-wrap: wrap; gap: 4px" },
|
||||
row.completed_problems.map((problem: any) =>
|
||||
h(
|
||||
NTag,
|
||||
{
|
||||
type: "success",
|
||||
size: "small",
|
||||
style: "margin: 2px",
|
||||
},
|
||||
`${problem._id}: ${problem.title}`,
|
||||
),
|
||||
),
|
||||
),
|
||||
])
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "进度",
|
||||
key: "progress_percentage",
|
||||
width: 120,
|
||||
render: (row: ProblemSetProgress) => {
|
||||
return `${row.progress_percentage.toFixed(0)}%`
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
key: "is_completed",
|
||||
width: 100,
|
||||
render: (row: ProblemSetProgress) => {
|
||||
if (row.is_completed) {
|
||||
return h(NTag, { type: "success" }, "已完成")
|
||||
} else {
|
||||
return h(NTag, { type: "warning" }, "进行中")
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<n-flex justify="space-between" align="center" style="margin-bottom: 16px">
|
||||
<n-h3 style="margin: 0">用户进度</n-h3>
|
||||
<n-text depth="3">共 {{ stats.total }} 人参与</n-text>
|
||||
</n-flex>
|
||||
|
||||
<!-- 统计信息卡片 -->
|
||||
<n-grid :cols="3" :x-gap="16" style="margin-bottom: 16px">
|
||||
<n-grid-item>
|
||||
<n-card size="small">
|
||||
<n-statistic label="总参与人数" :value="stats.total" />
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
<n-grid-item>
|
||||
<n-card size="small">
|
||||
<n-statistic label="已完成人数" :value="stats.completed" />
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
<n-grid-item>
|
||||
<n-card size="small">
|
||||
<n-statistic label="平均进度" :value="stats.avgProgress.toFixed(0) + '%'" />
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</n-grid>
|
||||
|
||||
<n-data-table
|
||||
:columns="progressColumns"
|
||||
:data="progress"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
:bordered="false"
|
||||
:single-line="false"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,28 +1,27 @@
|
||||
<script setup lang="ts">
|
||||
import { Icon } from "@iconify/vue"
|
||||
import {
|
||||
getProblemSetDetail,
|
||||
getProblemSetProblems,
|
||||
joinProblemSet,
|
||||
getUserBadges,
|
||||
} from "../api"
|
||||
import { getTagColor } from "utils/functions"
|
||||
import {
|
||||
ProblemSet,
|
||||
ProblemSetProblem,
|
||||
UserBadge as UserBadgeType,
|
||||
} from "utils/types"
|
||||
import { DIFFICULTY } from "utils/constants"
|
||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||
import UserBadge from "shared/components/UserBadge.vue"
|
||||
import { useFireworks } from "../problem/composables/useFireworks"
|
||||
import ProblemSetHeader from "./components/ProblemSetHeader.vue"
|
||||
import ProblemSetProblemsList from "./components/ProblemSetProblemsList.vue"
|
||||
import UserProgressView from "./components/UserProgressView.vue"
|
||||
import { useUserStore } from "shared/store/user"
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const message = useMessage()
|
||||
|
||||
const { isDesktop } = useBreakpoints()
|
||||
const { celebrate } = useFireworks()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const problemSetId = computed(() => Number(route.params.problemSetId))
|
||||
|
||||
@@ -31,25 +30,7 @@ const problems = ref<ProblemSetProblem[]>([])
|
||||
const isJoined = ref(false)
|
||||
const isJoining = ref(false)
|
||||
const userBadges = ref<UserBadgeType[]>([])
|
||||
|
||||
function getDifficultyTag(difficulty: string) {
|
||||
const difficultyMap: Record<
|
||||
string,
|
||||
{ type: "success" | "warning" | "error" | "default"; text: string }
|
||||
> = {
|
||||
Easy: { type: "success", text: "简单" },
|
||||
Medium: { type: "warning", text: "中等" },
|
||||
Hard: { type: "error", text: "困难" },
|
||||
}
|
||||
return difficultyMap[difficulty] || { type: "default", text: "未知" }
|
||||
}
|
||||
|
||||
function getProgressPercentage() {
|
||||
if (!problemSet.value) return 0
|
||||
return Math.round(
|
||||
(problemSet.value.completed_count / problemSet.value.problems_count) * 100,
|
||||
)
|
||||
}
|
||||
const activeTab = ref("problems")
|
||||
|
||||
async function loadProblemSetDetail() {
|
||||
const res = await getProblemSetDetail(problemSetId.value)
|
||||
@@ -112,123 +93,43 @@ async function handleJoinProblemSet() {
|
||||
}
|
||||
}
|
||||
|
||||
const showTabs = computed(
|
||||
() =>
|
||||
userStore.isSuperAdmin ||
|
||||
(isJoined.value && problemSet.value?.user_progress?.is_completed),
|
||||
)
|
||||
|
||||
onMounted(init)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="problemSet">
|
||||
<n-card style="margin-bottom: 24px">
|
||||
<n-flex justify="space-between" align="center">
|
||||
<n-flex align="center">
|
||||
<n-tag type="warning" v-if="problemSet.status === 'archived'">
|
||||
已归档
|
||||
</n-tag>
|
||||
<n-tag :type="getDifficultyTag(problemSet.difficulty).type">
|
||||
{{ getDifficultyTag(problemSet.difficulty).text }}
|
||||
</n-tag>
|
||||
<n-h2 style="margin: 0">{{ problemSet.title }}</n-h2>
|
||||
<n-tooltip trigger="hover" v-if="problemSet.description">
|
||||
<template #trigger>
|
||||
<Icon width="20" icon="emojione:information" />
|
||||
</template>
|
||||
{{ problemSet.description }}
|
||||
</n-tooltip>
|
||||
</n-flex>
|
||||
|
||||
<n-flex align="center">
|
||||
<!-- 用户徽章显示区域 - 只在已加入且有徽章时显示 -->
|
||||
<n-flex v-if="isJoined && userBadges.length > 0" align="center">
|
||||
<n-text>已获徽章</n-text>
|
||||
<UserBadge
|
||||
v-for="badge in userBadges"
|
||||
:key="badge.id"
|
||||
:badge="badge"
|
||||
<ProblemSetHeader
|
||||
:problem-set="problemSet"
|
||||
:is-joined="isJoined"
|
||||
:is-joining="isJoining"
|
||||
:user-badges="userBadges"
|
||||
@join="handleJoinProblemSet"
|
||||
/>
|
||||
</n-flex>
|
||||
|
||||
<!-- 完成进度 - 只在已加入时显示 -->
|
||||
<n-flex align="center" v-if="isJoined">
|
||||
<n-text strong>完成进度</n-text>
|
||||
<n-text>
|
||||
{{ problemSet.completed_count }} / {{ problemSet.problems_count }}
|
||||
</n-text>
|
||||
</n-flex>
|
||||
<n-progress
|
||||
v-if="isJoined"
|
||||
:percentage="getProgressPercentage()"
|
||||
:height="8"
|
||||
:border-radius="4"
|
||||
style="width: 200px"
|
||||
<n-tabs v-if="showTabs" v-model:value="activeTab" animated>
|
||||
<n-tab-pane name="problems" tab="题目列表">
|
||||
<ProblemSetProblemsList
|
||||
:problems="problems"
|
||||
:is-joined="isJoined"
|
||||
@problem-click="handleProblemClick"
|
||||
/>
|
||||
<n-button
|
||||
v-if="!isJoined"
|
||||
type="primary"
|
||||
size="large"
|
||||
:loading="isJoining"
|
||||
@click="handleJoinProblemSet"
|
||||
>
|
||||
加入题单
|
||||
</n-button>
|
||||
<n-tag v-else type="success" size="large">
|
||||
<template #icon>
|
||||
<Icon icon="material-symbols:check-circle" />
|
||||
</template>
|
||||
已加入
|
||||
</n-tag>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
</n-card>
|
||||
<n-grid :cols="isDesktop ? 4 : 1" :x-gap="16" :y-gap="16">
|
||||
<n-grid-item
|
||||
v-for="(problemSetProblem, index) in problems"
|
||||
:key="problemSetProblem.id"
|
||||
>
|
||||
<n-card
|
||||
hoverable
|
||||
@click="handleProblemClick(problemSetProblem.problem._id)"
|
||||
style="cursor: pointer"
|
||||
>
|
||||
<n-flex align="center">
|
||||
<Icon
|
||||
style="margin-right: 10px"
|
||||
width="48"
|
||||
icon="noto:check-mark-button"
|
||||
v-if="problemSetProblem.is_completed"
|
||||
</n-tab-pane>
|
||||
<n-tab-pane name="progress" tab="用户进度">
|
||||
<UserProgressView />
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
<ProblemSetProblemsList
|
||||
v-else
|
||||
:problems="problems"
|
||||
:is-joined="isJoined"
|
||||
@problem-click="handleProblemClick"
|
||||
/>
|
||||
|
||||
<n-flex vertical style="flex: 1">
|
||||
<n-flex align="center">
|
||||
<n-h4 style="margin: 0">#{{ index + 1 }}</n-h4>
|
||||
<n-h4 style="margin: 0">
|
||||
{{ problemSetProblem.problem.title }}
|
||||
</n-h4>
|
||||
</n-flex>
|
||||
|
||||
<n-flex align="center" size="small">
|
||||
<n-tag
|
||||
:type="getTagColor(problemSetProblem.problem.difficulty)"
|
||||
size="small"
|
||||
>
|
||||
{{ DIFFICULTY[problemSetProblem.problem.difficulty] }}
|
||||
</n-tag>
|
||||
<n-text type="info">分数:{{ problemSetProblem.score }}</n-text>
|
||||
<n-text v-if="!problemSetProblem.is_required">(选做)</n-text>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
</n-grid>
|
||||
|
||||
<div class="tip">
|
||||
<n-text>题目完成后会自动返回题单页面</n-text>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tip {
|
||||
padding-top: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
||||
@@ -104,8 +104,7 @@ watch(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<n-flex vertical size="large">
|
||||
<n-flex v-if="problemSets.length > 0" vertical size="large">
|
||||
<n-space>
|
||||
<n-space align="center">
|
||||
<n-text>难度:</n-text>
|
||||
@@ -136,7 +135,7 @@ watch(
|
||||
/>
|
||||
</n-space>
|
||||
|
||||
<n-grid :cols="isDesktop ? 4 : 1" :x-gap="16" :y-gap="16">
|
||||
<n-grid :cols="isDesktop ? 3 : 1" :x-gap="16" :y-gap="16">
|
||||
<n-grid-item v-for="problemSet in problemSets" :key="problemSet.id">
|
||||
<n-card
|
||||
hoverable
|
||||
@@ -158,35 +157,13 @@ watch(
|
||||
<n-text>{{ problemSet.problems_count }} 道题目</n-text>
|
||||
</n-flex>
|
||||
|
||||
<n-flex align="center" size="small">
|
||||
<n-tag type="warning" v-if="problemSet.status === 'archived'">
|
||||
已归档
|
||||
</n-tag>
|
||||
<n-tag
|
||||
v-if="problemSet.user_progress?.is_joined"
|
||||
type="success"
|
||||
size="small"
|
||||
>
|
||||
<template #icon>
|
||||
<Icon icon="material-symbols:check-circle" width="12" />
|
||||
</template>
|
||||
已加入
|
||||
</n-tag>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
|
||||
<n-flex align="center" style="height: 28px">
|
||||
<!-- 用户进度显示 -->
|
||||
<div v-if="problemSet.user_progress?.is_joined">
|
||||
<n-flex
|
||||
align="center"
|
||||
justify="space-between"
|
||||
style="margin-bottom: 8px"
|
||||
>
|
||||
<n-text depth="3" style="font-size: 12px">
|
||||
我的进度: {{ problemSet.user_progress.completed_count }} /
|
||||
{{ problemSet.user_progress.total_count }}
|
||||
</n-text>
|
||||
<n-progress
|
||||
v-if="
|
||||
problemSet.user_progress?.is_joined &&
|
||||
!problemSet.user_progress?.is_completed
|
||||
"
|
||||
type="line"
|
||||
:percentage="
|
||||
Math.round(problemSet.user_progress.progress_percentage)
|
||||
@@ -200,12 +177,33 @@ watch(
|
||||
)
|
||||
"
|
||||
/>
|
||||
<n-tag type="warning" v-if="problemSet.status === 'archived'">
|
||||
已归档
|
||||
</n-tag>
|
||||
<n-tag
|
||||
v-if="
|
||||
problemSet.user_progress?.is_joined &&
|
||||
!problemSet.user_progress?.is_completed
|
||||
"
|
||||
type="warning"
|
||||
>
|
||||
已加入
|
||||
</n-tag>
|
||||
<n-tag
|
||||
v-if="problemSet.user_progress?.is_completed"
|
||||
type="error"
|
||||
>
|
||||
已完成
|
||||
</n-tag>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
</div>
|
||||
|
||||
<!-- 奖章显示 -->
|
||||
<div v-if="problemSet.badges && problemSet.badges.length > 0">
|
||||
<n-flex align="center" justify="space-between">
|
||||
<n-flex
|
||||
v-if="problemSet.badges && problemSet.badges.length > 0"
|
||||
align="center"
|
||||
justify="space-between"
|
||||
>
|
||||
<n-text depth="3">
|
||||
创建于
|
||||
{{ parseTime(problemSet.create_time, "YYYY-MM-DD") }}
|
||||
@@ -226,9 +224,9 @@ watch(
|
||||
/>
|
||||
</template>
|
||||
<n-flex vertical size="small">
|
||||
<span style="font-weight: bold"
|
||||
>徽章: {{ badge.name }}</span
|
||||
>
|
||||
<span style="font-weight: bold">
|
||||
徽章: {{ badge.name }}
|
||||
</span>
|
||||
<span>
|
||||
获取条件:
|
||||
{{
|
||||
@@ -242,7 +240,6 @@ watch(
|
||||
</n-tooltip>
|
||||
</n-flex>
|
||||
</n-flex>
|
||||
</div>
|
||||
</n-flex>
|
||||
</n-card>
|
||||
</n-grid-item>
|
||||
@@ -254,7 +251,7 @@ watch(
|
||||
v-model:page="query.page"
|
||||
/>
|
||||
</n-flex>
|
||||
</div>
|
||||
<n-empty v-else></n-empty>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -58,8 +58,8 @@ function getConditionText() {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
}
|
||||
|
||||
.badge-icon {
|
||||
|
||||
@@ -251,6 +251,12 @@ export interface UserBadge {
|
||||
earned_time: Date
|
||||
}
|
||||
|
||||
export interface CompletedProblem {
|
||||
id: number
|
||||
_id: string
|
||||
title: string
|
||||
}
|
||||
|
||||
export interface ProblemSetProgress {
|
||||
id: number
|
||||
problemset: ProblemSetList
|
||||
@@ -260,6 +266,7 @@ export interface ProblemSetProgress {
|
||||
total_problems_count: number
|
||||
progress_percentage: number
|
||||
is_completed: boolean
|
||||
completed_problems: CompletedProblem[]
|
||||
}
|
||||
|
||||
export interface CreateProblemSetData {
|
||||
|
||||
Reference in New Issue
Block a user