Commit c891a12f authored by wangxl's avatar wangxl

3333

parent bb21ff48
...@@ -27,8 +27,6 @@ export default { ...@@ -27,8 +27,6 @@ export default {
}, },
data () { data () {
return { return {
current: 0,
routerList: [],
collapsed: false, collapsed: false,
menuList: [], menuList: [],
openKeys: [], openKeys: [],
...@@ -83,7 +81,6 @@ export default { ...@@ -83,7 +81,6 @@ export default {
if (value) { if (value) {
this.menuList = JSON.parse(window.sessionStorage.getItem('menuList')) this.menuList = JSON.parse(window.sessionStorage.getItem('menuList'))
this.openKeys = [this.menuList[0].id] this.openKeys = [this.menuList[0].id]
this.$store.commit('app/setOpenKeys', this.menuList[0].id)
} }
} }
} }
......
...@@ -317,12 +317,16 @@ export function changeSystemType (type) { ...@@ -317,12 +317,16 @@ export function changeSystemType (type) {
try { try {
this.$store.commit('app/clearStore') this.$store.commit('app/clearStore')
setType(type + '') setType(type + '')
this.$store.commit('app/setsystemType', type) await store.dispatch('user/getMenuList')
let menuList = JSON.parse(window.sessionStorage.getItem('menuList')) this.$store.commit('app/setSystemType', type)
this.$store.commit('app/initStore', [menuList[0].id])
this.$router.push('/') this.$router.push('/')
resolve(true) resolve(true)
} catch (e) { } catch (e) {
this.$api.base.logout().then(({ data }) => { }).catch(() => { })
removeToken()
window.sessionStorage.clear();
this.$store.commit('app/clearStore')
this.$router.push(`/login`)
reject(false) reject(false)
} }
}) })
...@@ -341,8 +345,7 @@ router.beforeEach(async (to, from, next) => { ...@@ -341,8 +345,7 @@ router.beforeEach(async (to, from, next) => {
NProgress.done() NProgress.done()
} else { } else {
const hasUser = JSON.parse(window.sessionStorage.getItem('user')) const hasUser = JSON.parse(window.sessionStorage.getItem('user'))
const hasMenu = JSON.parse(window.sessionStorage.getItem('menuList')) if (hasUser) {
if (hasUser && hasMenu) {
if (hasUser.type === '3' && !!!hasUser.systemType && hasUser.roles != '4') { if (hasUser.type === '3' && !!!hasUser.systemType && hasUser.roles != '4') {
if (to.path === '/sys') { if (to.path === '/sys') {
next() next()
......
...@@ -18,7 +18,7 @@ const mutations = { ...@@ -18,7 +18,7 @@ const mutations = {
setTabsArray: (state, payload) => { setTabsArray: (state, payload) => {
state.tabsArray = payload state.tabsArray = payload
}, },
setsystemType: (state, payload) => { setSystemType: (state, payload) => {
state.systemType = payload state.systemType = payload
}, },
addTabs: (state, payload) => { addTabs: (state, payload) => {
...@@ -142,7 +142,7 @@ const mutations = { ...@@ -142,7 +142,7 @@ const mutations = {
this.commit('app/setTabsArray', []) this.commit('app/setTabsArray', [])
this.commit('app/setTabsActive', '') this.commit('app/setTabsActive', '')
this.commit('app/setCachedViews', []) this.commit('app/setCachedViews', [])
this.commit('app/setsystemType', null) this.commit('app/setSystemType', null)
}, },
} }
......
...@@ -19,8 +19,6 @@ const actions = { ...@@ -19,8 +19,6 @@ const actions = {
if (data) { if (data) {
try { try {
window.sessionStorage.setItem('user', JSON.stringify(data.userInfo)) window.sessionStorage.setItem('user', JSON.stringify(data.userInfo))
window.sessionStorage.setItem('menuList', JSON.stringify(data.menuList))
this.commit('app/initStore', [data.menuList[0].id])
resolve(data) resolve(data)
} catch (error) { } catch (error) {
reject(error) reject(error)
...@@ -35,7 +33,7 @@ const actions = { ...@@ -35,7 +33,7 @@ const actions = {
}, },
getMenuList ({ dispatch }) { getMenuList ({ dispatch }) {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
await api.base.getMenuList().then(({ data = {} }) => { await api.base.getMenuList({ systemType: getType() }).then(({ data = {} }) => {
if (data) { if (data) {
try { try {
window.sessionStorage.setItem('menuList', JSON.stringify(data)) window.sessionStorage.setItem('menuList', JSON.stringify(data))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment