Sfoglia il codice sorgente

增加功能:url带有效token可直接使用

wandequan 1 anno fa
parent
commit
3c0dd658d6
2 ha cambiato i file con 8 aggiunte e 2 eliminazioni
  1. 1 0
      index.html
  2. 7 2
      src/views/HomeView.vue

+ 1 - 0
index.html

@@ -0,0 +1 @@
+<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>三维数字孪生SDK</title><script src="/static/config/web_config.js"></script><link rel="stylesheet" href="/static/css/element-reset.css"><link rel="stylesheet" href="/static/css/reset.css"><script defer="defer" type="module" src="/js/chunk-vendors.ece1c778.js"></script><script defer="defer" type="module" src="/js/index.668bda43.js"></script><link href="/css/chunk-vendors.13243bcb.css" rel="stylesheet"><link href="/css/index.94d7ae98.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.e6979eb1.js" nomodule></script><script defer="defer" src="/js/index-legacy.f3044709.js" nomodule></script></head><body><noscript><strong>We're sorry but 开发者中心 doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

+ 7 - 2
src/views/HomeView.vue

@@ -8,7 +8,7 @@
 </template>
 
 <script>
-import {defineAsyncComponent} from "vue";
+import { defineAsyncComponent } from "vue";
 import Router from "@/router";
 
 export default {
@@ -20,9 +20,14 @@ export default {
     Bottom: defineAsyncComponent(() => import('@/components/main/Bottom.vue')),
   },
   mounted() {
-    if ( (this.$store.state.token && this.$store.state.token=='') || localStorage.getItem('user-token') ) {
+    if ((this.$store.state.token && this.$store.state.token == '') || localStorage.getItem('user-token')) {
     } else {
+      if (location.search.indexOf("?token=") > -1) {
+        localStorage.setItem('user-token', location.search.replace("?token=", ""))
+        window.location.href = location.origin
+      } else {
         window.location.href = '/login'
+      }
     }
   }
 }