Compare commits
No commits in common. "1b6ffddcf9c3adaad3df6fb194a6cc0bd3f273f4" and "bb6925f3a224355de01cab82b5a5fe2b984ec1a6" have entirely different histories.
1b6ffddcf9
...
bb6925f3a2
@ -254,8 +254,12 @@ export default {
|
|||||||
},
|
},
|
||||||
routerTitle: {
|
routerTitle: {
|
||||||
dashboard: {
|
dashboard: {
|
||||||
zh: '仪表盘',
|
zh: '',
|
||||||
en: 'Dashboard'
|
en: '',
|
||||||
|
dashboard: {
|
||||||
|
zh: '仪表盘',
|
||||||
|
en: 'Dashboard'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
basic: {
|
basic: {
|
||||||
zh: '系统管理',
|
zh: '系统管理',
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<!--
|
<!--
|
||||||
* @Author: your name
|
* @Author: your name
|
||||||
* @Date: 2021-01-27 10:07:42
|
* @Date: 2021-01-27 10:07:42
|
||||||
* @LastEditTime: 2021-12-22 16:06:25
|
* @LastEditTime: 2021-03-08 11:59:59
|
||||||
* @LastEditors: zwq
|
* @LastEditors: gtz
|
||||||
* @Description: In User Settings Edit
|
* @Description: In User Settings Edit
|
||||||
* @FilePath: \mt-bus-fe\src\layout\components\Sidebar\index.vue
|
* @FilePath: \mt-bus-fe\src\layout\components\Sidebar\index.vue
|
||||||
-->
|
-->
|
||||||
@ -31,17 +31,31 @@ import { mapGetters } from 'vuex'
|
|||||||
import Logo from './Logo'
|
import Logo from './Logo'
|
||||||
import SidebarItem from './SidebarItem'
|
import SidebarItem from './SidebarItem'
|
||||||
import variables from '@/styles/variables.scss'
|
import variables from '@/styles/variables.scss'
|
||||||
import { constantRoutes } from '@/router'
|
// import { constantRoutes } from '@/router'
|
||||||
|
import store from '@/store'
|
||||||
export default {
|
export default {
|
||||||
components: { SidebarItem, Logo },
|
components: { SidebarItem, Logo },
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'sidebar',
|
'sidebar',
|
||||||
'permission_routes',
|
'choicepart',
|
||||||
'language'
|
'language'
|
||||||
]),
|
]),
|
||||||
|
partList() {
|
||||||
|
const cangoList = []
|
||||||
|
const constantRoutes = store.getters.permission_routes
|
||||||
|
constantRoutes.map(item => {
|
||||||
|
if (!item.hidden && item.meta) {
|
||||||
|
cangoList.push(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const formatList = cangoList.map((item, index) => {
|
||||||
|
return this.setIndex(item, index)
|
||||||
|
})
|
||||||
|
return formatList
|
||||||
|
},
|
||||||
routeList() {
|
routeList() {
|
||||||
return constantRoutes
|
return [this.partList[this.choicepart]]
|
||||||
},
|
},
|
||||||
activeMenu() {
|
activeMenu() {
|
||||||
const route = this.$route
|
const route = this.$route
|
||||||
@ -53,7 +67,6 @@ export default {
|
|||||||
return path
|
return path
|
||||||
},
|
},
|
||||||
showLogo() {
|
showLogo() {
|
||||||
console.log(this.$route)
|
|
||||||
return this.$store.state.settings.sidebarLogo
|
return this.$store.state.settings.sidebarLogo
|
||||||
},
|
},
|
||||||
variables() {
|
variables() {
|
||||||
@ -62,6 +75,24 @@ export default {
|
|||||||
isCollapse() {
|
isCollapse() {
|
||||||
return !this.sidebar.opened
|
return !this.sidebar.opened
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
$route: function(val) {
|
||||||
|
if (val.meta.routeIndex >= 0) {
|
||||||
|
this.$store.dispatch('app/setChoicepart', val.meta.routeIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
setIndex(list, index) {
|
||||||
|
list.meta.routeIndex = index
|
||||||
|
if (list.children) {
|
||||||
|
list.children.map(item => {
|
||||||
|
this.setIndex(item, index)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -45,8 +45,8 @@ export default {
|
|||||||
return this.$store.state.tagsView.visitedViews
|
return this.$store.state.tagsView.visitedViews
|
||||||
},
|
},
|
||||||
routes() {
|
routes() {
|
||||||
return this.$store.state.permission.routes
|
// return this.$store.state.permission.routes
|
||||||
// return []
|
return []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* @Date: 2020-12-14 09:07:03
|
* @Date: 2020-12-14 09:07:03
|
||||||
* @LastEditors: zwq
|
* @LastEditors: gtz
|
||||||
* @LastEditTime: 2021-12-22 16:13:30
|
* @LastEditTime: 2021-02-25 09:42:36
|
||||||
* @FilePath: \basic-admin\src\permission.js
|
* @FilePath: \basic-admin\src\permission.js
|
||||||
* @Description: 路由权限检查
|
* @Description: 路由权限检查
|
||||||
*/
|
*/
|
||||||
import router from './router'
|
import router from './router'
|
||||||
|
// import { resetRouter } from '@/router'
|
||||||
import { Message } from 'element-ui'
|
import { Message } from 'element-ui'
|
||||||
import NProgress from 'nprogress' // progress bar
|
import NProgress from 'nprogress' // progress bar
|
||||||
import 'nprogress/nprogress.css' // progress bar style
|
import 'nprogress/nprogress.css' // progress bar style
|
||||||
@ -34,28 +35,38 @@ router.beforeEach(async(to, from, next) => {
|
|||||||
next({ path: '/' })
|
next({ path: '/' })
|
||||||
NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939
|
NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939
|
||||||
} else {
|
} else {
|
||||||
// next()
|
const hasRoles = store.getters.menus && store.getters.menus.length > 0
|
||||||
NProgress.done()
|
console.log('store.getters.menus', store.getters.menus)
|
||||||
try {
|
console.log('store.getters', store.getters)
|
||||||
// // generate accessible routes map based on roles
|
console.log('hasRoles=', hasRoles)
|
||||||
// const accessRoutes = await store.dispatch('permission/generateRoutes')
|
if (hasRoles) {
|
||||||
// console.log(accessRoutes)
|
console.log('hasRoles=', store.getters.menus)
|
||||||
// router.addRoutes(accessRoutes)
|
|
||||||
next()
|
next()
|
||||||
|
NProgress.done()
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
// // generate accessible routes map based on roles
|
||||||
|
const { menus } = await store.dispatch('user/getInfo')
|
||||||
|
console.log(menus)
|
||||||
|
const accessRoutes = await store.dispatch('permission/generateRoutes', menus)
|
||||||
|
console.log('accessRoutes', accessRoutes)
|
||||||
|
router.addRoutes(accessRoutes)
|
||||||
|
next({ ...to, replace: true })
|
||||||
// hack method to ensure that addRoutes is complete
|
// hack method to ensure that addRoutes is complete
|
||||||
// set the replace: true, so the navigation will not leave a history record
|
// set the replace: true, so the navigation will not leave a history record
|
||||||
// next({ ...to, replace: true })
|
// next({ ...to, replace: true })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// remove token and go to login page to re-login
|
// remove token and go to login page to re-login
|
||||||
next(`/login?redirect=${to.path}`)
|
next(`/login?redirect=${to.path}`)
|
||||||
await store.dispatch('user/resetToken')
|
await store.dispatch('user/resetToken')
|
||||||
Message.error(error || 'Has Error')
|
Message.error(error || 'Has Error')
|
||||||
NProgress.done()
|
NProgress.done()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* has no token*/
|
/* has no token*/
|
||||||
console.log('to.path=' + to.path)
|
console.log('has no token to.path=' + to.path)
|
||||||
console.log('whiteList.indexOf(to.path)=' + whiteList.indexOf(to.path))
|
console.log('whiteList.indexOf(to.path)=' + whiteList.indexOf(to.path))
|
||||||
if (whiteList.indexOf(to.path) !== -1) {
|
if (whiteList.indexOf(to.path) !== -1) {
|
||||||
// in the free login whitelist, go directly
|
// in the free login whitelist, go directly
|
||||||
|
@ -2,6 +2,7 @@ import Vue from 'vue'
|
|||||||
import Router from 'vue-router'
|
import Router from 'vue-router'
|
||||||
import i18n from '@/lang/i18n'
|
import i18n from '@/lang/i18n'
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
|
import store from '@/store'
|
||||||
|
|
||||||
const routerTitle = i18n.routerTitle
|
const routerTitle = i18n.routerTitle
|
||||||
const language = Cookies.get('language')
|
const language = Cookies.get('language')
|
||||||
@ -59,24 +60,11 @@ export const constantRoutes = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
component: Layout,
|
component: () => import('@/views/ChoicePart'),
|
||||||
redirect: '/dashboard',
|
hidden: true,
|
||||||
children: [
|
meta: { requireToken: true }
|
||||||
{
|
|
||||||
path: 'dashboard',
|
|
||||||
component: () => import('@/views/dashboard/index'),
|
|
||||||
name: 'Dashboard',
|
|
||||||
meta: { title: routerTitle.dashboard?.[language] || routerTitle.dashboard.en, icon: 'form', iconPart: 'dashboard', affix: true, required: true, requireToken: true }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// path: '/',
|
|
||||||
// component: () => import('@/views/ChoicePart'),
|
|
||||||
// hidden: true,
|
|
||||||
// meta: { requireToken: true }
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// path: '/auth-redirect',
|
// path: '/auth-redirect',
|
||||||
// component: () => import('@/views/login/auth-redirect'),
|
// component: () => import('@/views/login/auth-redirect'),
|
||||||
// hidden: true
|
// hidden: true
|
||||||
@ -90,7 +78,28 @@ export const constantRoutes = [
|
|||||||
path: '/401',
|
path: '/401',
|
||||||
component: () => import('@/views/error-page/401'),
|
component: () => import('@/views/error-page/401'),
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
}
|
||||||
|
// 工单管理、厂务管理、包装管理、接口管理、数据采集、报表、质量管理、SPC
|
||||||
|
/** when your routing map is too long, you can split it into small modules **/
|
||||||
|
// 404 page must be placed at the end !!!
|
||||||
|
// { path: '*', redirect: '/404', hidden: true }
|
||||||
|
]
|
||||||
|
|
||||||
|
export const dynamicRoutes = [
|
||||||
|
// {
|
||||||
|
// path: '/dashboard',
|
||||||
|
// component: Layout,
|
||||||
|
// redirect: '/dashboard',
|
||||||
|
// name: 'dashboard',
|
||||||
|
// children: [
|
||||||
|
// {
|
||||||
|
// path: 'dashboard',
|
||||||
|
// component: () => import('@/views/dashboard/index'),
|
||||||
|
// name: 'Dashboard',
|
||||||
|
// meta: { title: routerTitle.dashboard.dashboard?.[language] || routerTitle.dashboard.dashboard.en, icon: 'dashboard', affix: true }
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
path: '/basicData',
|
path: '/basicData',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
@ -502,7 +511,7 @@ export const constantRoutes = [
|
|||||||
path: 'recipe',
|
path: 'recipe',
|
||||||
component: () => import('@/views/EquipmentManager/RecipeManager'),
|
component: () => import('@/views/EquipmentManager/RecipeManager'),
|
||||||
name: 'RecipeManage',
|
name: 'RecipeManage',
|
||||||
meta: { title: routerTitle.equipment.recipe?.[language] || routerTitle.equipment.recipe.en, icon: 'form', affix: true }
|
meta: { title: routerTitle.equipment.recipe?.[language] || routerTitle.equipment.recipe?.en, icon: 'form', affix: true }
|
||||||
}, {
|
}, {
|
||||||
path: 'sparepart',
|
path: 'sparepart',
|
||||||
component: () => import('@/views/EquipmentManager/sqarepart'),
|
component: () => import('@/views/EquipmentManager/sqarepart'),
|
||||||
@ -520,7 +529,7 @@ export const constantRoutes = [
|
|||||||
component: () => import('@/views/EquipmentManager/RecipeManager/subpage/detail'),
|
component: () => import('@/views/EquipmentManager/RecipeManager/subpage/detail'),
|
||||||
name: 'RecipeParamManage',
|
name: 'RecipeParamManage',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
meta: { title: routerTitle.equipment.recipeform?.[language] || routerTitle.equipment.recipeform.en, icon: 'form', affix: true }
|
meta: { title: routerTitle.equipment.recipeform?.[language] || routerTitle.equipment.recipeform?.en, icon: 'form', affix: true }
|
||||||
}, {
|
}, {
|
||||||
path: 'statussetting',
|
path: 'statussetting',
|
||||||
component: () => import('@/views/EquipmentManager/StatusSetting'),
|
component: () => import('@/views/EquipmentManager/StatusSetting'),
|
||||||
@ -1178,18 +1187,18 @@ export const constantRoutes = [
|
|||||||
path: 'plan',
|
path: 'plan',
|
||||||
component: () => import('@/views/QualityManager/plan'),
|
component: () => import('@/views/QualityManager/plan'),
|
||||||
name: 'PlanManage',
|
name: 'PlanManage',
|
||||||
meta: { title: routerTitle.quality.plan?.[language] || routerTitle.quality.plan.en, icon: 'form', affix: true }
|
meta: { title: routerTitle.quality.plan?.[language] || routerTitle.quality.plan?.en, icon: 'form', affix: true }
|
||||||
}, {
|
}, {
|
||||||
path: 'planparam',
|
path: 'planparam',
|
||||||
component: () => import('@/views/QualityManager/plan/subpage/detail'),
|
component: () => import('@/views/QualityManager/plan/subpage/detail'),
|
||||||
name: 'PlanParamManage',
|
name: 'PlanParamManage',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
meta: { title: routerTitle.quality.planform?.[language] || routerTitle.quality.planform.en, icon: 'form', affix: true }
|
meta: { title: routerTitle.quality.planform?.[language] || routerTitle.quality.planform?.en, icon: 'form', affix: true }
|
||||||
}, {
|
}, {
|
||||||
path: 'issue',
|
path: 'issue',
|
||||||
component: () => import('@/views/QualityManager/plan/issuedplan'),
|
component: () => import('@/views/QualityManager/plan/issuedplan'),
|
||||||
name: 'PlanIssuedManage',
|
name: 'PlanIssuedManage',
|
||||||
meta: { title: routerTitle.quality.issuedplan?.[language] || routerTitle.quality.issuedplan.en, icon: 'form', affix: true }
|
meta: { title: routerTitle.quality.issuedplan?.[language] || routerTitle.quality.issuedplan?.en, icon: 'form', affix: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/offlineDetec',
|
path: '/offlineDetec',
|
||||||
@ -1287,23 +1296,49 @@ export const constantRoutes = [
|
|||||||
},
|
},
|
||||||
{ path: '*', redirect: '/404', hidden: true }
|
{ path: '*', redirect: '/404', hidden: true }
|
||||||
]
|
]
|
||||||
export const asyncRoutes = [
|
|
||||||
// 404 page must be placed at the end !!!
|
|
||||||
{ path: '*', redirect: '/404', hidden: true }
|
|
||||||
]
|
|
||||||
|
|
||||||
const createRouter = () =>
|
const createRouter = (r) =>
|
||||||
new Router({
|
new Router({
|
||||||
// mode: 'history', // require service support
|
// mode: 'history', // require service support
|
||||||
scrollBehavior: () => ({ y: 0 }),
|
scrollBehavior: () => ({ y: 0 }),
|
||||||
routes: constantRoutes
|
routes: r
|
||||||
})
|
})
|
||||||
|
|
||||||
const router = createRouter()
|
const router = createRouter(constantRoutes)
|
||||||
|
|
||||||
|
router.beforeEach((to, from, next) => {
|
||||||
|
console.log('route.index', to, to.meta.routeIndex)
|
||||||
|
if (to.meta.routeIndex >= 0) {
|
||||||
|
store.dispatch('app/setChoicepart', to.meta.routeIndex)
|
||||||
|
}
|
||||||
|
// 拦截器
|
||||||
|
console.log('route,to.path:', to.path)
|
||||||
|
if (to.meta.requireToken) {
|
||||||
|
if (Cookies.get('Admin-Token')) {
|
||||||
|
if (to.meta.required) {
|
||||||
|
if (Cookies.get('choicepart') === 'undefined' || !Cookies.get('choicepart')) {
|
||||||
|
next({
|
||||||
|
path: '/'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
next({
|
||||||
|
path: '/login'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
|
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
|
||||||
export function resetRouter() {
|
export function resetRouter() {
|
||||||
const newRouter = createRouter()
|
const newRouter = createRouter(constantRoutes)
|
||||||
router.matcher = newRouter.matcher // reset router
|
router.matcher = newRouter.matcher // reset router
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* @Date: 2020-12-14 09:07:03
|
* @Date: 2020-12-14 09:07:03
|
||||||
* @LastEditors: zwq
|
* @LastEditors: gtz
|
||||||
* @LastEditTime: 2021-12-22 11:38:46
|
* @LastEditTime: 2021-01-29 14:24:20
|
||||||
* @FilePath: \basic-admin\src\store\getters.js
|
* @FilePath: \basic-admin\src\store\getters.js
|
||||||
* @Description:
|
* @Description:
|
||||||
*/
|
*/
|
||||||
@ -19,6 +19,7 @@ const getters = {
|
|||||||
introduction: state => state.user.introduction,
|
introduction: state => state.user.introduction,
|
||||||
username: state => state.user.username,
|
username: state => state.user.username,
|
||||||
roles: state => state.user.roles,
|
roles: state => state.user.roles,
|
||||||
|
menus: state => state.user.menus,
|
||||||
permission_routes: state => state.permission.routes
|
permission_routes: state => state.permission.routes
|
||||||
}
|
}
|
||||||
export default getters
|
export default getters
|
||||||
|
@ -1,38 +1,36 @@
|
|||||||
/*
|
import { dynamicRoutes, constantRoutes } from '@/router'
|
||||||
* @Author: zwq
|
import { getListItems } from '@/utils/tree'
|
||||||
* @Date: 2021-09-18 16:09:08
|
|
||||||
* @LastEditors: zwq
|
|
||||||
* @LastEditTime: 2021-12-22 15:43:46
|
|
||||||
* @Description:
|
|
||||||
*/
|
|
||||||
import { asyncRoutes, constantRoutes } from '@/router'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use meta.role to determine if the current user has permission
|
* Use meta.role to determine if the current user has permission
|
||||||
* @param roles
|
* @param roles
|
||||||
* @param route
|
* @param route
|
||||||
*/
|
*/
|
||||||
function hasPermission(roles, route) {
|
function hasPermission(menuList, route) {
|
||||||
if (route.meta && route.meta.roles) {
|
// if (route.meta && route.meta.roles) {
|
||||||
return roles.some(role => route.meta.roles.includes(role))
|
// return roles.some(role => route.meta.roles.includes(role))
|
||||||
} else {
|
// } else {
|
||||||
|
// return true
|
||||||
|
// }
|
||||||
|
if (route.hidden) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
return menuList.some(m => route.path === m.h)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter asynchronous routing tables by recursion
|
* Filter asynchronous routing tables by recursion
|
||||||
* @param routes asyncRoutes
|
* @param routes asyncRoutes
|
||||||
* @param roles
|
* @param menuList
|
||||||
*/
|
*/
|
||||||
export function filterAsyncRoutes(routes, roles) {
|
export function filterAsyncRoutes(routes, menuList) {
|
||||||
const res = []
|
const res = []
|
||||||
|
|
||||||
routes.forEach(route => {
|
routes.forEach(route => {
|
||||||
const tmp = { ...route }
|
const tmp = { ...route }
|
||||||
if (hasPermission(roles, tmp)) {
|
if (hasPermission(menuList, tmp)) {
|
||||||
if (tmp.children) {
|
if (tmp.children) {
|
||||||
tmp.children = filterAsyncRoutes(tmp.children, roles)
|
tmp.children = filterAsyncRoutes(tmp.children, menuList)
|
||||||
}
|
}
|
||||||
res.push(tmp)
|
res.push(tmp)
|
||||||
}
|
}
|
||||||
@ -54,13 +52,19 @@ const mutations = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
generateRoutes({ commit }, roles) {
|
generateRoutes({ commit }, menus) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
let accessedRoutes
|
let accessedRoutes
|
||||||
if (roles.includes('admin')) {
|
console.log(menus)
|
||||||
accessedRoutes = asyncRoutes || []
|
if (!menus) {
|
||||||
|
accessedRoutes = []
|
||||||
} else {
|
} else {
|
||||||
accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)
|
const menuList = []
|
||||||
|
getListItems(menus, node => menuList.push(node))
|
||||||
|
console.log(menuList)
|
||||||
|
console.log(dynamicRoutes)
|
||||||
|
accessedRoutes = filterAsyncRoutes(dynamicRoutes, menuList)
|
||||||
|
console.log(accessedRoutes)
|
||||||
}
|
}
|
||||||
commit('SET_ROUTES', accessedRoutes)
|
commit('SET_ROUTES', accessedRoutes)
|
||||||
resolve(accessedRoutes)
|
resolve(accessedRoutes)
|
||||||
|
@ -9,6 +9,7 @@ const state = {
|
|||||||
avatar: '',
|
avatar: '',
|
||||||
introduction: '',
|
introduction: '',
|
||||||
roles: [],
|
roles: [],
|
||||||
|
menus: [],
|
||||||
username: Cookies.get('username') || ''
|
username: Cookies.get('username') || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +26,9 @@ const mutations = {
|
|||||||
SET_AVATAR: (state, avatar) => {
|
SET_AVATAR: (state, avatar) => {
|
||||||
state.avatar = avatar
|
state.avatar = avatar
|
||||||
},
|
},
|
||||||
|
SET_MENUS: (state, menus) => {
|
||||||
|
state.menus = menus
|
||||||
|
},
|
||||||
SET_ROLES: (state, roles) => {
|
SET_ROLES: (state, roles) => {
|
||||||
state.roles = roles
|
state.roles = roles
|
||||||
},
|
},
|
||||||
@ -66,16 +70,17 @@ const actions = {
|
|||||||
reject('Verification failed, please Login again.')
|
reject('Verification failed, please Login again.')
|
||||||
}
|
}
|
||||||
|
|
||||||
const { roles, name, avatar, introduction } = data
|
const { roles, name, avatar, introduction, menus } = data
|
||||||
|
|
||||||
// roles must be a non-empty array
|
// roles must be a non-empty array
|
||||||
if (!roles || roles.length <= 0) {
|
if (!menus || menus.length <= 0) {
|
||||||
reject('getInfo: roles must be a non-null array!')
|
reject('getInfo: menus must be a non-null array!')
|
||||||
}
|
}
|
||||||
|
|
||||||
commit('SET_ROLES', roles)
|
commit('SET_ROLES', roles || [])
|
||||||
commit('SET_NAME', name)
|
commit('SET_NAME', name)
|
||||||
commit('SET_AVATAR', avatar)
|
commit('SET_AVATAR', avatar)
|
||||||
|
commit('SET_MENUS', menus)
|
||||||
commit('SET_INTRODUCTION', introduction)
|
commit('SET_INTRODUCTION', introduction)
|
||||||
resolve(data)
|
resolve(data)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@ -92,6 +97,7 @@ const actions = {
|
|||||||
dispatch('tagsView/delAllViews', null, { root: true })
|
dispatch('tagsView/delAllViews', null, { root: true })
|
||||||
commit('SET_TOKEN', '')
|
commit('SET_TOKEN', '')
|
||||||
commit('SET_ROLES', [])
|
commit('SET_ROLES', [])
|
||||||
|
commit('SET_MENUS', [])
|
||||||
commit('SET_USERNAME')
|
commit('SET_USERNAME')
|
||||||
Cookies.set('username', '')
|
Cookies.set('username', '')
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user