Skip to content

Commit

Permalink
account 模块去除 vm 属性
Browse files Browse the repository at this point in the history
  • Loading branch information
FairyEver committed Feb 5, 2019
1 parent 949ff5b commit be1483f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/layout/header-aside/components/header-user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export default {
*/
logOff () {
this.logout({
vm: this,
confirm: true
})
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/login/page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ export default {
// 注意 这里的演示没有传验证码
// 具体需要传递的数据请自行修改代码
this.login({
vm: this,
username: this.formLogin.username,
password: this.formLogin.password
})
Expand Down
17 changes: 9 additions & 8 deletions src/store/modules/d2admin/modules/account.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Message, MessageBox } from 'element-ui'
import util from '@/libs/util.js'
import router from '@/router'
import { AccountLogin } from '@api/sys.login'

export default {
Expand All @@ -7,13 +9,11 @@ export default {
/**
* @description 登录
* @param {Object} param context
* @param {Object} param vm {Object} vue 实例
* @param {Object} param username {String} 用户账号
* @param {Object} param password {String} 密码
* @param {Object} param route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式
*/
login ({ dispatch }, {
vm,
username,
password
}) {
Expand Down Expand Up @@ -49,10 +49,9 @@ export default {
/**
* @description 注销用户并返回登录页面
* @param {Object} param context
* @param {Object} param vm {Object} vue 实例
* @param {Object} param confirm {Boolean} 是否需要确认
*/
logout ({ commit, dispatch }, { vm, confirm = false }) {
logout ({ commit, dispatch }, { confirm = false } = {}) {
/**
* @description 注销
*/
Expand All @@ -63,14 +62,14 @@ export default {
// 清空 vuex 用户信息
await dispatch('d2admin/user/set', {}, { root: true })
// 跳转路由
vm.$router.push({
router.push({
name: 'login'
})
}
// 判断是否需要确认
if (confirm) {
commit('d2admin/gray/set', true, { root: true })
vm.$confirm('注销当前账户吗? 打开的标签页和用户设置将会被保存。', '确认操作', {
MessageBox.confirm('注销当前账户吗? 打开的标签页和用户设置将会被保存。', '确认操作', {
confirmButtonText: '确定注销',
cancelButtonText: '放弃',
type: 'warning'
Expand All @@ -81,7 +80,9 @@ export default {
})
.catch(() => {
commit('d2admin/gray/set', false, { root: true })
vm.$message('放弃注销用户')
Message({
message: '放弃注销用户'
})
})
} else {
logout()
Expand All @@ -91,7 +92,7 @@ export default {
* @description 用户登录后从持久化数据加载一系列的设置
* @param {Object} state vuex state
*/
load ({ commit, dispatch }) {
load ({ dispatch }) {
return new Promise(async resolve => {
// DB -> store 加载用户名
await dispatch('d2admin/user/load', null, { root: true })
Expand Down

0 comments on commit be1483f

Please sign in to comment.