Просмотр исходного кода

考试界面添加跳转功能

ChengYuXuan 5 лет назад
Родитель
Сommit
03465bceac
1 измененных файлов с 17 добавлено и 7 удалено
  1. 17 7
      src/views/exam/ExamPane.vue

+ 17 - 7
src/views/exam/ExamPane.vue

@@ -322,7 +322,12 @@ export default Vue.extend({
     },
     },
     leaveExam() {
     leaveExam() {
       this.exitDialog = false
       this.exitDialog = false
-      this.$router.push('/')
+      let redirect_uri = this.$route.query.redirect_uri ?? ''
+      if (redirect_uri) {
+        window.location.href = decodeURI(redirect_uri as string)
+      } else {
+        this.$router.push('/')
+      }
     },
     },
     submitAnswer() {
     submitAnswer() {
       this.submitDialog = false
       this.submitDialog = false
@@ -340,12 +345,17 @@ export default Vue.extend({
       objectiveJudge(this.examId, mapObj)
       objectiveJudge(this.examId, mapObj)
         .then(() => {
         .then(() => {
           setTimeout(() => {
           setTimeout(() => {
-            this.$router.push({
-              name: 'result',
-              params: {
-                examId: this.examId.toString()
-              }
-            })
+            let redirect_uri = this.$route.query.redirect_uri ?? ''
+            if (redirect_uri) {
+              window.location.href = decodeURIComponent(redirect_uri as string)
+            } else {
+              this.$router.push({
+                name: 'result',
+                params: {
+                  examId: this.examId.toString()
+                }
+              })
+            }
           }, 1000)
           }, 1000)
         })
         })
         .catch(() => {
         .catch(() => {