diff --git a/src/layout/components/MyHead/index.vue b/src/layout/components/MyHead/index.vue index dbc4c13..6714838 100644 --- a/src/layout/components/MyHead/index.vue +++ b/src/layout/components/MyHead/index.vue @@ -34,6 +34,21 @@ export default { computed: { ...mapGetters(["avatar", "name"]), }, + methods: { + async logout() { + this.$confirm("确定注销并退出系统吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }) + .then(() => { + this.$store.dispatch("LogOut").then(() => { + location.href = "/index"; + }); + }) + .catch(() => {}); + }, + }, }; diff --git a/src/store/modules/user.js b/src/store/modules/user.js index ab0a6fe..eda05fc 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,96 +1,106 @@ -import { login, logout, getInfo } from '@/api/login' -import { getToken, setToken, removeToken } from '@/utils/auth' +import { login, logout, getInfo } from "@/api/login"; +import { getToken, setToken, removeToken } from "@/utils/auth"; const user = { state: { token: getToken(), - name: '', - avatar: '', + name: "", + avatar: "", roles: [], - permissions: [] + permissions: [], }, mutations: { SET_TOKEN: (state, token) => { - state.token = token + state.token = token; }, SET_NAME: (state, name) => { - state.name = name + state.name = name; }, SET_AVATAR: (state, avatar) => { - state.avatar = avatar + state.avatar = avatar; }, SET_ROLES: (state, roles) => { - state.roles = roles + state.roles = roles; }, SET_PERMISSIONS: (state, permissions) => { - state.permissions = permissions - } + state.permissions = permissions; + }, }, actions: { // 登录 Login({ commit }, userInfo) { - const username = userInfo.username.trim() - const password = userInfo.password - const code = userInfo.code - const uuid = userInfo.uuid + const username = userInfo.username.trim(); + const password = userInfo.password; + const code = userInfo.code; + const uuid = userInfo.uuid; return new Promise((resolve, reject) => { - login(username, password, code, uuid).then(res => { - setToken(res.token) - commit('SET_TOKEN', res.token) - resolve() - }).catch(error => { - reject(error) - }) - }) + login(username, password, code, uuid) + .then((res) => { + setToken(res.token); + commit("SET_TOKEN", res.token); + resolve(); + }) + .catch((error) => { + reject(error); + }); + }); }, // 获取用户信息 GetInfo({ commit, state }) { return new Promise((resolve, reject) => { - getInfo().then(res => { - const user = res.user - const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar; - if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组 - commit('SET_ROLES', res.roles) - commit('SET_PERMISSIONS', res.permissions) - } else { - commit('SET_ROLES', ['ROLE_DEFAULT']) - } - commit('SET_NAME', user.userName) - commit('SET_AVATAR', avatar) - resolve(res) - }).catch(error => { - reject(error) - }) - }) + getInfo() + .then((res) => { + const user = res.user; + const avatar = + user.avatar == "" || user.avatar == null + ? require("@/assets/images/profile.jpg") + : process.env.VUE_APP_BASE_API + user.avatar; + if (res.roles && res.roles.length > 0) { + // 验证返回的roles是否是一个非空数组 + commit("SET_ROLES", res.roles); + commit("SET_PERMISSIONS", res.permissions); + } else { + commit("SET_ROLES", ["ROLE_DEFAULT"]); + } + commit("SET_NAME", user.nickName); + commit("SET_AVATAR", avatar); + resolve(res); + }) + .catch((error) => { + reject(error); + }); + }); }, // 退出系统 LogOut({ commit, state }) { return new Promise((resolve, reject) => { - logout(state.token).then(() => { - commit('SET_TOKEN', '') - commit('SET_ROLES', []) - commit('SET_PERMISSIONS', []) - removeToken() - resolve() - }).catch(error => { - reject(error) - }) - }) + logout(state.token) + .then(() => { + commit("SET_TOKEN", ""); + commit("SET_ROLES", []); + commit("SET_PERMISSIONS", []); + removeToken(); + resolve(); + }) + .catch((error) => { + reject(error); + }); + }); }, // 前端 登出 FedLogOut({ commit }) { - return new Promise(resolve => { - commit('SET_TOKEN', '') - removeToken() - resolve() - }) - } - } -} + return new Promise((resolve) => { + commit("SET_TOKEN", ""); + removeToken(); + resolve(); + }); + }, + }, +}; -export default user +export default user; diff --git a/src/views/volunteer/addressGl/index.vue b/src/views/volunteer/addressGl/index.vue new file mode 100644 index 0000000..e744312 --- /dev/null +++ b/src/views/volunteer/addressGl/index.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/src/views/volunteer/gxhzs/gxhzsdh/index.vue b/src/views/volunteer/gxhzs/gxhzsdh/index.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/views/volunteer/gxhzs/mygxhzs/index.vue b/src/views/volunteer/gxhzs/mygxhzs/index.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/views/volunteer/hdtj/hdGl/index.vue b/src/views/volunteer/hdtj/hdGl/index.vue new file mode 100644 index 0000000..e1ef63c --- /dev/null +++ b/src/views/volunteer/hdtj/hdGl/index.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/src/views/volunteer/hdtj/hdtjChild/index.vue b/src/views/volunteer/hdtj/hdtjChild/index.vue new file mode 100644 index 0000000..cd1a4c3 --- /dev/null +++ b/src/views/volunteer/hdtj/hdtjChild/index.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/src/views/volunteer/hdtj/hdyq/index.vue b/src/views/volunteer/hdtj/hdyq/index.vue new file mode 100644 index 0000000..6d5ce84 --- /dev/null +++ b/src/views/volunteer/hdtj/hdyq/index.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/src/views/volunteer/userbq/bqhsj/index.vue b/src/views/volunteer/userbq/bqhsj/index.vue new file mode 100644 index 0000000..83208b9 --- /dev/null +++ b/src/views/volunteer/userbq/bqhsj/index.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/src/views/volunteer/userbq/dictGl/index.vue b/src/views/volunteer/userbq/dictGl/index.vue new file mode 100644 index 0000000..2518173 --- /dev/null +++ b/src/views/volunteer/userbq/dictGl/index.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/src/views/volunteer/yzczs/myycxhd/index.vue b/src/views/volunteer/yzczs/myycxhd/index.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/views/volunteer/yzczs/myycxzs/index.vue b/src/views/volunteer/yzczs/myycxzs/index.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/views/volunteer/yzczs/ycxzsff/index.vue b/src/views/volunteer/yzczs/ycxzsff/index.vue new file mode 100644 index 0000000..e69de29