From 2fd8d143715811fffe3c08a6553bf525cfa46bb1 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sun, 5 Apr 2020 17:01:57 +0800 Subject: [PATCH] pref: post publishing experience. (#125) * pref: post publishing experience. * fix: sheet tab icon. --- src/api/log.js | 12 +- src/views/post/PostEdit.vue | 21 ++-- .../post/components/PostSettingDrawer.vue | 15 ++- src/views/sheet/SheetEdit.vue | 21 ++-- src/views/sheet/SheetList.vue | 49 ++++++-- .../sheet/components/SheetSettingDrawer.vue | 19 ++- src/views/system/Installation.vue | 4 +- src/views/user/Profile.vue | 116 +++++++++--------- 8 files changed, 158 insertions(+), 99 deletions(-) diff --git a/src/api/log.js b/src/api/log.js index 35378764..c1061b9f 100644 --- a/src/api/log.js +++ b/src/api/log.js @@ -71,12 +71,20 @@ logApi.logType = { text: '页面发布' }, SHEET_EDITED: { - value: 50, + value: 55, text: '页面修改' }, SHEET_DELETED: { - value: 50, + value: 60, text: '页面删除' + }, + MFA_UPDATED: { + value: 65, + text: '两步验证' + }, + LOGGED_PRE_CHECK: { + value: 70, + text: '登陆验证' } } diff --git a/src/views/post/PostEdit.vue b/src/views/post/PostEdit.vue index 47187173..05465b3b 100644 --- a/src/views/post/PostEdit.vue +++ b/src/views/post/PostEdit.vue @@ -46,12 +46,12 @@ 保存草稿 预览 { - this.saving = false + this.draftSaving = false }) } else { postApi @@ -204,7 +205,7 @@ export default { this.postToStage = response.data.data }) .finally(() => { - this.saving = false + this.draftSaving = false }) } } else { @@ -217,7 +218,7 @@ export default { this.postToStage = response.data.data }) .finally(() => { - this.saving = false + this.draftSaving = false }) } }, @@ -229,7 +230,7 @@ export default { if (!this.postToStage.title) { this.postToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss') } - this.saving = true + this.previewSaving = true if (this.postToStage.id) { // Update the post postApi.update(this.postToStage.id, this.postToStage, false).then(response => { @@ -240,7 +241,7 @@ export default { window.open(response.data, '_blank') }) .finally(() => { - this.saving = false + this.previewSaving = false }) }) } else { @@ -254,7 +255,7 @@ export default { window.open(response.data, '_blank') }) .finally(() => { - this.saving = false + this.previewSaving = false }) }) } diff --git a/src/views/post/components/PostSettingDrawer.vue b/src/views/post/components/PostSettingDrawer.vue index 2af5cdee..6bdc205f 100644 --- a/src/views/post/components/PostSettingDrawer.vue +++ b/src/views/post/components/PostSettingDrawer.vue @@ -293,12 +293,12 @@ style="marginRight: 8px" @click="handleDraftClick" v-if="saveDraftButton" - :disabled="saving" + :loading="draftSaving" >保存草稿 {{ selectedPost.id?'保存':'发布' }} @@ -335,7 +335,8 @@ export default { categories: [], categoryToCreate: {}, customTpls: [], - saving: false + saving: false, + draftSaving: false } }, props: { @@ -495,7 +496,11 @@ export default { this.selectedPost.tagIds = this.selectedTagIds // Set post metas this.selectedPost.metas = this.selectedMetas - this.saving = true + if (this.selectedPost.status === 'DRAFT') { + this.draftSaving = true + } else { + this.saving = true + } if (this.selectedPost.id) { // Update the post postApi @@ -514,6 +519,7 @@ export default { }) .finally(() => { this.saving = false + this.draftSaving = false }) } else { // Create the post @@ -534,6 +540,7 @@ export default { }) .finally(() => { this.saving = false + this.draftSaving = false }) } }, diff --git a/src/views/sheet/SheetEdit.vue b/src/views/sheet/SheetEdit.vue index 58de5635..84066881 100644 --- a/src/views/sheet/SheetEdit.vue +++ b/src/views/sheet/SheetEdit.vue @@ -41,12 +41,12 @@ 保存草稿 预览 { - this.saving = false + this.draftSaving = false }) } else { sheetApi @@ -194,7 +195,7 @@ export default { this.sheetToStage = response.data.data }) .finally(() => { - this.saving = false + this.draftSaving = false }) } } else { @@ -206,7 +207,7 @@ export default { this.sheetToStage = response.data.data }) .finally(() => { - this.saving = false + this.draftSaving = false }) } }, @@ -218,7 +219,7 @@ export default { if (!this.sheetToStage.title) { this.sheetToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss') } - this.saving = true + this.previewSaving = true if (this.sheetToStage.id) { sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => { this.$log.debug('Updated sheet', response.data.data) @@ -228,7 +229,7 @@ export default { window.open(response.data, '_blank') }) .finally(() => { - this.saving = false + this.previewSaving = false }) }) } else { @@ -241,7 +242,7 @@ export default { window.open(response.data, '_blank') }) .finally(() => { - this.saving = false + this.previewSaving = false }) }) } diff --git a/src/views/sheet/SheetList.vue b/src/views/sheet/SheetList.vue index 72710e8a..625e7fed 100644 --- a/src/views/sheet/SheetList.vue +++ b/src/views/sheet/SheetList.vue @@ -3,18 +3,18 @@
- - + + - 独立页面 + {{ pane.title }} - - - - - 自定义页面 - - +
@@ -28,6 +28,35 @@ import IndependentSheetList from './components/IndependentSheetList' import CustomSheetList from './components/CustomSheetList' export default { + data() { + const panes = [ + { title: '独立页面', icon: 'paper-clip', component: 'IndependentSheetList', key: 'independent' }, + { title: '自定义页面', icon: 'fork', component: 'CustomSheetList', key: 'custom' } + ] + return { + activeKey: panes[0].key, + panes + } + }, + beforeRouteEnter(to, from, next) { + // Get post id from query + const activeKey = to.query.activeKey + next(vm => { + if (activeKey) { + vm.activeKey = activeKey + } + }) + }, + watch: { + activeKey: { + handler: function(newVal, oldVal) { + if (newVal) { + const path = this.$router.history.current.path + this.$router.push({ path, query: { activeKey: newVal } }).catch(err => err) + } + } + } + }, components: { IndependentSheetList, CustomSheetList diff --git a/src/views/sheet/components/SheetSettingDrawer.vue b/src/views/sheet/components/SheetSettingDrawer.vue index c163f2a2..2f9ed4ce 100644 --- a/src/views/sheet/components/SheetSettingDrawer.vue +++ b/src/views/sheet/components/SheetSettingDrawer.vue @@ -203,12 +203,12 @@ v-if="saveDraftButton" style="marginRight: 8px" @click="handleDraftClick" - :disabled="saving" + :loading="draftSaving" >保存草稿
{{ selectedSheet.id?'保存':'发布' }} @@ -233,7 +233,8 @@ export default { settingLoading: true, selectedSheet: this.sheet, customTpls: [], - saving: false + saving: false, + draftSaving: false } }, props: { @@ -346,7 +347,11 @@ export default { return } this.selectedSheet.metas = this.selectedMetas - this.saving = true + if (this.selectedSheet.status === 'DRAFT') { + this.draftSaving = true + } else { + this.saving = true + } if (this.selectedSheet.id) { sheetApi .update(this.selectedSheet.id, this.selectedSheet, false) @@ -360,10 +365,11 @@ export default { } this.$emit('onSaved', true) - this.$router.push({ name: 'SheetList' }) + this.$router.push({ name: 'SheetList', query: { activeKey: 'custom' } }) }) .finally(() => { this.saving = false + this.draftSaving = false }) } else { sheetApi @@ -378,11 +384,12 @@ export default { } this.$emit('onSaved', true) - this.$router.push({ name: 'SheetList' }) + this.$router.push({ name: 'SheetList', query: { activeKey: 'custom' } }) this.selectedSheet = response.data.data }) .finally(() => { this.saving = false + this.draftSaving = false }) } }, diff --git a/src/views/system/Installation.vue b/src/views/system/Installation.vue index d32594be..b8888981 100644 --- a/src/views/system/Installation.vue +++ b/src/views/system/Installation.vue @@ -231,8 +231,8 @@ export default { this.$set(this.installation, 'url', window.location.protocol + '//' + window.location.host) }, methods: { - handleValidateConfirmPassword(rule,value, callback){ - if (this.installation.confirmPassword && this.installation.password !== this.installation.confirmPassword ) { + handleValidateConfirmPassword(rule, value, callback) { + if (this.installation.confirmPassword && this.installation.password !== this.installation.confirmPassword) { callback('确认密码和密码不匹配') } callback() diff --git a/src/views/user/Profile.vue b/src/views/user/Profile.vue index 9c3f216a..13e03e9a 100644 --- a/src/views/user/Profile.vue +++ b/src/views/user/Profile.vue @@ -145,49 +145,64 @@ /> - + Authy 功能丰富 专为两步验证码 - - IOS/Android/Windows/Mac/Linux + + iOS/Android/Windows/Mac/Linux - - Chrome扩展 + + Chrome 扩展 - GoogleAuthenticator 简单易用 但不支持密钥导出备份 + Google Authenticator 简单易用,但不支持密钥导出备份 - - IOS + + iOS - + Android - MicrosoftAuthenticator 使用微软全家桶的推荐 + Microsoft Authenticator 使用微软全家桶的推荐 - - IOS/Android + + iOS/Android 1Password 强大安全的密码管理付费应用 - - IOS/Android/Windows/Mac/Linux/ChromeOS + + iOS/Android/Windows/Mac/Linux/ChromeOS @@ -215,18 +230,14 @@ :confirmLoading="false" @cancel="handleCloseMFAuthModal" :closable="false" - :maskClosable="false" icon="safety-certificate" :keyboard="false" :centered="true" :destroyOnClose="true" :width="300" - > - - + + -
-

- 1.请扫描二维码或导入 key + + -

-

- MFAKey:
{{ mfaParam.mfaKey }} -

-

- 2.验证两步验证码 - - - - - -

-

* 推荐使用 Authy | 微软验证器

-
+
+ + + + + +
@@ -303,7 +309,7 @@ export default { authcode: null, qrImage: null, modal: { - title: '确认开启两步验证?', + title: '确认开启两步验证?', visible: false }, switch: { @@ -332,7 +338,7 @@ export default { watch: { mfaType(value) { if (value) { - this.mfaParam.mfaUsed = (value !== 'NONE') + this.mfaParam.mfaUsed = value !== 'NONE' } }, mfaUsed(value) { @@ -404,12 +410,12 @@ export default { if (!useMFAuth && this.mfaUsed) { // true -> false // show cloes MFA modal - this.mfaParam.modal.title = '确认关闭两步验证?' + this.mfaParam.modal.title = '确认关闭两步验证?' this.mfaParam.modal.visible = true } else { // false -> true // show open MFA modal - this.mfaParam.modal.title = '确认开启两步验证?' + this.mfaParam.modal.title = '确认开启两步验证?' // generate MFAKey and Qr Image userApi.mfaGenerate('TFA_TOTP').then(response => { this.mfaParam.mfaKey = response.data.data.mfaKey @@ -422,14 +428,14 @@ export default { var mfaType = this.mfaUsed ? 'NONE' : 'TFA_TOTP' if (mfaType === 'NONE') { if (!this.mfaParam.authcode) { - this.$message.warn('两步验证码不能为空') + this.$message.warn('两步验证码不能为空!') return } } userApi.mfaUpdate(mfaType, this.mfaParam.mfaKey, this.mfaParam.authcode).then(response => { this.handleCloseMFAuthModal() this.mfaParam.mfaType = response.data.data.mfaType - this.$message.success(this.mfaUsed ? '两步验证已关闭!' : '两步验证已开启,下次登陆生效!') + this.$message.success(this.mfaUsed ? '两步验证已关闭!' : '两步验证已开启,下次登陆生效!') }) }, handleCloseMFAuthModal() {