Damon 4 лет назад
Родитель
Сommit
3fc82d306a

+ 36 - 21
src/components/GlobalHeader.vue

@@ -6,13 +6,23 @@
     </div>
 <!--    <div><span style="color: #a4a4a4">[定位用空白及调试信息]</span>———当前: <span style="color: red">{{ currentPage }}</span>页</div>-->
 <!--    <div></div>-->
-    <div id="global-header-navigator">
-      <div class="global-header-navigator-tab" @click="toPortal"><span class="global-header-navigator-tab-text">首页</span></div>
-      <div class="global-header-navigator-tab" @click="toTask"><span class="global-header-navigator-tab-text">任务</span></div>
-      <div class="global-header-navigator-tab" @click="toManage"><span class="global-header-navigator-tab-text">教师[临]</span></div>
-      <div class="global-header-navigator-tab" @click="toHome"><span class="global-header-navigator-tab-text">个人中心</span></div>
-      <div class="global-header-navigator-tab" @click="testButton"><span class="global-header-navigator-tab-text">...</span></div>
-    </div>
+<!--    <div id="global-header-navigator">-->
+<!--      <div class="global-header-navigator-tab" @click="toPortal"><span class="global-header-navigator-tab-text">首页</span></div>-->
+<!--      <div class="global-header-navigator-tab" @click="toTask"><span class="global-header-navigator-tab-text">任务</span></div>-->
+<!--      <div class="global-header-navigator-tab" @click="toManage"><span class="global-header-navigator-tab-text">教师[临]</span></div>-->
+<!--      <div class="global-header-navigator-tab" @click="toHome"><span class="global-header-navigator-tab-text">个人中心</span></div>-->
+<!--      <div class="global-header-navigator-tab" @click="testButton"><span class="global-header-navigator-tab-text">...</span></div>-->
+<!--    </div>-->
+    <el-menu :default-active="1" mode="horizontal" >
+      <el-submenu index="1">
+        <template #title>首页</template>
+        <el-menu-item index="1-1">全部课程</el-menu-item>
+        <el-menu-item index="1-2">全部测试</el-menu-item>
+      </el-submenu>
+      <el-menu-item index="2">
+        任务
+      </el-menu-item>
+    </el-menu>
     <div id="global-header-icon">
       <div class="global-header-icon-content" @click="toMessage">
         <svg height="32" viewBox="0 0 1024 1024" width="32" xmlns="http://www.w3.org/2000/svg">
