Browse Source

日常开发

林旭祥 1 month ago
parent
commit
40658781a5
3 changed files with 35 additions and 26 deletions
  1. 6 8
      src/App.vue
  2. 8 2
      src/router/permission.ts
  3. 21 16
      src/views/analysis/detail.vue

+ 6 - 8
src/App.vue

@@ -4,14 +4,12 @@
 
 <script setup lang="ts">
 //import Speech from 'speak-tts';
-import router from '@/router';
-const { proxy } = getCurrentInstance() as any;
-if (!['/analysis/index', '/analysis/detail'].includes(router.currentRoute.value.path)) {
-    proxy?.$http.common.baiduToken({}).then((res: any) => {
-        let tok = res.token;
-        localStorage.setItem('tok', tok);
-    });
-}
+// const { proxy } = getCurrentInstance() as any;
+// proxy?.$http.common.baiduToken({}).then((res: any) => {
+//     let tok = res.token;
+//     localStorage.setItem('tok', tok);
+// });
+
 //let speech = new Speech();
 //let state = localStorage.getItem('ttsState');
 // if (!speech.hasBrowserSupport()) {

+ 8 - 2
src/router/permission.ts

@@ -1,4 +1,5 @@
 import router from './index';
+import http from '@/api';
 const whiteList = ['/login', '/login/qrcode', '/login/mobile', '/login/sunshineRun', '/analysis/index', '/analysis/detail'];
 const routers = router.getRoutes().map((item) => {
   return item.path;
@@ -25,7 +26,12 @@ router.beforeEach(async (to, from, next) => {
       next({ path: '/gesture' });
     } else if (to.path === '/login/sunshineRun') {
       next({ path: '/sunshineRun' });
-    }  else {
+    } else {
+      //获取百度TTS的token
+      http.common.baiduToken({}).then((res: any) => {
+        let tok = res.token;
+        localStorage.setItem('tok', tok);
+      });
       next();
     }
   } else {
@@ -43,7 +49,7 @@ router.beforeEach(async (to, from, next) => {
       // 否则全部重定向到登录页
       if (to.path === '/gesture') {
         next(`/login/qrcode`);
-      }else if (to.path === '/sunshineRun') {
+      } else if (to.path === '/sunshineRun') {
         next(`/login/sunshineRun`);
       } else {
         next(`/login`);

+ 21 - 16
src/views/analysis/detail.vue

@@ -349,7 +349,12 @@ const getDetails = () => {
 
 //返回
 const getBack = () => {
-  router.go(-1);
+  console.log("router", router.options.history.state.back)
+  if (router.options.history.state.back == null) {
+    router.push({ path: '/analysis/index', query: { project: query.value.exam_name, school: details.value.school_id }  });
+  } else {
+    router.go(-1);
+  }
 };
 
 onBeforeMount(() => {
@@ -380,23 +385,23 @@ onMounted(() => {
   height: calc(100vh - 10vh - 20px);
   overflow-y: scroll;
   overflow-x: hidden;
-	padding-bottom: 20px;
-	padding-top: 10vh;
+  padding-bottom: 20px;
+  padding-top: 10vh;
 
   .back {
-	position: fixed;
-	top: 0;
-	width: 100%;
-	height: 10vh;
-	line-height: 10vh;
-	display: flex;
-	align-items: center;
-	justify-content: flex-start;
-	box-sizing: border-box;
-	padding: 0 1.5rem;
-	cursor: pointer;
-	z-index: 2;
-}
+    position: fixed;
+    top: 0;
+    width: 100%;
+    height: 10vh;
+    line-height: 10vh;
+    display: flex;
+    align-items: center;
+    justify-content: flex-start;
+    box-sizing: border-box;
+    padding: 0 1.5rem;
+    cursor: pointer;
+    z-index: 2;
+  }
 
   .back::before {
     content: "";