From ee926737084301707695cdeb885255cc26d9422b Mon Sep 17 00:00:00 2001 From: wangqing Date: Wed, 23 Dec 2020 18:41:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E9=A1=B5=E9=9D=A2=20?= =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=ACskins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintignore | 1 + .stylelintignore | 1 + src/components/tinymce/index.vue | 2 ++ src/router/modules/root.js | 19 ++++++------ src/store/modules/user.js | 12 ++++++++ src/views/account/login.vue | 2 +- src/views/account/member.vue | 13 ++++++--- src/views/account/validate.vue | 50 ++++++++++++++++++++++++++++---- src/views/home/index.vue | 23 +++++++++------ src/views/redirect.vue | 34 +++++++++++++++++++--- 10 files changed, 124 insertions(+), 33 deletions(-) diff --git a/.eslintignore b/.eslintignore index fe76fd2..be8ea34 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,3 +7,4 @@ src/utils/sign.js src/views/form/ src/utils/ src/components/ +src/assets/ diff --git a/.stylelintignore b/.stylelintignore index 89a3ac0..bccb12f 100644 --- a/.stylelintignore +++ b/.stylelintignore @@ -6,3 +6,4 @@ src/utils/sign.js src/views/form/ src/utils/ src/components/ +src/assets/ diff --git a/src/components/tinymce/index.vue b/src/components/tinymce/index.vue index 8f50b55..6cc3fa5 100644 --- a/src/components/tinymce/index.vue +++ b/src/components/tinymce/index.vue @@ -36,6 +36,8 @@ export default { selector: `#${this.tinymceId}`, language: 'zh_CN', menubar: 'false', + skin_url: '/tinymce/skins/ui/tduck', + content_css : '/tinymce/skins/content/tduck' , plugins, toolbar, height: 300, diff --git a/src/router/modules/root.js b/src/router/modules/root.js index 0886ffa..db82889 100644 --- a/src/router/modules/root.js +++ b/src/router/modules/root.js @@ -2,13 +2,18 @@ export default [ { path: '/test', meta: {requireLogin: false}, - component: () => import(/* webpackChunkName: 'root' */ '@/views/test') + component: () => import(/* webpackChunkName: 'root' */ '@/components/tinymce/example/Index') }, { - path: '/redirect', + path: '/redirect/:type', meta: {requireLogin: false}, component: () => import(/* webpackChunkName: 'root' */ '@/views/redirect') }, + { + path: '/account/validate', + meta: {requireLogin: true}, + component: () => import(/* webpackChunkName: 'root' */ '@/views/account/validate') + }, { path: '/', meta: {requireLogin: false}, @@ -25,15 +30,10 @@ export default [ component: () => import(/* webpackChunkName: 'root' */ '@/views/account/login.vue') }, { - path: '/forget/password', + path: 'forget/password', meta: {requireLogin: false}, component: () => import(/* webpackChunkName: 'root' */ '@/views/account/ForgetPwd') }, - { - path: '/account/validate', - meta: {requireLogin: true}, - component: () => import(/* webpackChunkName: 'root' */ '@/views/account/validate') - }, { path: '/enterprise', meta: {requireLogin: false}, @@ -50,7 +50,8 @@ export default [ component: () => import(/* webpackChunkName: 'root' */ '@/views/official/proposal') } ] - }, { + }, + { path: '/home', meta: {requireLogin: true}, component: () => import(/* webpackChunkName: 'root' */ '@/views/home/index.vue'), diff --git a/src/store/modules/user.js b/src/store/modules/user.js index a59c359..5983072 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -25,6 +25,16 @@ const actions = { resolve() }) }, + update(context, payload) { + return new Promise(resolve => { + // 模拟登录成功,写入 token 信息 + context.commit('setData', { + token: state.token, + userInfo: payload + }) + resolve() + }) + }, logout(context) { context.commit('delData') } @@ -38,6 +48,8 @@ const mutations = { state.userInfo = JSON.stringify(data.userInfo) }, delData() { + state.token = null + state.userInfo = null localStorage.removeItem('token') localStorage.removeItem('userInfo') } diff --git a/src/views/account/login.vue b/src/views/account/login.vue index ded627f..c648f8d 100644 --- a/src/views/account/login.vue +++ b/src/views/account/login.vue @@ -349,7 +349,7 @@ export default { }, // qq登录授权地址 getQQLoginAuthorizeUrl() { - let reUrl = getCurrentDomain() + '/redirect' + let reUrl = getCurrentDomain() + '/redirect/qqlogin' this.$api.get('/login/qq/authorize/url', {params: {redirectUri: reUrl}}).then(res => { this.qqLoginAuthorizeUrl = res.data }) diff --git a/src/views/account/member.vue b/src/views/account/member.vue index fc76999..2fc4a40 100644 --- a/src/views/account/member.vue +++ b/src/views/account/member.vue @@ -342,7 +342,7 @@ export default { ] }, bindWxDialogVisible: false, - bindWxQrcode: false, + bindWxQrcode: '', editNameDialogVisible: false, pwdDialogVisible: false, phoneDialogVisible: false, @@ -372,6 +372,9 @@ export default { this.$api.get('/user/current/detail').then(res => { if (res.data) { this.userInfo = res.data + this.$store.dispatch('user/update', this.userInfo).then(() => { + + }) } }) }, @@ -409,6 +412,7 @@ export default { this.$api.get('/user/update-email/msg', {params: {email: this.userInfoForm.email}}).then(res => { if (res.data) { this.msgSuccess('发送成功,请去您的邮箱查看') + this.emailDialogVisible = false } }) } @@ -437,18 +441,19 @@ export default { if (res.data) { this.msgSuccess('保存成功') this.queryUserInfo() + } }) }, // qq登录授权地址 getQQLoginAuthorizeUrl() { - let reUrl = getCurrentDomain() + '/redirect' + let reUrl = getCurrentDomain() + '/redirect/bindqq' this.$api.get('/login/qq/authorize/url', {params: {redirectUri: reUrl}}).then(res => { this.qqLoginAuthorizeUrl = res.data }) }, redirectUrl(url) { - location.href = url + window.open(url) }, updateUserPhoneHandle() { this.$refs['updatePhoneForm'].validateField(['phoneNumber', 'code'], err => { @@ -468,6 +473,7 @@ export default { let {wxName} = res.data if (wxName) { this.msgSuccess('绑定成功') + clearInterval(this.bindWxTimer) this.userInfo.wxName = wxName this.bindWxDialogVisible = false } @@ -476,7 +482,6 @@ export default { }, 5 * 1000) }, cropUploadSuccess(res) { - console.log(res) this.userInfoForm.avatar = res.data this.updateUserHandle() } diff --git a/src/views/account/validate.vue b/src/views/account/validate.vue index 105f14a..d62af01 100644 --- a/src/views/account/validate.vue +++ b/src/views/account/validate.vue @@ -1,8 +1,16 @@ @@ -23,8 +31,8 @@ export default { if (type == 'updateEmail') { let code = this.$route.query.code let email = this.$route.query.email - this.$api.post('/update/email', {email: email, key: code}).then(res => { - if (res.data) { + this.$api.post('/user/update/email', {email: email, key: code}).then(res => { + if (!res.data) { this.bindEmailErr = true } }) @@ -34,3 +42,33 @@ export default { } + diff --git a/src/views/home/index.vue b/src/views/home/index.vue index fbb7b91..c1b97d5 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -110,9 +110,6 @@ export default { }, getUserInfo() { let user = JSON.parse(this.getStore.getters['user/userInfo']) - if (!user) { - this.logoutHandle() - } return user } }, @@ -129,13 +126,21 @@ export default { this.menuIndex = routerPath }, logoutHandle() { - this.$store.dispatch('user/logout').then(() => { - router.push({ - path: '/login', - query: { - redirect: router.currentRoute.fullPath - } + this.$confirm('您确定要退出登录吗?', '退出确认', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.$store.dispatch('user/logout').then(() => { + router.push({ + path: '/login', + query: { + redirect: router.currentRoute.fullPath + } + }) }) + }).catch(() => { + }) } } diff --git a/src/views/redirect.vue b/src/views/redirect.vue index 4f15956..92e3dda 100644 --- a/src/views/redirect.vue +++ b/src/views/redirect.vue @@ -11,11 +11,39 @@ export default { return {} }, created() { + // 重定向类型 + let type = this.$route.params.type + // eslint-disable-next-line no-debugger + debugger + if (type == 'qqlogin') { + this.qqLoginHandle() + } else if (type == 'bindqq') { + this.bindQqHandle() + } + }, + methods: { + bindQqHandle() { + let code = getQueryString('code') + let state = getQueryString('state') + if (code && state) { + let reUrl = getCurrentDomain() + '/redirect/bindqq' + this.$api.post('/user/bind/qq', {authorizeCode: code, redirectUri: reUrl}).then(res => { + if (res.data) { + this.msgSuccess('绑定成功') + window.close() + } else { + this.msgError('绑定失败,该qq已经绑定其他账号') + } + }) + } + } + }, + qqLoginHandle() { // qq 登录重定向 let code = getQueryString('code') let state = getQueryString('state') if (code && state) { - let reUrl = getCurrentDomain() + '/redirect' + let reUrl = getCurrentDomain() + '/redirect/qqlogin' this.$api.post('/login/qq', {authorizeCode: code, redirectUri: reUrl}).then(res => { if (res.data) { this.msgSuccess('登录成功') @@ -39,8 +67,6 @@ export default { } }) } - }, - methods: {} - + } }