mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
32 lines
652 B
JavaScript
32 lines
652 B
JavaScript
/**
|
|
* plugins/index.js
|
|
*
|
|
* Automatically included in `./src/main.js`
|
|
*/
|
|
|
|
// Plugins
|
|
import vuetify from './vuetify'
|
|
import router from '@/router'
|
|
import store from '@/store'
|
|
import axios from 'axios'
|
|
|
|
export function registerPlugins (app) {
|
|
app
|
|
.use(vuetify)
|
|
.use(router)
|
|
.use(store)
|
|
|
|
// 读取用户令牌
|
|
const token = localStorage.getItem('user-token')
|
|
|
|
if (token) {
|
|
store.state.user.jwtToken = token
|
|
}
|
|
|
|
// 所有axios请求均携带用户令牌
|
|
axios.defaults.headers.common['Authorization'] = `Bearer ${store.state.user.jwtToken}`
|
|
|
|
app.config.globalProperties.$axios = axios
|
|
store.commit('initializeFetch')
|
|
}
|