소스 검색

chore: set problems page as home; remove home/about pages; clean up nav redirects; remove public status filter from user problem list

yangyi 2 주 전
부모
커밋
5efa2c6e6a
7개의 변경된 파일과 13개의 추가작업 그리고 68개의 파일을 삭제
  1. 1 1
      src/layout/AdminLayout.vue
  2. 4 4
      src/layout/UserLayout.vue
  3. 4 21
      src/router/index.ts
  4. 0 14
      src/view/AboutView.vue
  5. 0 12
      src/view/HomeView.vue
  6. 1 1
      src/view/LoginView.vue
  7. 3 15
      src/view/problem/ProblemListView.vue

+ 1 - 1
src/layout/AdminLayout.vue

@@ -33,7 +33,7 @@ const handleClose = (key: string, keyPath: string[]) => {
 <template>
   <el-container>
     <el-header class="header">
-      <div class="header-left" @click="router.push('/')">
+      <div class="header-left" @click="router.push('/problems')">
         <img src="/logo.svg" alt="logo" class="logo">
         <h2 class="title">{{title}}</h2>
       </div>

+ 4 - 4
src/layout/UserLayout.vue

@@ -2,7 +2,7 @@
   <div class="user-layout">
     <el-container>
       <el-header class="header">
-        <div class="header-left" @click="router.push('/')">
+        <div class="header-left" @click="router.push('/problems')">
           <img :src="metaStore.logo" alt="logo" class="logo">
           <h2 class="title">{{metaStore.title}}</h2>
         </div>
@@ -71,16 +71,16 @@ const isStaff = computed(() => {
 const loginHandler = () => {
   router.push('/login')
 }
-let activeIndex = ref('/')
+let activeIndex = ref('/problems')
 const menus = computed(()=>{
-  return userRoutes[0].children?.filter((child) => !String(child.path).includes(':'));
+  return userRoutes[0].children?.filter((child) => !String(child.path).includes(':') && child.path !== '/');
 })
 const handleSelect = () => {
   //todo: 处理菜单选择
 }
 const logoutHandler = () => {
   loginUserStore.logoutUser()
-  router.push('/')
+  router.push('/problems')
 }
 </script>
 <style scoped>

+ 4 - 21
src/router/index.ts

@@ -1,7 +1,6 @@
 import {createRouter, createWebHistory, type Router, type RouteRecordRaw} from 'vue-router'
 
-import HomeView from '../view/HomeView.vue'
-import AboutView from '../view/AboutView.vue'
+
 import LoginView from '../view/LoginView.vue'
 import UserLayout from '../layout/UserLayout.vue'
 import AdminLayout from "../layout/AdminLayout.vue";
@@ -16,8 +15,6 @@ import ContestDetailView from "../view/contest/ContestDetailView.vue";
 import ContestRankingView from "../view/contest/ContestRankingView.vue";
 import SubmissionListView from "../view/submission/SubmissionListView.vue";
 import {
-    HomeFilled,
-    Menu,
     User,
     Document,
     Files,
@@ -36,21 +33,7 @@ export const userRoutes:RouteRecordRaw[] = [
         children: [
             {
                 path: '/',
-                name: 'home',
-                component: HomeView,
-                meta: {
-                    title: '首页',
-                    icon: HomeFilled
-                }
-            },
-            {
-                path: '/about',
-                name: 'about',
-                component: AboutView,
-                meta: {
-                    title: '关于',
-                    icon: Menu
-                }
+                redirect: '/problems'
             },
             {
                 path: '/problems',
@@ -184,7 +167,7 @@ router.beforeEach((to, _from, next) => {
             next({path: '/login', query: {redirect: to.fullPath}})
         } else if (role !== 'admin') {
             ElMessage.error('无权访问')
-            next('/')
+            next('/problems')
         } else {
             next()
         }
@@ -194,7 +177,7 @@ router.beforeEach((to, _from, next) => {
             next({path: '/login', query: {redirect: to.fullPath}})
         } else if (role !== 'admin' && role !== 'coach') {
             ElMessage.error('无权访问')
-            next('/')
+            next('/problems')
         } else {
             next()
         }

+ 0 - 14
src/view/AboutView.vue

@@ -1,14 +0,0 @@
-<template>
-<h1>这是about页面</h1>
-  <el-text>
-    这是基于Vite + Vue + TypeScript构建的前端模板
-  </el-text>
-</template>
-
-<script setup lang="ts">
-console.log('about')
-</script>
-
-<style scoped>
-
-</style>

+ 0 - 12
src/view/HomeView.vue

@@ -1,12 +0,0 @@
-<template>
-<el-text>
-  这是基于Vite + Vue + TypeScript构建的前端模板
-</el-text>
-</template>
-
-<script setup lang="ts">
-</script>
-
-<style scoped>
-
-</style>

+ 1 - 1
src/view/LoginView.vue

@@ -8,7 +8,7 @@
       </div>
 
       <el-card class="auth-card" shadow="never">
-        <el-button class="back-btn" text @click="router.push('/')">
+        <el-button class="back-btn" text @click="router.push('/problems')">
           <el-icon><ArrowLeft /></el-icon>
           返回主页
         </el-button>

+ 3 - 15
src/view/problem/ProblemListView.vue

@@ -13,8 +13,7 @@ const api = getProblemController()
 const searchForm = reactive({
   title: '',
   difficulty: '',
-  categoryId: undefined as number | undefined,
-  isPublic: undefined as number | undefined
+  categoryId: undefined as number | undefined
 })
 
 const categoryOptions = ref<CategoryVo[]>([])
@@ -59,7 +58,6 @@ const fetchData = async () => {
       title: searchForm.title || undefined,
       difficulty: searchForm.difficulty || undefined,
       categoryId: searchForm.categoryId,
-      isPublic: searchForm.isPublic,
       pageNum: pagination.pageNum,
       pageSize: pagination.pageSize
     }
@@ -84,7 +82,6 @@ const handleReset = () => {
   searchForm.title = ''
   searchForm.difficulty = ''
   searchForm.categoryId = undefined
-  searchForm.isPublic = undefined
   handleSearch()
 }
 
@@ -128,12 +125,7 @@ onMounted(() => {
             <el-option v-for="item in categoryOptions" :key="item.id" :label="item.categoryName" :value="item.id" />
           </el-select>
         </el-form-item>
-        <el-form-item label="公开状态">
-          <el-select v-model="searchForm.isPublic" placeholder="全部" clearable style="width: 120px">
-            <el-option label="公开" :value="1" />
-            <el-option label="未公开" :value="0" />
-          </el-select>
-        </el-form-item>
+
         <el-form-item>
           <el-button type="primary" @click="handleSearch">
             <el-icon class="el-icon--left"><Search /></el-icon>搜索
@@ -158,11 +150,7 @@ onMounted(() => {
             <el-tag :type="difficultyTag(row.difficulty)">{{ difficultyLabel(row.difficulty) }}</el-tag>
           </template>
         </el-table-column>
-        <el-table-column label="公开状态" width="100" align="center">
-          <template #default="{ row }">
-            <el-tag :type="row.isPublic === 1 ? 'success' : 'info'">{{ row.isPublic === 1 ? '公开' : '未公开' }}</el-tag>
-          </template>
-        </el-table-column>
+
         <el-table-column label="时间限制" width="110" align="center">
           <template #default="{ row }">{{ row.timeLimitMs ?? '-' }} ms</template>
         </el-table-column>