Explorar o código

fix:修复了作业有可能无法暂存和提交的问题

LiaoYanZhou hai 9 meses
pai
achega
8079d19db4

+ 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=http://127.0.0.1:4000";
+    //     window.location.href = "http://localhost:4000/login";
+    //     // {本地门户首页地址}?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) {

+ 7 - 4
src/views/EditPage/EditPage.vue

@@ -13,7 +13,9 @@
       <Dictionaries />
     </div>
     <div class="my-work-input">
-      <Edit :engagement="dataForm.engagement"/>
+      <Edit
+          :engagement="dataForm.engagement"
+      />
     </div>
     <Slider :dialogueId="dataForm.dialogueId" :engagement="dataForm.engagement"/>
   </div>
@@ -92,14 +94,15 @@
 
     await apis.getEngagement(store.user.id, assignmentId)
         .then((_res:any) => {
+          console.log(_res)
           Object.assign(dataForm, {
             dialogueId: dataForm.dialogueId,
             messages: dataForm.messages,
             engagement: _res.data.data
           })
-          if(!dataForm.engagement){
-            fetchData()
-          }
+          // if(!dataForm.engagement){
+          //   fetchData()
+          // }
         }).catch((_err:any) => {
           console.log("错误", _err)
         })

+ 3 - 2
src/views/Home/component/Edit/index.vue

@@ -19,6 +19,7 @@
 </template>
 
 <script lang="ts" setup>
+
   import "./index.scss";
   import type {engagementVO, IAssignment} from "@/types/vo";
   import {defineProps, onMounted, reactive, ref} from 'vue'
@@ -34,11 +35,9 @@
   interface IEditProps {
     engagement: engagementVO
   }
-
   const props = defineProps<{
     engagement: engagementVO
   }>()
-
   const apis = useApis()
   const store = useStore()
 
@@ -82,6 +81,7 @@
 
   // 提交操作
   const handleSubmit = async () => {
+    console.log(props)
     // 先自动暂存
     try {
       await handleStage();
@@ -111,6 +111,7 @@
   // 暂存操作
   const handleStage = async () => {
     try {
+      console.log(props)
       const _res = await apis.engagementStage(store.user.id, props.engagement.assignmentId, JSON.stringify(getQuillContent), getText.value, getHTML.value);
       emitter.emit('click-stage');
       success(_res.data.data);

+ 33 - 32
src/views/HomeworkPage/component/HomeworkDetail.vue

@@ -146,17 +146,40 @@ const getButtonTooltip = computed(() => {
 })
 
 function handleStart(){
-  getEngagement()
+  apis.getEngagement(store.user.id, assignmentId)
+      .then((_res:any) => {
+        //还未参加作业,则先加入作业
+        if(_res.data.data == null){
+          apis.engageAssignment(assignmentId)
+              .then((res:any) => {
+                ElMessage({
+                  message: '参加作业成功',
+                  type: 'success',
+                })
+                // 加入作业后重新获取状态
+                fetchEngagementStatus()
+                if(data.type == 'writing' || data.type == '写作'){
+                  router.push(`/home/assignment/${assignmentId}/edit`).then(() => {
+                    window.location.reload()
+                  })
+                } else if(data.type == 'speaking' || data.type == 'AI口语'){
+                  router.push(`/home/assignment/${assignmentId}/aispeaking`).then(() => {
+                    window.location.reload()
+                  })
+                }
+              })
+              .catch((_err:any) => {
+                console.log("参加做业的错误",_err)
+                ElMessage({
+                  message: '参加作业失败',
+                  type: 'error',
+                })
+              })
+        }
+      }).catch((_err:any) => {
+    console.log(_err)
+  })
   console.log(data.type)
-  if(data.type == 'writing' || data.type == '写作'){
-    router.push(`/home/assignment/${assignmentId}/edit`).then(() => {
-      window.location.reload()
-    })
-  } else if(data.type == 'speaking' || data.type == 'AI口语'){
-    router.push(`/home/assignment/${assignmentId}/aispeaking`).then(() => {
-      window.location.reload()
-    })
-  }
 }
 
 function downloadFile(url:string, fileName:string) {
@@ -183,28 +206,6 @@ async function fetchEngagementStatus() {
   }
 }
 
-async function getEngagement(){
-  apis.getEngagement(store.user.id, assignmentId)
-      .then((_res:any) => {
-        //还未参加作业,则先加入作业
-        if(_res.data.data == null){
-          apis.engageAssignment(assignmentId)
-              .then((res:any) => {
-                ElMessage({
-                  message: '参加作业成功',
-                  type: 'success',
-                })
-                // 加入作业后重新获取状态
-                fetchEngagementStatus()
-              })
-              .catch((_err:any) => {
-                console.log("参加做业的错误",_err)
-              })
-        }
-      }).catch((_err:any) => {
-        console.log(_err)
-      })
-}
 
 
 const fetchData = () => {