Browse Source

启用在线作业

Michael Wang 3 years ago
parent
commit
77938d9387

+ 3 - 0
.eslintrc.js

@@ -40,6 +40,9 @@ module.exports = {
     "vue/attribute-hyphenation": ["error", "never"],
     "vue/v-on-event-hyphenation": ["error", "never", { autofix: true }],
     "vue/no-v-html": "off",
+    // TODO: https://github.com/vuejs/rfcs/discussions/369  defineProps deconstructure retain reactivity
+    // eslint-disable-next-line vue/no-setup-props-destructure
+    "vue/no-setup-props-destructure": "off",
   },
   ignorePatterns: [
     // FIXME: ignore lang="tsx" don't know how to fix

+ 1 - 1
src/components/MainLayout/MainLayout.vue

@@ -69,7 +69,7 @@ async function getMenus() {
     });
 }
 function switchMenu(menu: MenuOption) {
-  console.log(menu.routeName);
+  // console.log(menu.routeName);
   void router.push({ name: menu.routeName });
 }
 

+ 0 - 2
src/features/OnlineExam/CommittmentDialog.vue

@@ -1,6 +1,4 @@
 <script setup lang="ts">
-// TODO: https://github.com/vuejs/rfcs/discussions/369  defineProps deconstructure retain reactivity
-// eslint-disable-next-line vue/no-setup-props-destructure
 const { content = "" } = defineProps<{ content: string }>();
 
 const emit = defineEmits<{ (e: "on-commit-result", v: boolean): void }>();

+ 0 - 2
src/features/OnlineExam/FaceRecognition.vue

@@ -17,8 +17,6 @@ import { execLocal, fileExists } from "@/utils/nativeMethods";
  * 可能存在多个异步比对的任务同时进行
  */
 
-// TODO: https://github.com/vuejs/rfcs/discussions/369  defineProps deconstructure retain reactivity
-// eslint-disable-next-line vue/no-setup-props-destructure
 const {
   width = 400,
   height = 300,

+ 8 - 3
src/features/OnlineExam/OnlineExamHome.vue

@@ -2,11 +2,9 @@
 import { httpApp } from "@/plugins/axiosApp";
 import { ExamType, OnlineExam } from "@/types/student-client";
 import { closeMediaStream } from "@/utils/camera";
-import { onMounted } from "vue";
+import { onMounted, watch } from "vue";
 import OnlineExamList from "./OnlineExamList.vue";
 
-// TODO: https://github.com/vuejs/rfcs/discussions/369  defineProps deconstructure retain reactivity
-// eslint-disable-next-line vue/no-setup-props-destructure
 const { examType = "ONLINE" } = defineProps<{ examType?: ExamType }>();
 
 let courses: OnlineExam[] = $ref([]);
@@ -26,6 +24,13 @@ onMounted(async () => {
   await getData().finally(() => (loading = false));
 });
 
+watch(
+  () => examType,
+  async () => {
+    await getData().finally(() => (loading = false));
+  }
+);
+
 async function getData() {
   courses = [];
   let examListRes: { data: OnlineExam[]; status: number } = {

+ 0 - 2
src/features/OnlineExam/OnlineExamList.vue

@@ -8,8 +8,6 @@ import { useTimers } from "@/setups/useTimers";
 import { WEEKDAY_NAMES } from "@/constants/constants";
 import OnlineExamResultList from "./OnlineExamResultList.vue";
 
-// TODO: https://github.com/vuejs/rfcs/discussions/369  defineProps deconstructure retain reactivity
-// eslint-disable-next-line vue/no-setup-props-destructure
 const {
   courses = [],
   endCourses = [],

+ 0 - 2
src/features/OnlineExam/StartExamModal.vue

@@ -10,8 +10,6 @@ import { checkExamInProgress } from "../UserLogin/useExamInProgress";
 import { store } from "@/store/store";
 import { closeMediaStream } from "@/utils/camera";
 
-// TODO: https://github.com/vuejs/rfcs/discussions/369  defineProps deconstructure retain reactivity
-// eslint-disable-next-line vue/no-setup-props-destructure
 const { course } = defineProps<{ course: OnlineExam }>();
 
 const emit = defineEmits<{ (e: "on-unselect-course"): void }>();

+ 24 - 18
src/router/index.ts

@@ -34,24 +34,10 @@ const routes: RouteRecordRaw[] = [
         name: "OnlineExam",
       },
       {
-        path: "password",
-        component: ChangePassword,
-        name: "ChangePassword",
-      },
-      {
-        path: "site-message",
-        component: SiteMessage,
-        name: "SiteMessage",
-      },
-      {
-        path: "site-message/:noticeId",
-        component: SiteMessageDetail,
-        name: "SiteMessageDetail",
-      },
-      {
-        path: "offline-exam",
-        component: OfflineExam,
-        name: "OfflineExam",
+        path: "online-homework",
+        component: OnlineExam,
+        name: "OnlineHomework",
+        props: { examType: "ONLINE_HOMEWORK" },
       },
       {
         path: "online-practice",
@@ -68,6 +54,26 @@ const routes: RouteRecordRaw[] = [
         component: OnlinePracticeRecordDetail,
         name: "OnlinePracticeRecordDetail",
       },
+      {
+        path: "offline-exam",
+        component: OfflineExam,
+        name: "OfflineExam",
+      },
+      {
+        path: "site-message",
+        component: SiteMessage,
+        name: "SiteMessage",
+      },
+      {
+        path: "site-message/:noticeId",
+        component: SiteMessageDetail,
+        name: "SiteMessageDetail",
+      },
+      {
+        path: "password",
+        component: ChangePassword,
+        name: "ChangePassword",
+      },
     ],
   },
   {