|
|
|
|
|
|
|
|
// get user info |
|
|
// get user info |
|
|
getInfo({ commit, state }) { |
|
|
getInfo({ commit, state }) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
api.getInfo({token:Cookies.get('token')}).then(res => { |
|
|
|
|
|
|
|
|
api.getInfo({token:Cookies.get(location.host+'-token')}).then(res => { |
|
|
commit('SET_INFO', res.data.info?res.data.info:{}) |
|
|
commit('SET_INFO', res.data.info?res.data.info:{}) |
|
|
commit('SET_PERMISSION', res.data.permission?res.data.permission:[]) |
|
|
commit('SET_PERMISSION', res.data.permission?res.data.permission:[]) |
|
|
if(res.data.permission.length>0){ |
|
|
if(res.data.permission.length>0){ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
resolve(res.data.info) |
|
|
resolve(res.data.info) |
|
|
}).catch(e => { |
|
|
}).catch(e => { |
|
|
Cookies.set('token','') |
|
|
|
|
|
|
|
|
Cookies.set(location.host+'-token','') |
|
|
commit('SET_INFO', null) |
|
|
commit('SET_INFO', null) |
|
|
commit('SET_MENU', []) |
|
|
commit('SET_MENU', []) |
|
|
commit('SET_ROLES', null) |
|
|
commit('SET_ROLES', null) |
|
|
|
|
|
|
|
|
// user logout |
|
|
// user logout |
|
|
logout({ commit, state }) { |
|
|
logout({ commit, state }) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
api.logout(Cookies.get('token')).then(res => { |
|
|
|
|
|
Cookies.set('token','') |
|
|
|
|
|
|
|
|
api.logout(Cookies.get(location.host+'-token')).then(res => { |
|
|
|
|
|
Cookies.set(location.host+'-token','') |
|
|
commit('SET_INFO', null) |
|
|
commit('SET_INFO', null) |
|
|
commit('SET_MENU', []) |
|
|
commit('SET_MENU', []) |
|
|
commit('SET_ROLES', null) |
|
|
commit('SET_ROLES', null) |
|
|
|
|
|
|
|
|
// remove token |
|
|
// remove token |
|
|
resetToken({ commit }) { |
|
|
resetToken({ commit }) { |
|
|
return new Promise(resolve => { |
|
|
return new Promise(resolve => { |
|
|
Cookies.set('token','') |
|
|
|
|
|
|
|
|
Cookies.set(location.host+'-token','') |
|
|
commit('SET_INFO', null) |
|
|
commit('SET_INFO', null) |
|
|
commit('SET_MENU', []) |
|
|
commit('SET_MENU', []) |
|
|
commit('SET_ROLES', null) |
|
|
commit('SET_ROLES', null) |