25da4210 by 任超

架构

1 parent d88e515f
...@@ -6,15 +6,8 @@ const getters = { ...@@ -6,15 +6,8 @@ const getters = {
6 token: state => state.user.token, 6 token: state => state.user.token,
7 avatar: state => state.user.avatar, 7 avatar: state => state.user.avatar,
8 name: state => state.user.name, 8 name: state => state.user.name,
9 introduction: state => state.user.introduction,
10 permission_routes: state => state.permission.routes, 9 permission_routes: state => state.permission.routes,
11 addRoutes: state => state.permission.addRoutes, 10 addRoutes: state => state.permission.addRoutes,
12 errorLogs: state => state.errorLog.logs, 11 errorLogs: state => state.errorLog.logs
13 fdglSaveInfo: state => state.organizationmanage.fdgl,
14 cardTypeOption: state => state.dictionaries.cardTypeOption,
15 xingzuoTypeOption: state => state.dictionaries.xingzuoTypeOption,
16 sysInfo: state => state.dictionariesAll.sysInfo,
17 centralizationData: state => state.housemap.centralizationData,
18 distributedData: state => state.housemap.distributedData,
19 } 12 }
20 export default getters 13 export default getters
......
...@@ -5,13 +5,9 @@ import Cookies from 'js-cookie'; ...@@ -5,13 +5,9 @@ import Cookies from 'js-cookie';
5 const state = { 5 const state = {
6 name: Cookies.get('username'), 6 name: Cookies.get('username'),
7 avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', 7 avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
8 introduction: '',
9 userInfo: null 8 userInfo: null
10 } 9 }
11 const mutations = { 10 const mutations = {
12 SET_INTRODUCTION: (state, introduction) => {
13 state.introduction = introduction
14 },
15 SET_NAME: (state, name) => { 11 SET_NAME: (state, name) => {
16 state.name = name 12 state.name = name
17 }, 13 },
...@@ -24,51 +20,6 @@ const mutations = { ...@@ -24,51 +20,6 @@ const mutations = {
24 } 20 }
25 21
26 const actions = { 22 const actions = {
27 // user login
28 login ({ commit }, userInfo) {
29 const { username, password, code, num, location } = userInfo
30 return new Promise((resolve, reject) => {
31 login({ username: username.trim(), password: password, code: code, location: location }).then(response => {
32 const { result, code, msg } = response
33 if (code === 200) {
34 Cookies.set('token', result.token)
35 commit('SET_USERINFO', result.userInfo)
36 Cookies.set("userInfo", result.userInfo.id, { expires: 720 })
37 Cookies.set("username", result.userInfo.username, { expires: 720 })
38 commit('SET_NAME', result.userInfo.username)
39 } else {
40 Message.error(msg);
41 }
42 resolve(response)
43 }).catch(error => {
44 reject(error)
45 })
46 })
47 },
48 // user logout
49 logout ({ commit, state, dispatch }) {
50 return new Promise((resolve, reject) => {
51 // logout(state.token).then(() => {
52 commit('SET_USERINFO', null)
53 Cookies.remove("userInfo")
54 Cookies.remove("routerTo")
55 Cookies.remove('token')
56 resetRouter()
57 store.dispatch('permission/resetRoutes')
58 // reset visited views and cached views
59 // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485
60 dispatch('tagsView/delAllViews', null, { root: true })
61 resolve()
62 })
63 },
64 // remove token
65 resetToken ({ commit }) {
66 return new Promise(resolve => {
67 commit('SET_USERINFO', null)
68 Cookies.remove("userInfo")
69 resolve()
70 })
71 },
72 } 23 }
73 export default { 24 export default {
74 namespaced: true, 25 namespaced: true,
......