Skip to content

Commit

Permalink
pref: post publishing experience. (halo-dev/console#125)
Browse files Browse the repository at this point in the history
* pref: post publishing experience.

* fix: sheet tab icon.
  • Loading branch information
ruibaby authored Apr 5, 2020
1 parent ffc8bf1 commit 6ad3358
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 99 deletions.
12 changes: 10 additions & 2 deletions src/api/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '登陆验证'
}
}

Expand Down
21 changes: 11 additions & 10 deletions src/views/post/PostEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
<a-button
type="danger"
@click="handleSaveDraft(false)"
:disabled="saving"
:loading="draftSaving"
>保存草稿</a-button>
<a-button
@click="handlePreview"
style="margin-left: 8px;"
:disabled="saving"
:loading="previewSaving"
>预览</a-button>
<a-button
type="primary"
Expand Down Expand Up @@ -97,7 +97,8 @@ export default {
selectedMetas: [],
isSaved: false,
contentChanges: 0,
saving: false
draftSaving: false,
previewSaving: false
}
},
beforeRouteEnter(to, from, next) {
Expand Down Expand Up @@ -183,7 +184,7 @@ export default {
if (!this.postToStage.title) {
this.postToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss')
}
this.saving = true
this.draftSaving = true
if (this.postToStage.id) {
// Update the post
if (draftOnly) {
Expand All @@ -193,7 +194,7 @@ export default {
this.$message.success('保存草稿成功!')
})
.finally(() => {
this.saving = false
this.draftSaving = false
})
} else {
postApi
Expand All @@ -204,7 +205,7 @@ export default {
this.postToStage = response.data.data
})
.finally(() => {
this.saving = false
this.draftSaving = false
})
}
} else {
Expand All @@ -217,7 +218,7 @@ export default {
this.postToStage = response.data.data
})
.finally(() => {
this.saving = false
this.draftSaving = false
})
}
},
Expand All @@ -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 => {
Expand All @@ -240,7 +241,7 @@ export default {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
this.previewSaving = false
})
})
} else {
Expand All @@ -254,7 +255,7 @@ export default {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
this.previewSaving = false
})
})
}
Expand Down
15 changes: 11 additions & 4 deletions src/views/post/components/PostSettingDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,12 @@
style="marginRight: 8px"
@click="handleDraftClick"
v-if="saveDraftButton"
:disabled="saving"
:loading="draftSaving"
>保存草稿</a-button>
<a-button
@click="handlePublishClick"
type="primary"
:disabled="saving"
:loading="saving"
> {{ selectedPost.id?'保存':'发布' }} </a-button>
</div>
</a-drawer>
Expand Down Expand Up @@ -335,7 +335,8 @@ export default {
categories: [],
categoryToCreate: {},
customTpls: [],
saving: false
saving: false,
draftSaving: false
}
},
props: {
Expand Down Expand Up @@ -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
Expand All @@ -514,6 +519,7 @@ export default {
})
.finally(() => {
this.saving = false
this.draftSaving = false
})
} else {
// Create the post
Expand All @@ -534,6 +540,7 @@ export default {
})
.finally(() => {
this.saving = false
this.draftSaving = false
})
}
},
Expand Down
21 changes: 11 additions & 10 deletions src/views/sheet/SheetEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
<a-button
type="danger"
@click="handleSaveDraft(false)"
:disabled="saving"
:loading="draftSaving"
>保存草稿</a-button>
<a-button
@click="handlePreview"
style="margin-left: 8px;"
:disabled="saving"
:loading="previewSaving"
>预览</a-button>
<a-button
type="primary"
Expand Down Expand Up @@ -90,7 +90,8 @@ export default {
selectedMetas: [],
isSaved: false,
contentChanges: 0,
saving: false
draftSaving: false,
previewSaving: false
}
},
beforeRouteEnter(to, from, next) {
Expand Down Expand Up @@ -174,7 +175,7 @@ export default {
if (!this.sheetToStage.title) {
this.sheetToStage.title = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss')
}
this.saving = true
this.draftSaving = true
if (this.sheetToStage.id) {
if (draftOnly) {
sheetApi
Expand All @@ -183,7 +184,7 @@ export default {
this.$message.success('保存草稿成功!')
})
.finally(() => {
this.saving = false
this.draftSaving = false
})
} else {
sheetApi
Expand All @@ -194,7 +195,7 @@ export default {
this.sheetToStage = response.data.data
})
.finally(() => {
this.saving = false
this.draftSaving = false
})
}
} else {
Expand All @@ -206,7 +207,7 @@ export default {
this.sheetToStage = response.data.data
})
.finally(() => {
this.saving = false
this.draftSaving = false
})
}
},
Expand All @@ -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)
Expand All @@ -228,7 +229,7 @@ export default {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
this.previewSaving = false
})
})
} else {
Expand All @@ -241,7 +242,7 @@ export default {
window.open(response.data, '_blank')
})
.finally(() => {
this.saving = false
this.previewSaving = false
})
})
}
Expand Down
49 changes: 39 additions & 10 deletions src/views/sheet/SheetList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<a-row>
<a-col :span="24">
<div class="card-container">
<a-tabs type="card">
<a-tab-pane key="independent">
<a-tabs
v-model="activeKey"
type="card"
>
<a-tab-pane
v-for="pane in panes"
:key="pane.key"
>
<span slot="tab">
<a-icon type="paper-clip" />独立页面
<a-icon :type="pane.icon" />{{ pane.title }}
</span>
<IndependentSheetList />
</a-tab-pane>
<a-tab-pane key="custom">
<span slot="tab">
<a-icon type="fork" />自定义页面
</span>
<CustomSheetList />
<component :is="pane.component"></component>
</a-tab-pane>
</a-tabs>
</div>
Expand All @@ -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
Expand Down
19 changes: 13 additions & 6 deletions src/views/sheet/components/SheetSettingDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@
v-if="saveDraftButton"
style="marginRight: 8px"
@click="handleDraftClick"
:disabled="saving"
:loading="draftSaving"
>保存草稿</a-button>
<a-button
type="primary"
@click="handlePublishClick"
:disabled="saving"
:loading="saving"
>{{ selectedSheet.id?'保存':'发布' }}</a-button>
</div>
</a-drawer>
Expand All @@ -233,7 +233,8 @@ export default {
settingLoading: true,
selectedSheet: this.sheet,
customTpls: [],
saving: false
saving: false,
draftSaving: false
}
},
props: {
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
})
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/views/system/Installation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading

0 comments on commit 6ad3358

Please sign in to comment.