fix(前台): 地址打错不再是一整页空白,题目、比赛、题单不存在时写明是哪样不存在、给一个回去的按钮

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-13 22:03:49 +08:00
1 parent f3956ad6a1
commit 06c679579c
6 files changed
+153 -37

No files matched your search

@@ -0,0 +1,71 @@
<script setup lang="ts">
import { Icon } from "@iconify/vue"
import { useThemeVars } from "naive-ui"
import type { RouteLocationRaw } from "vue-router"
/**
* 「找不到」的整页提示:地址打错、题目 / 比赛 / 题单不存在或没公开、比赛还没开始。
* 原来各页各写各的 —— 打错地址是一整页空白、题号不对只有一个「无数据」,学生看不出出了什么事。
* 样子跟提交详情的「这条提交不存在」一致:图标、一句话、一句为什么、一个回去的按钮。
*/
const props = withDefaults(
defineProps<{
title: string
hint?: string
icon?: string
to?: RouteLocationRaw
toLabel?: string
}>(),
{ hint: "", icon: "ph:magnifying-glass", to: "/", toLabel: "回首页" },
)
const theme = useThemeVars()
const router = useRouter()
</script>
<template>
<div class="not-found">
<Icon :icon="props.icon" :width="40" class="icon" />
<span class="title">{{ props.title }}</span>
<span v-if="props.hint" class="hint">{{ props.hint }}</span>
<div class="actions">
<slot>
<n-button type="primary" @click="router.push(props.to)">{{ props.toLabel }}</n-button>
</slot>
</div>
</div>
</template>
<style scoped>
.not-found {
min-height: 360px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 10px;
padding: 48px 16px;
text-align: center;
}
.icon {
color: v-bind("theme.textColor3");
opacity: 0.7;
}
.title {
font-size: 18px;
font-weight: 600;
}
.hint {
font-size: var(--oj-fs-sec);
color: v-bind("theme.textColor3");
}
.actions {
display: flex;
gap: 10px;
margin-top: 8px;
}
</style>