From e1e826565abaad1fe49389d8ad2eb7f7fdacc28a Mon Sep 17 00:00:00 2001 From: zmc <zmc_li@foxmail.com> Date: 星期二, 05 九月 2023 18:31:19 +0800 Subject: [PATCH] 接口 --- src/main.ts | 34 ++++++++++++++++++++++++++++------ 1 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 65c587c..d913468 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,10 +12,34 @@ const app = createApp(App) -axios.defaults.baseURL = 'http://localhost:8081' + +// function SecretPiniaPlugin() { +// return { secret: 'the cake is a lie',vue:'333.0' } +// } + +// 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' +axios.defaults.baseURL = 'http://114.215.109.124:8803' app.config.globalProperties.$http = axios -app.use(createPinia()) +// app.use(pinia) app.use(router) -- Gitblit v1.9.3