@@ -50,6 +60,11 @@ import InfoCard from "@/views/PortalPage/components/InfoCard";
 export default {
   name: "GlobalHeader",
   components: { InfoCard },
+  data() {
+    return {
+
+    };
+  },
   computed: {
     currentPage: function () {
       return this.$route.name;
@@ -107,22 +122,22 @@ export default {
   cursor: pointer;
 }
 
-#global-header-navigator {
-  display: flex;
-}
+/*#global-header-navigator {*/
+/*  display: flex;*/
+/*}*/
 
-.global-header-navigator-tab {
-  height: 48px;
-  width: 72px;
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  margin-left: 10px;
-}
+/*.global-header-navigator-tab {*/
+/*  height: 48px;*/
+/*  width: 72px;*/
+/*  display: flex;*/
+/*  justify-content: center;*/
+/*  align-items: center;*/
+/*  margin-left: 10px;*/
+/*}*/
 
-.global-header-navigator-tab:hover {
-  cursor: pointer;
-}
+/*.global-header-navigator-tab:hover {*/
+/*  cursor: pointer;*/
+/*}*/
 
 #global-header-icon {
   width: 120px;

+ 2 - 1
src/global/register-element.js

@@ -32,7 +32,7 @@ import {
   ElTag,
   ElTimeline,
   ElTimelineItem,
-  ElBacktop, ElDropdown, ElMenu, ElMenuItem,
+  ElBacktop, ElDropdown, ElMenu, ElMenuItem, ElSubmenu,
 } from "element-plus";
 
 // NOTE 使用到的组件列表,请确保 import 和 component 的一致性
@@ -74,6 +74,7 @@ const components = [
   ElDropdown,
   ElMenu,
   ElMenuItem,
+  ElSubmenu,
 ];
 
 export default function (app) {

+ 15 - 15
src/router/index.js

@@ -78,20 +78,20 @@ const router = createRouter({
   routes,
 });
 
-// router.beforeEach((to, from, next) => {
-//   if (to.name === "Portal" || to.name === "Auth") {
-//     next();
-//   } else if (!store.state.user.token) {
-//     ElMessage({
-//       showClose: true,
-//       message: "请先登录",
-//       type: "warning",
-//       duration: 1000,
-//     });
-//     next({ name: "Auth" });
-//   } else {
-//     next();
-//   }
-// });
+router.beforeEach((to, from, next) => {
+  if (to.name === "Portal" || to.name === "Auth") {
+    next();
+  } else if (!store.state.user.token) {
+    ElMessage({
+      showClose: true,
+      message: "请先登录",
+      type: "warning",
+      duration: 1000,
+    });
+    next({ name: "Auth" });
+  } else {
+    next();
+  }
+});
 
 export default router;

+ 18 - 16
src/views/CoursePage/CoursePage.vue

@@ -2,7 +2,7 @@
   <GlobalHeader/>
   <div id="course-page-body">
     <div id="course-back-button" @click="toPortal">
-      <svg data-v-ba633cb8="" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="24">
+      <svg data-v-ba633cb8="" viewBox="0 0 1024 1024" width="24" xmlns="http://www.w3.org/2000/svg">
         <path d="M224 480h640a32 32 0 1 1 0 64H224a32 32 0 0 1 0-64z" fill="currentColor"></path>
         <path d="m237.248 512 265.408 265.344a32 32 0 0 1-45.312 45.312l-288-288a32 32 0 0 1 0-45.312l288-288a32 32 0 1 1 45.312 45.312L237.248 512z" fill="currentColor"></path>
       </svg>
@@ -11,21 +11,23 @@
       <el-tab-pane class="course-page-main" label="全部课程" name="first">
         <CourseCard v-for="course in courses_show" :key="course.id" :courseVO="course"/>
       </el-tab-pane>
-      <el-tab-pane v-if="courses_my.length!==0" class="course-page-main" label="我的课程" name="second">
-        <CourseCard v-for="course in courses_my" :key="course.id" :courseVO="course"/>
-      </el-tab-pane>
-      <el-tab-pane v-else class="course-page-main" label="我的课程" name="second" style="display: flex; flex-direction: column; justify-content: center;align-items: center;margin-top: 16vh">
-        <svg class="icon" height="128" viewBox="0 0 1024 1024" width="128" xmlns="http://www.w3.org/2000/svg">
-          <path
-            d="M909.016 820.828H841a30 30 0 0 1 0-60h38.016a20 20 0 0 0 20-20V145.185a20 20 0 0 0-20-20H352a20 20 0 0 0-20 20v28h370.016a50 50 0 0 1 50 50v223.36a29.989 29.989 0 1 1-59.507 5.283h-0.493V253.185a20
-                20 0 0 0-20-20H145a20 20 0 0 0-20 20v625.643a20 20 0 0 0 20 20h337a30 30 0 0 1 0 60H115a50 50 0 0 1-50-50V223.185a50 50 0 0 1 50-50h157v-58a50 50 0 0 1 50-50h587.016a50 50 0 0 1 50 50v655.643a50 50 0 0 1-50 50z m-663.037-484H572.74a29.979 29.979 0 1 1 0
-                59.957H245.979a29.979 29.979 0 1 1 0-59.957z m0 290.043h74.912a29.979 29.979 0 0 1 29.979 29.978 29.979 29.979 0 0 1-29.979
-                29.979h-74.912A29.979 29.979 0 0 1 216 656.849a29.979 29.979 0 0 1 29.979-29.978zM216 511.807a29.979 29.979 0 0 1 29.979-29.979h140.935a29.979 29.979 0 0 1 29.979 29.979v0.042a29.979 29.979 0 0 1-29.979 29.979H245.979A29.979 29.979 0 0 1 216 511.849v-0.042z m163 177.521c0-107.419
-                 87.081-194.5 194.5-194.5S768 581.909 768 689.328a193.618 193.618 0 0 1-37.9 115.356l84.115 84.115a30 30 0 1 1-42.425 42.429l-84.3-84.3a193.6 193.6 0 0 1-113.99 36.9c-107.419 0-194.5-87.081-194.5-194.5z m194.5 134.5a134.5 134.5 0 1 0-134.5-134.5 134.5 134.5 0 0 0 134.5 134.5z"
-            fill="#bfbfbf"></path>
-        </svg>
-        <div>
-          暂无数据
+      <el-tab-pane label="我的课程" name="second">
+        <div v-if="courses_my.length!==0" class="course-page-main">
+          <CourseCard v-for="course in courses_my" :key="course.id" :courseVO="course"/>
+        </div>
+        <div v-else class="course-page-main" style="display: flex; flex-direction: column; justify-content: center;align-items: center;margin-top: 16vh">
+          <svg class="icon" height="128" viewBox="0 0 1024 1024" width="128" xmlns="http://www.w3.org/2000/svg">
+            <path
+              d="M909.016 820.828H841a30 30 0 0 1 0-60h38.016a20 20 0 0 0 20-20V145.185a20 20 0 0 0-20-20H352a20 20 0 0 0-20 20v28h370.016a50 50 0 0 1 50 50v223.36a29.989 29.989 0 1 1-59.507 5.283h-0.493V253.185a20
+                  20 0 0 0-20-20H145a20 20 0 0 0-20 20v625.643a20 20 0 0 0 20 20h337a30 30 0 0 1 0 60H115a50 50 0 0 1-50-50V223.185a50 50 0 0 1 50-50h157v-58a50 50 0 0 1 50-50h587.016a50 50 0 0 1 50 50v655.643a50 50 0 0 1-50 50z m-663.037-484H572.74a29.979 29.979 0 1 1 0
+                  59.957H245.979a29.979 29.979 0 1 1 0-59.957z m0 290.043h74.912a29.979 29.979 0 0 1 29.979 29.978 29.979 29.979 0 0 1-29.979
+                  29.979h-74.912A29.979 29.979 0 0 1 216 656.849a29.979 29.979 0 0 1 29.979-29.978zM216 511.807a29.979 29.979 0 0 1 29.979-29.979h140.935a29.979 29.979 0 0 1 29.979 29.979v0.042a29.979 29.979 0 0 1-29.979 29.979H245.979A29.979 29.979 0 0 1 216 511.849v-0.042z m163 177.521c0-107.419
+                   87.081-194.5 194.5-194.5S768 581.909 768 689.328a193.618 193.618 0 0 1-37.9 115.356l84.115 84.115a30 30 0 1 1-42.425 42.429l-84.3-84.3a193.6 193.6 0 0 1-113.99 36.9c-107.419 0-194.5-87.081-194.5-194.5z m194.5 134.5a134.5 134.5 0 1 0-134.5-134.5 134.5 134.5 0 0 0 134.5 134.5z"
+              fill="#bfbfbf"></path>
+          </svg>
+          <div>
+            暂无数据
+          </div>
         </div>
       </el-tab-pane>
     </el-tabs>

+ 2 - 2
src/views/PortalPage/PortalPage.css

@@ -4,7 +4,7 @@
     grid-template-columns: 1fr 2.5fr;
     grid-template-rows: 210px auto auto;
     grid-gap: 12px 12px;
-    padding: 10px 180px 80px 180px;
+    padding: 10px 10vw 80px 10vw;
 }
 
 #portal-carousel-card {
@@ -47,5 +47,5 @@
 .portal-my-card-main {
     display: grid;
     grid-template-columns: 1fr;
-    min-width: 250px;
+    min-width: calc(max(100%, 250px));
 }

+ 34 - 56
src/views/PortalPage/PortalPage.vue

@@ -2,8 +2,6 @@
   <GlobalHeader/>
   <div id="portal-body">
 
-    <!--    <InfoCard/>-->
-
     <CarouselCard id="portal-carousel-card"/>
 
     <div>
@@ -14,32 +12,24 @@
         <el-divider class="portal-card-divider"/>
         <div v-if="isLogin" :style="{height: (courseRowHeight - 63) + 'px'}" class="portal-card-main">
           <div class="portal-my-card-main">
-            <MyCourseCard :courseVO="course" v-for="course in myCourseList" :key="course.id"/>
+            <MyCourseCard v-for="course in myCourseList" :key="course.id" :courseVO="course"/>
           </div>
         </div>
-        <div v-else :style="{height: (courseRowHeight - 63) + 'px', marginTop: (courseRowHeight / 2 - 120) + 'px'}"
-             class="portal-card-main">
-          <div>
-            <svg class="icon" height="128" viewBox="0 0 1024 1024" width="128" xmlns="http://www.w3.org/2000/svg">
-              <path
-                d="M909.016 820.828H841a30 30 0 0 1 0-60h38.016a20 20 0 0 0 20-20V145.185a20 20 0 0 0-20-20H352a20 20 0 0 0-20 20v28h370.016a50 50 0 0 1 50 50v223.36a29.989 29.989 0 1 1-59.507 5.283h-0.493V253.185a20
-                20 0 0 0-20-20H145a20 20 0 0 0-20 20v625.643a20 20 0 0 0 20 20h337a30 30 0 0 1 0 60H115a50 50 0 0 1-50-50V223.185a50 50 0 0 1 50-50h157v-58a50 50 0 0 1 50-50h587.016a50 50 0 0 1 50 50v655.643a50 50 0 0 1-50 50z m-663.037-484H572.74a29.979 29.979 0 1 1 0
-                59.957H245.979a29.979 29.979 0 1 1 0-59.957z m0 290.043h74.912a29.979 29.979 0 0 1 29.979 29.978 29.979 29.979 0 0 1-29.979
-                29.979h-74.912A29.979 29.979 0 0 1 216 656.849a29.979 29.979 0 0 1 29.979-29.978zM216 511.807a29.979 29.979 0 0 1 29.979-29.979h140.935a29.979 29.979 0 0 1 29.979 29.979v0.042a29.979 29.979 0 0 1-29.979 29.979H245.979A29.979 29.979 0 0 1 216 511.849v-0.042z m163 177.521c0-107.419
-                 87.081-194.5 194.5-194.5S768 581.909 768 689.328a193.618 193.618 0 0 1-37.9 115.356l84.115 84.115a30 30 0 1 1-42.425 42.429l-84.3-84.3a193.6 193.6 0 0 1-113.99 36.9c-107.419 0-194.5-87.081-194.5-194.5z m194.5 134.5a134.5 134.5 0 1 0-134.5-134.5 134.5 134.5 0 0 0 134.5 134.5z"
-                fill="#bfbfbf"></path>
-            </svg>
-          </div>
-          <div style="cursor:pointer;" @click="this.$router.push('/auth')">登录以查看更多</div>
+        <div v-else :style="{height: (courseRowHeight - 63) + 'px', marginTop: (courseRowHeight / 2 - 100) + 'px'}" class="portal-card-main" style="cursor: pointer"
+             @click="this.$router.push('/auth')">
+          <el-icon color="#bfbfbf" :size="72">
+            <Lock/>
+          </el-icon>
+          <div style="font-size: small; font-weight: bold; color: #666666">登录以查看</div>
         </div>
       </el-card>
     </div>
 
     <div>
-      <el-card id="portal-course-card-main" ref="portalCourseCardBodyMain" :style="{height: courseRowHeight + 'px'}">
+      <el-card id="portal-course-card-main" :style="{height: courseRowHeight + 'px'}">
         <div class="portal-card-title">
           <div class="portal-card-title-main">精选课程</div>
-          <ElButton round plain type="primary" @click="toCourse">查看全部课程</ElButton>
+          <ElButton plain round type="primary" @click="toCourse">查看全部课程</ElButton>
         </div>
         <el-divider class="portal-card-divider"/>
         <el-row justify="space-around" type="flex">
@@ -58,23 +48,15 @@
         <el-divider class="portal-card-divider"/>
         <div v-if="isLogin" :style="{height: (testRowHeight - 63) + 'px'}" class="portal-card-main">
           <div class="portal-my-card-main">
-            <MyTestCard :testVO="test" v-for="test in myTestList" :key="test.id"/>
+            <MyTestCard v-for="test in myTestList" :key="test.id" :testVO="test"/>
           </div>
         </div>
-        <div v-else :style="{height: (testRowHeight - 63) + 'px', marginTop: (testRowHeight / 2 - 120) + 'px'}"
-             class="portal-card-main">
-          <div>
-            <svg class="icon" height="128" viewBox="0 0 1024 1024" width="128" xmlns="http://www.w3.org/2000/svg">
-              <path
-                d="M909.016 820.828H841a30 30 0 0 1 0-60h38.016a20 20 0 0 0 20-20V145.185a20 20 0 0 0-20-20H352a20 20 0 0 0-20 20v28h370.016a50 50 0 0 1 50 50v223.36a29.989 29.989 0 1 1-59.507 5.283h-0.493V253.185a20
-                20 0 0 0-20-20H145a20 20 0 0 0-20 20v625.643a20 20 0 0 0 20 20h337a30 30 0 0 1 0 60H115a50 50 0 0 1-50-50V223.185a50 50 0 0 1 50-50h157v-58a50 50 0 0 1 50-50h587.016a50 50 0 0 1 50 50v655.643a50 50 0 0 1-50 50z m-663.037-484H572.74a29.979 29.979 0 1 1 0
-                59.957H245.979a29.979 29.979 0 1 1 0-59.957z m0 290.043h74.912a29.979 29.979 0 0 1 29.979 29.978 29.979 29.979 0 0 1-29.979
-                29.979h-74.912A29.979 29.979 0 0 1 216 656.849a29.979 29.979 0 0 1 29.979-29.978zM216 511.807a29.979 29.979 0 0 1 29.979-29.979h140.935a29.979 29.979 0 0 1 29.979 29.979v0.042a29.979 29.979 0 0 1-29.979 29.979H245.979A29.979 29.979 0 0 1 216 511.849v-0.042z m163 177.521c0-107.419
-                 87.081-194.5 194.5-194.5S768 581.909 768 689.328a193.618 193.618 0 0 1-37.9 115.356l84.115 84.115a30 30 0 1 1-42.425 42.429l-84.3-84.3a193.6 193.6 0 0 1-113.99 36.9c-107.419 0-194.5-87.081-194.5-194.5z m194.5 134.5a134.5 134.5 0 1 0-134.5-134.5 134.5 134.5 0 0 0 134.5 134.5z"
-                fill="#bfbfbf"></path>
-            </svg>
-          </div>
-          <div style="cursor:pointer;" @click="this.$router.push('/auth')">登录以查看更多</div>
+        <div v-else :style="{height: (testRowHeight - 63) + 'px', marginTop: (testRowHeight / 2 - 100) + 'px'}" class="portal-card-main" style="cursor: pointer"
+             @click="this.$router.push('/auth')">
+          <el-icon color="#bfbfbf" :size="72">
+            <Lock/>
+          </el-icon>
+          <div style="font-size: small; font-weight: bold; color: #666666">登录以查看</div>
         </div>
       </el-card>
     </div>
@@ -86,7 +68,7 @@
           <ElButton plain round type="primary" @click="toTest">查看全部测试</ElButton>
         </div>
         <el-divider class="portal-card-divider"/>
-        <el-tabs v-model="activeTestName" @tab-click="changeTestPane">
+        <el-tabs v-model="activeTestPaneName" @tab-click="changeTestPane">
           <el-tab-pane label="评测题" name="eval">
             <el-row justify="space-around">
               <el-col v-for="item in evalExamList.slice(0, cardRowLength)" :key="item.id" :lg="7" :md="11" :sm="11"
@@ -114,24 +96,23 @@
 <script>
 import GlobalHeader from "@/components/GlobalHeader";
 import CarouselCard from "@/views/PortalPage/components/CarouselCard";
-// import InfoCard from "@/views/PortalPage/components/InfoCard";
 import CourseCard from "@/components/CourseCard";
 import GlobalFooter from "@/components/GlobalFooter";
 import EvalCard from "@/components/EvalCard";
 import CoderCard from "@/components/CoderCard";
 import MyCourseCard from "@/views/PortalPage/components/MyCourseCard";
 import MyTestCard from "@/views/PortalPage/components/MyTestCard";
+import { Lock } from "@element-plus/icons-vue";
 
 export default {
   //属性
   name: "PortalPage",
-  components: {MyTestCard, CoderCard, GlobalFooter, CourseCard, CarouselCard, GlobalHeader, EvalCard, MyCourseCard},
+  components: { Lock, MyTestCard, CoderCard, GlobalFooter, CourseCard, CarouselCard, GlobalHeader, EvalCard, MyCourseCard },
   data() {
     return {
-      isLogin: this.$store.state.user.token !== undefined,
       extending: false,
       cardRowLength: 3,
-      activeTestName: "eval",
+      activeTestPaneName: "eval",
       evalExamList: [],
       courseList: [],
       coderExamList: [],
@@ -139,10 +120,15 @@ export default {
       myEvalExamList: [],
       myCoderExamList: [],
       myTestList: [],
-      courseRowHeight: 0,
-      testRowHeight: 0,
+      courseRowHeight: 360,
+      testRowHeight: 300,
     };
   },
+  computed: {
+    isLogin() {
+      return this.$store.state.user.token !== undefined;
+    }
+  },
 
   //生命周期函数
   beforeMount() {
@@ -174,11 +160,13 @@ export default {
       this.myCourseList = this.$apis.getStudentCourses({"studentId": this.$store.state.user.id}).then(res => {
         this.myCourseList = res.data.data;
       });
-      const evalRes = await this.$apis.getStudentEvalExams({state: 0});
-      this.myEvalExamList = evalRes.data.data.examVOList;
-      const coderRes = await this.$apis.getStudentCoderExams({});
-      this.myCoderExamList = coderRes.data.data.res;
-      this.myTestList = [].concat(this.myEvalExamList).concat(this.myCoderExamList);
+      this.myTestList = [].concat(this.evalExamList).concat(this.coderExamList);
+
+      // const evalRes = await this.$apis.getStudentEvalExams({state: 0});
+      // this.myEvalExamList = evalRes.data.data.examVOList;
+      // const coderRes = await this.$apis.getStudentCoderExams({});
+      // this.myCoderExamList = coderRes.data.data.res;
+      // this.myTestList = [].concat(this.myEvalExamList).concat(this.myCoderExamList);
     }
 
     await this.$nextTick(() => {
@@ -206,16 +194,6 @@ export default {
           this.cardRowLength = 2;
         }
         this.courseRowHeight = 640;
-      } else if (scrollTop < 5) {
-        this.extending = false;
-        if (document.body.clientWidth >= 1200) {
-          this.cardRowLength = 3;
-        } else if (document.body.clientWidth >= 992 && document.body.clientWidth < 1200) {
-          this.cardRowLength = 2;
-        } else if (document.body.clientWidth < 992) {
-          this.cardRowLength = 1;
-        }
-        this.courseRowHeight = 360;
       }
       this.testRowHeight = this.$refs.portalTestCardBodyMain.$el.clientHeight;
     },

+ 4 - 1
src/views/PortalPage/components/InfoCard.vue

@@ -52,7 +52,10 @@ export default {
     logout() {
       this.$store.commit("state_reset_user");
       this.$store.commit("storage_delete_user");
-      location.reload();
+      this.$router.push("/portal");
+      setTimeout(() => {
+        location.reload();
+      }, 0);
     },
   },