引入element-plus图标
This commit is contained in:
+11
-5
@@ -11,11 +11,13 @@ const service = axios.create({
|
||||
})
|
||||
|
||||
import { ElMessage, ElLoading } from 'element-plus'
|
||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||
|
||||
|
||||
// 添加请求拦截器
|
||||
service.interceptors.request.use(config => {
|
||||
// 在发送请求之前添加token到请求头
|
||||
const token = app.$store.state.loginInfo.token
|
||||
const token = mountedApp.$store.state.loginInfo.token
|
||||
if (token !== null && config.headers) {
|
||||
config.headers.token = token
|
||||
}
|
||||
@@ -39,7 +41,7 @@ service.interceptors.response.use(res=> {
|
||||
ElMessage.warning(message)
|
||||
}
|
||||
if (err.response.status === 403) {
|
||||
app.$router.push('/login')
|
||||
mountedApp.$router.push('/login')
|
||||
}
|
||||
}
|
||||
return Promise.reject(err)
|
||||
@@ -47,8 +49,8 @@ service.interceptors.response.use(res=> {
|
||||
|
||||
// 全局路由导航前置守卫
|
||||
router.beforeEach(function (to, from, next) {
|
||||
app.$store.commit('setBreadcrumb', routePathes[to.path] || [])
|
||||
if(filterExclude.indexOf(to.path) !== -1 || app.$store.state.loginInfo.token) {
|
||||
mountedApp.$store.commit('setBreadcrumb', routePathes[to.path] || [])
|
||||
if(filterExclude.indexOf(to.path) !== -1 || mountedApp.$store.state.loginInfo.token) {
|
||||
next()
|
||||
} else {
|
||||
next('/login')
|
||||
@@ -56,7 +58,11 @@ router.beforeEach(function (to, from, next) {
|
||||
})
|
||||
|
||||
const app = createApp(App)
|
||||
.use(router)
|
||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
app.component(key, component)
|
||||
}
|
||||
|
||||
const mountedApp = app.use(router)
|
||||
.use(store)
|
||||
.use(VueAxios, service)
|
||||
.directive('loading', ElLoading.directive)
|
||||
|
||||
Reference in New Issue
Block a user