|
@@ -1,31 +1,36 @@
|
|
|
import store from '@/store'
|
|
|
import menus from '@/data/menus'
|
|
|
+import Vue from 'vue';
|
|
|
+import {Message} from 'element-ui';
|
|
|
+
|
|
|
+Vue.prototype.$message = Message;
|
|
|
+let vm = new Vue()
|
|
|
|
|
|
function toLogin() {
|
|
|
- let ssoServer = process.env.SSO_SERVER
|
|
|
- let redirectUrl = window.location.protocol + '//' + window.location.host
|
|
|
- console.log('tologin ', `${ssoServer}/login?redirectUrl=${redirectUrl}/auth`)
|
|
|
- window.location.href = `${ssoServer}/login?redirectUrl=${redirectUrl}/auth`
|
|
|
+ let ssoServer = process.env.SSO_SERVER
|
|
|
+ let redirectUrl = window.location.protocol + '//' + window.location.host
|
|
|
+ console.log('tologin ', `${ssoServer}/login?redirectUrl=${redirectUrl}/auth`)
|
|
|
+ window.location.href = `${ssoServer}/login?redirectUrl=${redirectUrl}/auth`
|
|
|
}
|
|
|
|
|
|
function checkMenu(menu, ps) {
|
|
|
- let result = { name: menu.name, icon: menu.icon, path: menu.path }
|
|
|
- if (menu.children) {
|
|
|
- // 如果有下级菜单权限,则自动拥有上级菜单权限
|
|
|
- result.children = []
|
|
|
- menu.children.forEach(child => {
|
|
|
- let submenu = checkMenu(child, ps)
|
|
|
- if (submenu) {
|
|
|
- result.children.push(submenu)
|
|
|
- }
|
|
|
- })
|
|
|
- return result.children.length > 0 ? result : null
|
|
|
- } else if (menu.opts) {
|
|
|
- return menu.opts.some(opt => ps[opt.permission]) ? result : null
|
|
|
- } else {
|
|
|
- // 如果没有下级菜单且没有opts属性, 菜单可以直接访问,不需要权限
|
|
|
- return result
|
|
|
- }
|
|
|
+ let result = {name: menu.name, icon: menu.icon, path: menu.path}
|
|
|
+ if (menu.children) {
|
|
|
+ // 如果有下级菜单权限,则自动拥有上级菜单权限
|
|
|
+ result.children = []
|
|
|
+ menu.children.forEach(child => {
|
|
|
+ let submenu = checkMenu(child, ps)
|
|
|
+ if (submenu) {
|
|
|
+ result.children.push(submenu)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return result.children.length > 0 ? result : null
|
|
|
+ } else if (menu.opts) {
|
|
|
+ return menu.opts.some(opt => ps[opt.permission]) ? result : null
|
|
|
+ } else {
|
|
|
+ // 如果没有下级菜单且没有opts属性, 菜单可以直接访问,不需要权限
|
|
|
+ return result
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export default {
|
|
@@ -36,25 +41,31 @@ export default {
|
|
|
* @param {*} next
|
|
|
*/
|
|
|
routerBeforeEach: async function(to, from, next) {
|
|
|
- console.log('router before ', to)
|
|
|
- // if (to.path == '/auth' || to.path == '/nouser') {
|
|
|
- next()
|
|
|
- // } else {
|
|
|
- // let userInfo = store.getters['layout/userInfo']
|
|
|
- // console.log("user info ", userInfo)
|
|
|
- // if (!userInfo) {
|
|
|
- // // 本地是未登录状态, 保存目标页面地址, 去登录
|
|
|
- // let lastRoute = { path: to.path, params: to.params, query: to.query }
|
|
|
- // store.commit('setLastRoute', lastRoute)
|
|
|
- // toLogin()
|
|
|
- // } else {
|
|
|
- // if (to.meta.breadcrumbs) {
|
|
|
- // store.dispatch('setBreadcrumb', to.meta.breadcrumbs)
|
|
|
- // }
|
|
|
- // next()
|
|
|
- // }
|
|
|
- // return true
|
|
|
- // }
|
|
|
+ console.log('router before ', to)
|
|
|
+ if (to.path == '/supplement' && !Object.keys(to.params).length) {
|
|
|
+ vm.$message.warning('产品设计中')
|
|
|
+ return next('/')
|
|
|
+ } else {
|
|
|
+ next()
|
|
|
+ }
|
|
|
+ // if (to.path == '/auth' || to.path == '/nouser') {
|
|
|
+ next()
|
|
|
+ // } else {
|
|
|
+ // let userInfo = store.getters['layout/userInfo']
|
|
|
+ // console.log("user info ", userInfo)
|
|
|
+ // if (!userInfo) {
|
|
|
+ // // 本地是未登录状态, 保存目标页面地址, 去登录
|
|
|
+ // let lastRoute = { path: to.path, params: to.params, query: to.query }
|
|
|
+ // store.commit('setLastRoute', lastRoute)
|
|
|
+ // toLogin()
|
|
|
+ // } else {
|
|
|
+ // if (to.meta.breadcrumbs) {
|
|
|
+ // store.dispatch('setBreadcrumb', to.meta.breadcrumbs)
|
|
|
+ // }
|
|
|
+ // next()
|
|
|
+ // }
|
|
|
+ // return true
|
|
|
+ // }
|
|
|
},
|
|
|
toNoUser(){
|
|
|
console.log(this)
|