From 36a09f9c3d1547a40ba18d7556a9acfedc40c922 Mon Sep 17 00:00:00 2001
From: liyang <1711467488@qq.com>
Date: Sat, 17 Nov 2018 22:31:41 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E7=99=BB=E9=99=86=E8=B7=B3=E8=BD=AC?=
=?UTF-8?q?=E8=BD=AC=E4=BA=A4=E7=99=BB=E9=99=86=E9=A1=B5=E9=9D=A2=E5=A4=84?=
=?UTF-8?q?=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Former-commit-id: cfd1438def08f0c214df214e42e8fa54433b29ed [formerly cfd1438def08f0c214df214e42e8fa54433b29ed [formerly cfd1438def08f0c214df214e42e8fa54433b29ed [formerly cfd1438def08f0c214df214e42e8fa54433b29ed [formerly 850c00a248f8dace4cdb42cdda77dfbf528b8e15 [formerly e43dc23c06b5e7addc34b225e0d7512afa4cbf88]]]]]
Former-commit-id: b7a006b238aee7cfd6bbcd587fc1826aa53f9ecc
Former-commit-id: bba6b8fb7a93cb3363d4109490ea54a3a0066f4c
Former-commit-id: bbb7c9d3c44357c023c7194b1c85f529aa048fbc [formerly fa2a2a5a267fe5a96c5e82cc0c1650eb024da71b]
Former-commit-id: 383bf4b86f457cff9830e54bf43340e42a2045ab
Former-commit-id: 348c1d718cd6c5441c2b721fd6efd30a8f231838
Former-commit-id: 4c9476c29fb68d59150d2b0992dc20bbd2d588ad
Former-commit-id: 7bd01ddd895e182be3d7a24267c4721376225bd3
Former-commit-id: 70079fa65f5107867d7bb5b460f3d24563b61e9c
---
src/pages/login/page.vue | 10 ++++
src/router/index.js | 9 +--
src/store/modules/d2admin/modules/account.js | 60 +++++++++-----------
3 files changed, 43 insertions(+), 36 deletions(-)
diff --git a/src/pages/login/page.vue b/src/pages/login/page.vue
index ad2bdc7a1..ea7cc85ba 100644
--- a/src/pages/login/page.vue
+++ b/src/pages/login/page.vue
@@ -141,6 +141,16 @@ export default {
username: this.formLogin.username,
password: this.formLogin.password
})
+ .then(() => {
+ const redirect = this.$route.query.redirect
+ if (redirect) {
+ // 重定向到指定的页面
+ this.$router.replace(redirect)
+ } else {
+ // 重定向到开始路径
+ this.$router.replace('/')
+ }
+ })
} else {
// 登录表单校验失败
this.$message.error('表单校验失败')
diff --git a/src/router/index.js b/src/router/index.js
index 241e6215d..496b9504f 100755
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -36,12 +36,13 @@ router.beforeEach((to, from, next) => {
if (token && token !== 'undefined') {
next()
} else {
- // 将当前预计打开的页面完整地址临时存储 登录后继续跳转
- // 这个 cookie(redirect) 会在登录后自动删除
- util.cookies.set('redirect', to.fullPath)
// 没有登录的时候跳转到登录界面
+ // 携带上登陆成功之后需要跳转的页面完整路径
next({
- name: 'login'
+ name: 'login',
+ query: {
+ redirect: to.fullPath
+ }
})
}
} else {
diff --git a/src/store/modules/d2admin/modules/account.js b/src/store/modules/d2admin/modules/account.js
index b999e7a9d..40f20df85 100644
--- a/src/store/modules/d2admin/modules/account.js
+++ b/src/store/modules/d2admin/modules/account.js
@@ -15,40 +15,36 @@ export default {
login ({ dispatch }, {
vm,
username,
- password,
- route = {
- path: '/'
- }
+ password
}) {
- // 开始请求登录接口
- AccountLogin({
- username,
- password
- })
- .then(async res => {
- // 设置 cookie 一定要存 uuid 和 token 两个 cookie
- // 整个系统依赖这两个数据进行校验和存储
- // uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
- // token 代表用户当前登录状态 建议在网络请求中携带 token
- // 如有必要 token 需要定时更新,默认保存一天
- util.cookies.set('uuid', res.uuid)
- util.cookies.set('token', res.token)
- // 设置 vuex 用户信息
- await dispatch('d2admin/user/set', {
- name: res.name
- }, { root: true })
- // 用户登录后从持久化数据加载一系列的设置
- await dispatch('load')
- // 更新路由 尝试去获取 cookie 里保存的需要重定向的页面完整地址
- const path = util.cookies.get('redirect')
- // 根据是否存有重定向页面判断如何重定向
- vm.$router.replace(path ? { path } : route)
- // 删除 cookie 中保存的重定向页面
- util.cookies.remove('redirect')
- })
- .catch(err => {
- console.log('err: ', err)
+ return new Promise((resolve, reject) => {
+ // 开始请求登录接口
+ AccountLogin({
+ username,
+ password
})
+ .then(async res => {
+ // 设置 cookie 一定要存 uuid 和 token 两个 cookie
+ // 整个系统依赖这两个数据进行校验和存储
+ // uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
+ // token 代表用户当前登录状态 建议在网络请求中携带 token
+ // 如有必要 token 需要定时更新,默认保存一天
+ util.cookies.set('uuid', res.uuid)
+ util.cookies.set('token', res.token)
+ // 设置 vuex 用户信息
+ await dispatch('d2admin/user/set', {
+ name: res.name
+ }, { root: true })
+ // 用户登录后从持久化数据加载一系列的设置
+ await dispatch('load')
+ // 结束
+ resolve()
+ })
+ .catch(err => {
+ console.log('err: ', err)
+ reject(err)
+ })
+ })
},
/**
* @description 注销用户并返回登录页面
From 6eb8608a4df2d1eb60df78a12c044261f87e7240 Mon Sep 17 00:00:00 2001
From: liyang <1711467488@qq.com>
Date: Sat, 17 Nov 2018 22:32:05 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B9=8B=E5=89=8D=20file?=
=?UTF-8?q?name=20=E4=B9=A6=E5=86=99=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Former-commit-id: 38ee231d3c646cc572660bcb9f0a81ae71bc97e5 [formerly 38ee231d3c646cc572660bcb9f0a81ae71bc97e5 [formerly 38ee231d3c646cc572660bcb9f0a81ae71bc97e5 [formerly 38ee231d3c646cc572660bcb9f0a81ae71bc97e5 [formerly 4d9fcce66aaf3a4e6cbb6222c103189bf48826f5 [formerly 2de4e4812163b9dd5c67784ff789ae739472c406]]]]]
Former-commit-id: 17588b4cb0d407be7fdba96b35d632d914cee9f3
Former-commit-id: 11d685f1a2cab9e2a36f3f1ca3d523204da0060d
Former-commit-id: d4c2c2c58b014f26949a5a1728298a9bbc207a43 [formerly 5664bb367350fa0349c692af1e33d5804f569eee]
Former-commit-id: 7c0eb404bc10835ee07b4f4f00f48e909c1d9052
Former-commit-id: 641da3104e9c831445edcc8059810f8677c95c89
Former-commit-id: 4ead5d35ca00668bda815a657608890ed95c5048
Former-commit-id: bebb18b74721247ad556dec0e8e2048fd277c052
Former-commit-id: cf7bb999bd756891dcdc53dd27f139f493dcf7a7
---
src/pages/demo/playground/index/index.vue | 6 ++++--
src/pages/demo/playground/log/console/index.vue | 4 +++-
src/pages/demo/playground/log/error/index.vue | 4 +++-
src/pages/demo/playground/page-argu/get.vue | 4 +++-
src/pages/demo/playground/page-cache/params.vue | 4 +++-
src/pages/demo/playground/store/fullscreen/index.vue | 4 +++-
src/pages/demo/playground/store/transition/index.vue | 4 +++-
src/pages/demo/playground/store/ua/index.vue | 4 +++-
src/pages/demo/plugins/i18n/demo1.vue | 4 +++-
src/pages/demo/plugins/i18n/demo2.vue | 4 +++-
src/pages/demo/plugins/index/index.vue | 4 +++-
src/pages/demo/plugins/js-cookie/index.vue | 4 +++-
12 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/src/pages/demo/playground/index/index.vue b/src/pages/demo/playground/index/index.vue
index f487a6057..a61fd3050 100644
--- a/src/pages/demo/playground/index/index.vue
+++ b/src/pages/demo/playground/index/index.vue
@@ -11,7 +11,9 @@
diff --git a/src/pages/demo/playground/log/console/index.vue b/src/pages/demo/playground/log/console/index.vue
index 1ac646d0f..0a079dd7e 100644
--- a/src/pages/demo/playground/log/console/index.vue
+++ b/src/pages/demo/playground/log/console/index.vue
@@ -43,7 +43,9 @@
diff --git a/src/pages/demo/plugins/i18n/demo2.vue b/src/pages/demo/plugins/i18n/demo2.vue
index d7bbbe97d..c30a4f001 100644
--- a/src/pages/demo/plugins/i18n/demo2.vue
+++ b/src/pages/demo/plugins/i18n/demo2.vue
@@ -13,7 +13,9 @@ export default {
DemoI18n: () => import('./components/DemoI18n')
},
data () {
- filename: __filename
+ return {
+ filename: __filename
+ }
}
}
diff --git a/src/pages/demo/plugins/index/index.vue b/src/pages/demo/plugins/index/index.vue
index 9900c41e5..38a36e576 100644
--- a/src/pages/demo/plugins/index/index.vue
+++ b/src/pages/demo/plugins/index/index.vue
@@ -11,7 +11,9 @@
diff --git a/src/pages/demo/plugins/js-cookie/index.vue b/src/pages/demo/plugins/js-cookie/index.vue
index 7a7651d57..0d76f4b5b 100644
--- a/src/pages/demo/plugins/js-cookie/index.vue
+++ b/src/pages/demo/plugins/js-cookie/index.vue
@@ -26,7 +26,9 @@
import util from '@/libs/util.js'
export default {
data () {
- filename: __filename
+ return {
+ filename: __filename
+ }
},
methods: {
set (name = 'default-name', value = 'default-value') {
From 3477663d983da527d19e254e73517e899419f9f7 Mon Sep 17 00:00:00 2001
From: liyang <1711467488@qq.com>
Date: Sat, 17 Nov 2018 22:33:28 +0800
Subject: [PATCH 3/3] update version
Former-commit-id: b6d60cf55260edabb4ba6031cd3765f181277aad [formerly b6d60cf55260edabb4ba6031cd3765f181277aad [formerly b6d60cf55260edabb4ba6031cd3765f181277aad [formerly b6d60cf55260edabb4ba6031cd3765f181277aad [formerly 677763a096bfe8ccb8854b76d537223020c9908b [formerly 205bd5cd503883bfe9298af31d5e6a89154e4cc3]]]]]
Former-commit-id: 57c3bf230377e79714b6cb7892da05c49f8448ec
Former-commit-id: 07c1c20bce458531e39a704c2f8a214e6cfc72dd
Former-commit-id: 2e736f9ad94f5df73bdcdc5c4c6a53fbdc27333e [formerly e3430aedcc80550d8e69ff6886a2ff45632eb36b]
Former-commit-id: 79c1b1ab7af5ccee1e5a28d1a0c47c8b2cbd59f8
Former-commit-id: d03d243cb733403077d0a7fd2729c401c07556f7
Former-commit-id: c97cadaf85afc136ea19bf36a3f036f5956849dd
Former-commit-id: 2c6e33c3b0aab25a377d92815687e08c15dd7ed0
Former-commit-id: 9c72270c120295ef298c00f591941c2e833ba659
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 255d46432..934ad0ba2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "d2-admin",
- "version": "1.6.5",
+ "version": "1.6.6",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --open",