mirror of
https://github.com/fantastic-admin/basic.git
synced 2026-10-07 16:08:02 +08:00
代码优化
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
import axios from 'axios'
|
||||
// import qs from 'qs'
|
||||
// import Qs from 'qs'
|
||||
import router from '@/router/index'
|
||||
import store from '@/store/index'
|
||||
import { Message } from 'element-ui'
|
||||
@@ -36,7 +36,7 @@ api.interceptors.request.use(
|
||||
if (store.getters['user/isLogin']) {
|
||||
request.data.token = store.state.user.token
|
||||
}
|
||||
// request.data = qs.stringify(request.data)
|
||||
// request.data = Qs.stringify(request.data)
|
||||
}
|
||||
} else {
|
||||
// 带上 token
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@ Vue.use(auth)
|
||||
import cookies from 'vue-cookies'
|
||||
Vue.use(cookies)
|
||||
|
||||
import meta from 'vue-meta'
|
||||
Vue.use(meta)
|
||||
import VueMeta from 'vue-meta'
|
||||
Vue.use(VueMeta)
|
||||
|
||||
import ElementUI from 'element-ui'
|
||||
import 'element-ui/lib/theme-chalk/index.css'
|
||||
|
||||
+8
-8
@@ -1,10 +1,10 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
import VueRouter from 'vue-router'
|
||||
import store from '@/store/index'
|
||||
import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css' // progress bar style
|
||||
|
||||
Vue.use(Router)
|
||||
Vue.use(VueRouter)
|
||||
|
||||
import Layout from '@/layout'
|
||||
import EmptyLayout from '@/layout/empty'
|
||||
@@ -121,17 +121,17 @@ const lastRoute = [{
|
||||
}
|
||||
}]
|
||||
|
||||
const router = new Router({
|
||||
const router = new VueRouter({
|
||||
routes: constantRoutes
|
||||
})
|
||||
|
||||
// 解决路由在 push/replace 了相同地址报错的问题
|
||||
const originalPush = Router.prototype.push
|
||||
Router.prototype.push = function push(location) {
|
||||
const originalPush = VueRouter.prototype.push
|
||||
VueRouter.prototype.push = function push(location) {
|
||||
return originalPush.call(this, location).catch(err => err)
|
||||
}
|
||||
const originalReplace = Router.prototype.replace
|
||||
Router.prototype.replace = function replace(location) {
|
||||
const originalReplace = VueRouter.prototype.replace
|
||||
VueRouter.prototype.replace = function replace(location) {
|
||||
return originalReplace.call(this, location).catch(err => err)
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ router.beforeEach(async(to, from, next) => {
|
||||
* 重置 matcher
|
||||
* https://blog.csdn.net/baidu_28647571/article/details/101711682
|
||||
*/
|
||||
router.matcher = new Router({
|
||||
router.matcher = new VueRouter({
|
||||
routes: constantRoutes
|
||||
}).matcher
|
||||
const accessRoutes = await store.dispatch('menu/generateRoutes', {
|
||||
|
||||
Reference in New Issue
Block a user