From d5e4c0f3cf0fcc7b7110a0455fd836b94b0ad18b Mon Sep 17 00:00:00 2001 From: smallchill Date: Thu, 21 Feb 2019 22:19:04 +0800 Subject: [PATCH] :bug: Fixing a bug. --- src/mock/index.js | 6 +-- src/mock/menu.js | 116 ---------------------------------------------- src/mock/user.js | 26 +---------- src/permission.js | 14 ++---- vue.config.js | 2 +- 5 files changed, 10 insertions(+), 154 deletions(-) diff --git a/src/mock/index.js b/src/mock/index.js index 12550c1..35536e1 100644 --- a/src/mock/index.js +++ b/src/mock/index.js @@ -3,10 +3,10 @@ import menu from './menu'; /** * 模拟数据mock - * + * * mock是否开启模拟数据拦截 */ -user({ mock: true }); +user({ mock: true}); -menu({ mock: true }); \ No newline at end of file +menu({ mock: true }); diff --git a/src/mock/menu.js b/src/mock/menu.js index 49c1ee6..4e203f3 100644 --- a/src/mock/menu.js +++ b/src/mock/menu.js @@ -35,124 +35,8 @@ const top = [{ }, parentId: 3 }] -const first = [{ - label: "标签", - path: '/tags', - component: 'views/util/tags', - icon: 'icon-caidan', - meta: { - i18n: 'tags', - }, - children: [] -}, { - label: "存储", - path: '/store', - component: 'views/util/store', - icon: 'icon-caidan', - meta: { - i18n: 'store', - }, - children: [] -}, { - label: "全局函数", - path: 'https://avuex.avue.top/$/doc/api', - icon: 'icon-caidan', - meta: { - i18n: 'api', - }, - children: [] -}, { - label: "日志监控", - path: '/logs', - component: 'views/util/logs', - icon: 'icon-caidan', - meta: { - i18n: 'logs', - }, - children: [] -}, { - label: "表格", - path: '/table', - component: 'views/util/table', - icon: 'icon-caidan', - meta: { - i18n: 'table', - }, - children: [] -}, { - label: "表单", - path: '/form', - component: 'views/util/form', - icon: 'icon-caidan', - meta: { - i18n: 'form', - }, - children: [] -}, { - label: "权限", - path: '/permission', - component: 'views/util/permission', - icon: 'icon-caidan', - meta: { - i18n: 'permission', - }, - children: [] -}, { - label: "数据展示", - path: '/data', - component: 'views/util/data', - icon: 'icon-caidan', - meta: { - i18n: 'data', - }, - children: [] -}, { - label: "异常页", - path: '/error', - meta: { - i18n: 'error', - }, - icon: 'icon-caidan', - children: [{ - label: "403", - path: 'error', - component: 'components/error-page/403', - icon: 'icon-caidan', - children: [] - }, { - label: "404", - path: '404', - component: 'components/error-page/404', - icon: 'icon-caidan', - children: [] - }, { - label: "500", - path: '500', - component: 'components/error-page/500', - icon: 'icon-caidan', - children: [] - }] -}] -const second = [] -const third = [{ - label: "测试页面", - path: '/test', - component: 'views/test', - icon: 'icon-caidan', - meta: { - i18n: 'test', - }, - children: [] -}] export default ({ mock }) => { if (!mock) return; - let menu = [first, second, third]; - Mock.mock('/user/getMenu', 'get', (res) => { - let body = JSON.parse(res.body); - return { - data: menu[body.type] || [] - } - }) Mock.mock('/user/getTopMenu', 'get', () => { return { data: top diff --git a/src/mock/user.js b/src/mock/user.js index 686ed2b..d8b6a2b 100644 --- a/src/mock/user.js +++ b/src/mock/user.js @@ -13,30 +13,6 @@ export default ({ mock }) => { Mock.mock('/user/refesh', 'post', { data: new Date().getTime() + '' }); - //获取用户信息 - Mock.mock('/user/getUserInfo', 'get', { - data: { - userInfo: { - username: 'admin', - name: 'avue', - avatar: 'https://gitee.com/uploads/61/632261_smallweigit.jpg', - }, - roles: 'admin', - permission: [ - 'sys_crud_btn_add', - 'sys_crud_btn_export', - 'sys_menu_btn_add', - 'sys_menu_btn_edit', - 'sys_menu_btn_del', - 'sys_role_btn1', - 'sys_role_btn2', - 'sys_role_btn3', - 'sys_role_btn4', - 'sys_role_btn5', - 'sys_role_btn6', - ], //权限级别 - } - }); //获取表格数据 Mock.mock('/user/getTable', 'get', () => { @@ -65,4 +41,4 @@ export default ({ mock }) => { } } }) -} \ No newline at end of file +} diff --git a/src/permission.js b/src/permission.js index 2fcbb93..3993c17 100644 --- a/src/permission.js +++ b/src/permission.js @@ -1,6 +1,6 @@ /** * 全站权限配置 - * + * */ import router from './router/router' import store from './store' @@ -32,13 +32,9 @@ router.beforeEach((to, from, next) => { next({ path: '/' }) } else { //如果用户信息为空则获取用户信息,获取用户信息失败,跳转到登录页 - if (store.getters.roles.length === 0) { - store.dispatch('GetUserInfo').then(() => { - next({ ...to, replace: true }) - }).catch(() => { - store.dispatch('FedLogOut').then(() => { - next({ path: '/login' }) - }) + if (store.getters.token.length === 0) { + store.dispatch('FedLogOut').then(() => { + next({ path: '/login' }) }) } else { const value = to.query.src || to.fullPath; @@ -82,4 +78,4 @@ router.afterEach(() => { title = router.$avueRouter.generateTitle(title, i18n) //根据当前的标签也获取label的值动态设置浏览器标题 router.$avueRouter.setTitle(title); -}); \ No newline at end of file +}); diff --git a/vue.config.js b/vue.config.js index b127291..d7f4594 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,6 +1,6 @@ // 基础路径 注意发布之前要先修改这里 let baseUrl = './' -let url = 'http://localhost:88' +let url = 'http://localhost:8800' module.exports = { baseUrl: baseUrl, // 根据你的实际情况更改这里 lintOnSave: true,