Procházet zdrojové kódy

fix:修复了开始作业页面返回时的跳转问题

廖彦舟 před 7 měsíci
rodič
revize
171b9b8883

+ 15 - 15
src/router/index.ts

@@ -16,24 +16,24 @@ const router = createRouter({
     },
 
     // 登录与注册
-    {
-      path: "/",
-      redirect: () => {
-        window.location.href = "https://p-nju.seec.seecoder.cn/login?from=https://air-nju.seec.seecoder.cn";
-        // window.location.href = "http://localhost:8000/login?from=http://localhost:4000";
-        // {本地门户首页地址}?from={本地eai首页地址}
-        return "/"; // 占位返回值,实际不会执行
-    },
-    },
     // {
     //   path: "/",
-    //   redirect: "/login"
+    //   redirect: () => {
+    //     window.location.href = "https://p-nju.seec.seecoder.cn/login?from=https://air-nju.seec.seecoder.cn";
+    //     // window.location.href = "http://localhost:8000/login?from=http://localhost:4000";
+    //     // {本地门户首页地址}?from={本地eai首页地址}
+    //     return "/"; // 占位返回值,实际不会执行
     // },
-    // {
-    //   path: '/login',
-    //   name: 'login',
-    //   component: () => import('../views/LoginPage/LoginPage.vue')
     // },
+    {
+      path: "/",
+      redirect: "/login"
+    },
+    {
+      path: '/login',
+      name: 'login',
+      component: () => import('../views/LoginPage/LoginPage.vue')
+    },
     {
       path: '/register',
       name: 'register',
@@ -260,7 +260,7 @@ const router = createRouter({
  */
   router.beforeEach(async (to) => {
     const store = useStore();
-    const publicPaths = [ '/register', '/passwordChange', '/admin/login',];
+    const publicPaths = [ '/register', '/passwordChange','/login'];
     // 1. 检查URL中的token
     const urlToken = new URLSearchParams(window.location.search).get('token');
     if (urlToken) {

+ 1 - 1
src/views/CourseSquare/component/CourseDetails/component/CourseHomeworkTable.vue

@@ -272,7 +272,7 @@ const openEditor = (url: string, title: string) => {
   }
 
   const handleWriting = (assignmentId:number) => {
-    router.push(`/home/homeworkDetail/${assignmentId}`);
+    router.push(`/home/homeworkDetail/${assignmentId}?fromCourse=1`);
     // Location.reload()
   }
 

+ 14 - 7
src/views/HomeworkPage/component/HomeworkDetail.vue

@@ -228,13 +228,20 @@ const fetchData = () => {
 
 const handleBack = () => {
    // 跳转到我的作业页面,携带课程ID参数以便自动选中对应课程
-   router.push({
-     path: '/home/myHomework',
-     query: {
-       courseId: data.courseId,
-       fromAssignment: 'true'
-     }
-   }).then(() => {window.location.reload()})
+  const { fromCourse} = route.query
+  if (!fromCourse){
+    router.push({
+      name: 'myHomework',
+      query: {
+        courseId: data.courseId,
+        fromAssignment: 'true'
+      }
+    }).then(() => {window.location.reload()})
+  }
+  else{
+    router.back()
+  }
+
 }
 
 onMounted(() => {