From c2f95b0b9090a2394b5b068582b932a5e57b86aa Mon Sep 17 00:00:00 2001
From: zmc <zmc_li@foxmail.com>
Date: 星期二, 05 九月 2023 18:19:37 +0800
Subject: [PATCH] 雷达图 新增综合风险排名 数据接入配置

---
 src/main.ts |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/src/main.ts b/src/main.ts
index bc891f6..b6f4335 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,8 +1,6 @@
-// import './assets/main.css'
-
 import { createApp } from 'vue'
-import { createPinia } from 'pinia'
-
+// import { createPinia } from 'pinia'
+import Cookie from 'js-cookie'
 import App from './App.vue'
 import router from './router'
 
@@ -14,21 +12,34 @@
 
 const app = createApp(App)
 
-function SecretPiniaPlugin() {
-    return { secret: 'the cake is a lie',vue:'333.0' }
-  }
+
+// function SecretPiniaPlugin() {
+//     return { secret: 'the cake is a lie',vue:'333.0' }
+//   }
   
-  const pinia = createPinia()
-  // 灏嗘彃浠舵彁渚涚粰 pinia
-  pinia.use(SecretPiniaPlugin)
+//   const pinia = createPinia()
+//   // 灏嗘彃浠舵彁渚涚粰 pinia
+//   pinia.use(SecretPiniaPlugin)
   // pinia.use(() => ({'澶�':'闆ㄥぉ'}))
 
+router.beforeEach((to,from,next)=>{
+  const token = Cookie.get('token')
+  if(!token && to.name!='login'){
+    next({name:'login'}) 
+  }
+  // token瀛樺湪锛屼絾鐢ㄦ埛鍒囨崲鐨勬槸鐧诲綍椤甸潰鏃讹紝杩斿洖榛樿涓荤晫闈�
+  else if(token && to.name =='login'){
+    next({name:'edata'}) 
+  }else{
+    next()
+  }
+})
 
 // axios.defaults.baseURL = 'http://192.168.1.4:8081'
 axios.defaults.baseURL = 'http://localhost:8081'
 app.config.globalProperties.$http = axios
 
-app.use(pinia)
+// app.use(pinia)
 app.use(router)
 
 

--
Gitblit v1.9.3