Files
OJ2/apps/web/src/oj/home/index.vue
T
xuyueandClaude Opus 5.5 10d2638c23
Deploy / deploy (push) Canceled after 0s
feat(首页): 学生上课时首页最上面就是这节课和「接着做」,课后先看上次没做完的;老师有了自己的首页,看今天哪些班在上课、点进课堂看板
去掉和顶栏重复的找题框、常年空着的比赛卡、底部快捷入口,公告只留置顶那条。
修了当天上午上课、下午再登录时写「上次(今天的日期)还有几道没过」。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:53:38 +08:00

29 lines
1.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { STORAGE_KEY } from "utils/constants"
import storage from "utils/storage"
import { useUserStore } from "shared/store/user"
// 两边都按需加载:没登录的访客只拿题目列表那一份,登录了的学生只拿首页那一份
const Dashboard = defineAsyncComponent(() => import("./dashboard.vue"))
// 老师的首页单独一张(设计稿「首页重设计」HomeTeacher):今天哪些班在上课
const TeacherHome = defineAsyncComponent(() => import("./TeacherHome.vue"))
const ProblemList = defineAsyncComponent(() => import("oj/problem/list.vue"))
const userStore = useUserStore()
// profile 回来之前先按上次的登录标记猜一个:干等的话 /profile 一失败首页就是
// 白的,而先按「没登录」渲染又会让每个学生都先闪一下题目列表
const showDashboard = computed(() =>
userStore.isFinished ? userStore.isAuthed : !!storage.get(STORAGE_KEY.AUTHED),
)
</script>
<template>
<template v-if="showDashboard">
<!-- 资料回来之前分不出是不是老师,先空着,免得老师先闪一下学生的首页 -->
<TeacherHome v-if="userStore.isFinished && userStore.isTeacherOrAbove" />
<Dashboard v-else-if="userStore.isFinished" />
</template>
<ProblemList v-else />
</template>