import { createApp } from 'vue'
|
// import { createPinia } from 'pinia'
|
import Cookie from 'js-cookie'
|
import App from './App.vue'
|
import router from './router'
|
|
import "@/style/index.scss"
|
import axios from 'axios'
|
|
|
|
|
const app = createApp(App)
|
|
|
// 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(pinia)
|
app.use(router)
|
|
|
app.mount('#app')
|