From 1166e0d98f21642454a3adc66adbd1f64dec31e9 Mon Sep 17 00:00:00 2001
From: liyang <1711467488@qq.com>
Date: Thu, 13 Sep 2018 23:14:40 +0800
Subject: [PATCH 01/10] account user
Former-commit-id: 18e8f9b184a466dd3afdcca8b77ccd9922d408a4 [formerly 18e8f9b184a466dd3afdcca8b77ccd9922d408a4 [formerly 18e8f9b184a466dd3afdcca8b77ccd9922d408a4 [formerly 18e8f9b184a466dd3afdcca8b77ccd9922d408a4 [formerly 26eec1dacb860262e4e7a81946d6d44739441da3 [formerly 8b6ff706f6abb1771924571087264230424f32d2]]]]]
Former-commit-id: a9006cb1d0b08630344ae3148efc45bda1fae8f3
Former-commit-id: 209b2c0fe35119ed4319dac1a1b9c553e15c4522
Former-commit-id: 493b0705c65043774efc00cdcfbf3ad97ed54a52 [formerly acb407878497fbc86b0bbfa7470d43455a7944f2]
Former-commit-id: 39e40e3c3e4313c35eac57b87caea57fbf0c245d
Former-commit-id: 8873735485e0c6836cf2d8e1717f9e94a5de814e
Former-commit-id: 78d64eb4d6132adec46158bccf3c7d06576bce6d
Former-commit-id: 39429a1692c5c34c87bdff344622a752c06619f4
Former-commit-id: 6726ad62ee8fdb8e952920f8f5ffad86a7d4fa04
---
package-lock.json.REMOVED.git-id | 2 +-
src/main.js | 2 +-
src/store/modules/d2admin/modules/account.js | 46 ++++++++++----------
src/store/modules/d2admin/modules/user.js | 42 ++++++++++--------
4 files changed, 49 insertions(+), 43 deletions(-)
diff --git a/package-lock.json.REMOVED.git-id b/package-lock.json.REMOVED.git-id
index 298e7b3f..f90e2089 100644
--- a/package-lock.json.REMOVED.git-id
+++ b/package-lock.json.REMOVED.git-id
@@ -1 +1 @@
-4d463a54f93007210c2e07a05d8f012c386a0023
\ No newline at end of file
+b322c0027c15926f73f03ec142269e3512c5cc14
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index 2ac579e2..f9c5628b 100644
--- a/src/main.js
+++ b/src/main.js
@@ -62,7 +62,7 @@ new Vue({
// 检查最新版本
this.$store.dispatch('d2admin/releases/checkUpdate')
// 用户登录后从数据库加载一系列的设置
- this.$store.commit('d2admin/account/load')
+ this.$store.dispatch('d2admin/account/load')
// 获取并记录用户 UA
this.$store.commit('d2admin/ua/get')
// 初始化全屏监听
diff --git a/src/store/modules/d2admin/modules/account.js b/src/store/modules/d2admin/modules/account.js
index 78569bd9..133cba32 100644
--- a/src/store/modules/d2admin/modules/account.js
+++ b/src/store/modules/d2admin/modules/account.js
@@ -12,9 +12,7 @@ export default {
* @param {Object} param password {String} 密码
* @param {Object} param route {Object} 登录成功后定向的路由对象
*/
- login ({
- commit
- }, {
+ login ({ dispatch }, {
vm,
username,
password,
@@ -27,7 +25,7 @@ export default {
username,
password
})
- .then(res => {
+ .then(async res => {
// 设置 cookie 一定要存 uuid 和 token 两个 cookie
// 整个系统依赖这两个数据进行校验和存储
// uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
@@ -36,11 +34,11 @@ export default {
util.cookies.set('uuid', res.uuid)
util.cookies.set('token', res.token)
// 设置 vuex 用户信息
- commit('d2admin/user/set', {
+ await dispatch('d2admin/user/set', {
name: res.name
}, { root: true })
// 用户登录后从持久化数据加载一系列的设置
- commit('load')
+ await dispatch('load')
// 更新路由 尝试去获取 cookie 里保存的需要重定向的页面完整地址
const path = util.cookies.get('redirect')
// 根据是否存有重定向页面判断如何重定向
@@ -49,9 +47,7 @@ export default {
util.cookies.remove('redirect')
})
.catch(err => {
- console.group('登录结果')
console.log('err: ', err)
- console.groupEnd()
})
},
/**
@@ -92,26 +88,28 @@ export default {
} else {
logout()
}
- }
- },
- mutations: {
+ },
/**
* @description 用户登录后从持久化数据加载一系列的设置
* @param {Object} state vuex state
*/
- load (state) {
- // DB -> store 加载用户名
- this.commit('d2admin/user/load')
- // DB -> store 加载主题
- this.commit('d2admin/theme/load')
- // DB -> store 加载页面过渡效果设置
- this.commit('d2admin/transition/load')
- // DB -> store 持久化数据加载上次退出时的多页列表
- this.commit('d2admin/page/openedLoad')
- // DB -> store 持久化数据加载侧边栏折叠状态
- this.commit('d2admin/menu/asideCollapseLoad')
- // DB -> store 持久化数据加载全局尺寸
- this.commit('d2admin/size/load')
+ load ({ commit, dispatch }) {
+ return new Promise(async resolve => {
+ // DB -> store 加载用户名
+ await dispatch('d2admin/user/load', null, { root: true })
+ // DB -> store 加载主题
+ commit('d2admin/theme/load', null, { root: true })
+ // DB -> store 加载页面过渡效果设置
+ commit('d2admin/transition/load', null, { root: true })
+ // DB -> store 持久化数据加载上次退出时的多页列表
+ commit('d2admin/page/openedLoad', null, { root: true })
+ // DB -> store 持久化数据加载侧边栏折叠状态
+ commit('d2admin/menu/asideCollapseLoad', null, { root: true })
+ // DB -> store 持久化数据加载全局尺寸
+ commit('d2admin/size/load', null, { root: true })
+ // end
+ resolve()
+ })
}
}
}
diff --git a/src/store/modules/d2admin/modules/user.js b/src/store/modules/d2admin/modules/user.js
index add8a466..ff19e64b 100644
--- a/src/store/modules/d2admin/modules/user.js
+++ b/src/store/modules/d2admin/modules/user.js
@@ -7,34 +7,42 @@ export default {
// 用户信息
info: setting.user.info
},
- mutations: {
+ actions: {
/**
* @description 设置用户数据
* @param {Object} state vuex state
* @param {*} info info
*/
- set (state, info) {
- // store 赋值
- state.info = info
- // 持久化
- this.dispatch('d2admin/db/set', {
- dbName: 'sys',
- path: 'user.info',
- value: info,
- user: true
+ set ({ state, dispatch }, info) {
+ return new Promise(async resolve => {
+ // store 赋值
+ state.info = info
+ // 持久化
+ await dispatch('d2admin/db/set', {
+ dbName: 'sys',
+ path: 'user.info',
+ value: info,
+ user: true
+ }, { root: true })
+ // end
+ resolve()
})
},
/**
* @description 从数据库取用户数据
* @param {Object} state vuex state
*/
- async load (state) {
- // store 赋值
- state.info = await this.dispatch('d2admin/db/get', {
- dbName: 'sys',
- path: 'user.info',
- defaultValue: setting.user.info,
- user: true
+ load ({ state, dispatch }) {
+ return new Promise(async resolve => {
+ // store 赋值
+ state.info = await dispatch('d2admin/db/get', {
+ dbName: 'sys',
+ path: 'user.info',
+ defaultValue: setting.user.info,
+ user: true
+ }, { root: true })
+ // end
+ resolve()
})
}
}
From a057d7ddd4a636ee680fb47301457f1e5e4193f0 Mon Sep 17 00:00:00 2001
From: liyang <1711467488@qq.com>
Date: Fri, 14 Sep 2018 08:49:43 +0800
Subject: [PATCH 02/10] theme
Former-commit-id: 3fb5e37f648c98c9636ba8ac88f683e52cf8435e [formerly 3fb5e37f648c98c9636ba8ac88f683e52cf8435e [formerly 3fb5e37f648c98c9636ba8ac88f683e52cf8435e [formerly 3fb5e37f648c98c9636ba8ac88f683e52cf8435e [formerly 6f73a709ba4288f514deb2d74eb8603180b60b08 [formerly 28415f3ce8f01f9f26a0752a5f08d855bc4c56e2]]]]]
Former-commit-id: f199fcac91cb1b3aeef843974db74d0f9d622699
Former-commit-id: eec00c4f5e48c1a19ac096d3a8900bbb7ae361db
Former-commit-id: 9c7eb4c2f9115fda9b7d69e1c53444c99aeadb90 [formerly aac10159598f69b5c31ab136beb5ae11686ed2d6]
Former-commit-id: d38da464fd9a05e1ec2defc27ac4d8d4bed05ec3
Former-commit-id: eadfd85257cb054017000aca8100e5e68b359e2d
Former-commit-id: 9ce4b0a7b75a4ea9b9e24e96161a515bcadc6f04
Former-commit-id: ed40880ed8dda9601d859d5db5f19ab7bd42ade7
Former-commit-id: 3cbf4301dd98c44d8c4f1da0432922511ba9c7e3
---
.../components/d2-theme-list/index.vue | 4 +-
.../demo/playground/store/theme/index.vue | 4 +-
src/store/modules/d2admin/modules/account.js | 2 +-
src/store/modules/d2admin/modules/theme.js | 54 +++++++++++--------
4 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/src/layout/header-aside/components/header-theme/components/d2-theme-list/index.vue b/src/layout/header-aside/components/header-theme/components/d2-theme-list/index.vue
index efe3e343..e3d3e503 100644
--- a/src/layout/header-aside/components/header-theme/components/d2-theme-list/index.vue
+++ b/src/layout/header-aside/components/header-theme/components/d2-theme-list/index.vue
@@ -18,7 +18,7 @@
diff --git a/src/store/modules/d2admin/modules/account.js b/src/store/modules/d2admin/modules/account.js
index e8d16b9c..493130a9 100644
--- a/src/store/modules/d2admin/modules/account.js
+++ b/src/store/modules/d2admin/modules/account.js
@@ -106,7 +106,7 @@ export default {
// DB -> store 持久化数据加载侧边栏折叠状态
await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true })
// DB -> store 持久化数据加载全局尺寸
- commit('d2admin/size/load', null, { root: true })
+ await dispatch('d2admin/size/load', null, { root: true })
// end
resolve()
})
diff --git a/src/store/modules/d2admin/modules/size.js b/src/store/modules/d2admin/modules/size.js
index b500e033..a7d3416b 100644
--- a/src/store/modules/d2admin/modules/size.js
+++ b/src/store/modules/d2admin/modules/size.js
@@ -4,34 +4,42 @@ export default {
// 尺寸
value: '' // medium small mini
},
- mutations: {
+ actions: {
/**
* @description 设置尺寸
* @param {Object} state vuex state
* @param {String} size 尺寸
*/
- set (state, size) {
- // store 赋值
- state.value = size
- // 持久化
- this.dispatch('d2admin/db/set', {
- dbName: 'sys',
- path: 'size.value',
- value: state.value,
- user: true
+ set ({ state, dispatch }, size) {
+ return new Promise(async resolve => {
+ // store 赋值
+ state.value = size
+ // 持久化
+ await dispatch('d2admin/db/set', {
+ dbName: 'sys',
+ path: 'size.value',
+ value: state.value,
+ user: true
+ }, { root: true })
+ // end
+ resolve()
})
},
/**
* @description 从持久化数据读取尺寸设置
* @param {Object} state vuex state
*/
- async load (state) {
- // store 赋值
- state.value = await this.dispatch('d2admin/db/get', {
- dbName: 'sys',
- path: 'size.value',
- defaultValue: 'default',
- user: true
+ load ({ state, dispatch }) {
+ return new Promise(async resolve => {
+ // store 赋值
+ state.value = await dispatch('d2admin/db/get', {
+ dbName: 'sys',
+ path: 'size.value',
+ defaultValue: 'default',
+ user: true
+ }, { root: true })
+ // end
+ resolve()
})
}
}
From a7af1acbf4d4dc6a82ca57e8edf58235f7854d07 Mon Sep 17 00:00:00 2001
From: liyang <1711467488@qq.com>
Date: Fri, 14 Sep 2018 15:09:58 +0800
Subject: [PATCH 06/10] no message
Former-commit-id: a98f0dc7f8c8202102557ec44a29081de09ef657 [formerly a98f0dc7f8c8202102557ec44a29081de09ef657 [formerly a98f0dc7f8c8202102557ec44a29081de09ef657 [formerly a98f0dc7f8c8202102557ec44a29081de09ef657 [formerly f244e1fdd164c1b79a79bb5a6b747ee86b9d8589 [formerly 9a88fe535b9d40bff1dcca1e9c312ab81c0961b5]]]]]
Former-commit-id: 80f45f42407a12231dcb32861eae95da8b8f27d5
Former-commit-id: 294d0beb7890b73dd462900f6634b9ed43dda50b
Former-commit-id: f639bbc1de8e27b18262e84545ff22b8556c402a [formerly 0f01b98c3d1b41eaa511bb56813d860105da930f]
Former-commit-id: 9a33c6b83d309a76711c4fad397c149dac55a8b5
Former-commit-id: f556363312d2e505acc24ec531e787fc3863f9fc
Former-commit-id: 4433f382bc7c25d437eabfab96e4a7b0dbca28b5
Former-commit-id: eb558eb22372f558e8d93ae8dac07c40016e2644
Former-commit-id: 963b8effbe52965ae14a77172a37c50dcfd6cf56
---
.../components/header-size/index.vue | 16 +++++++---------
.../header-aside/components/tabs/index.vue | 6 ++----
src/router/index.js | 2 +-
src/store/modules/d2admin/modules/account.js | 2 +-
.../d2admin/modules/page.js.REMOVED.git-id | 2 +-
5 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/src/layout/header-aside/components/header-size/index.vue b/src/layout/header-aside/components/header-size/index.vue
index 2ed28cc7..a8a6f234 100644
--- a/src/layout/header-aside/components/header-size/index.vue
+++ b/src/layout/header-aside/components/header-size/index.vue
@@ -21,7 +21,7 @@