diff --git a/src/components/Editor/MarkdownEditor.vue b/src/components/Editor/MarkdownEditor.vue index ef395a80a..00a84f40e 100644 --- a/src/components/Editor/MarkdownEditor.vue +++ b/src/components/Editor/MarkdownEditor.vue @@ -6,7 +6,7 @@ :boxShadow="false" :toolbars="toolbars" :ishljs="true" - :autofocus="false" + autofocus @imgAdd="handleAttachmentUpload" @save="handleSaveDraft" /> @@ -20,19 +20,19 @@ import attachmentApi from '@/api/attachment' export default { name: 'MarkdownEditor', components: { - haloEditor + haloEditor, }, props: { originalContent: { type: String, required: false, - default: '' - } + default: '', + }, }, data() { return { toolbars, - originalContentData: '' + originalContentData: '', } }, watch: { @@ -41,7 +41,7 @@ export default { }, originalContentData(val) { this.$emit('onContentChange', val) - } + }, }, methods: { handleAttachmentUpload(pos, $file) { @@ -55,7 +55,7 @@ export default { }, handleSaveDraft() { this.$emit('onSaveDraft') - } - } + }, + }, } diff --git a/src/config/router.config.js b/src/config/router.config.js index 2210a4b27..55312da01 100644 --- a/src/config/router.config.js +++ b/src/config/router.config.js @@ -162,7 +162,7 @@ export const asyncRouterMap = [ { path: '/system', name: 'System', - component: PageView, + component: BlankLayout, redirect: '/system/options', meta: { title: '系统', icon: 'setting' }, children: [ diff --git a/src/layouts/PageView.vue b/src/layouts/PageView.vue index af6e87617..fe3eafe31 100644 --- a/src/layouts/PageView.vue +++ b/src/layouts/PageView.vue @@ -15,6 +15,11 @@ slot="extra" > + + diff --git a/src/views/attachment/components/AttachmentDetailDrawer.vue b/src/views/attachment/components/AttachmentDetailDrawer.vue index 56a31b253..7a241b589 100644 --- a/src/views/attachment/components/AttachmentDetailDrawer.vue +++ b/src/views/attachment/components/AttachmentDetailDrawer.vue @@ -44,6 +44,7 @@ v-if="editable" > @@ -57,7 +58,7 @@ @@ -134,9 +135,7 @@ cancelText="取消" v-if="addToPhoto" > - 添加到图库 + 添加到图库 { + this.$refs.nameInput.focus() + }) + } + }, doUpdateAttachment() { if (!this.attachment.name) { this.$notification['error']({ message: '提示', - description: '附件名称不能为空!' + description: '附件名称不能为空!', }) return } - attachmentApi.update(this.attachment.id, this.attachment).then(response => { + attachmentApi.update(this.attachment.id, this.attachment).then((response) => { this.$log.debug('Updated attachment', response.data.data) - this.$message.success('附件修改成功!') }) this.editable = false }, handleCopyNormalLink() { const text = `${encodeURI(this.attachment.path)}` this.$copyText(text) - .then(message => { + .then((message) => { this.$log.debug('copy', message) this.$message.success('复制成功!') }) - .catch(err => { + .catch((err) => { this.$log.debug('copy.err', err) this.$message.error('复制失败!') }) @@ -271,11 +277,11 @@ export default { handleCopyMarkdownLink() { const text = `![${this.attachment.name}](${encodeURI(this.attachment.path)})` this.$copyText(text) - .then(message => { + .then((message) => { this.$log.debug('copy', message) this.$message.success('复制成功!') }) - .catch(err => { + .catch((err) => { this.$log.debug('copy.err', err) this.$message.error('复制失败!') }) @@ -285,7 +291,7 @@ export default { this.photo['thumbnail'] = encodeURI(this.attachment.thumbPath) this.photo['url'] = encodeURI(this.attachment.path) this.photo['takeTime'] = new Date().getTime() - photoApi.create(this.photo).then(response => { + photoApi.create(this.photo).then((response) => { this.$message.success('添加成功!') this.photo = {} }) @@ -322,7 +328,7 @@ export default { this.$set(this, 'photoPreviewVisible', photo) this.$set(this, 'videoPreviewVisible', video) this.$set(this, 'nonsupportPreviewVisible', nonsupport) - } - } + }, + }, } diff --git a/src/views/comment/components/CommentTab.vue b/src/views/comment/components/CommentTab.vue index 11dd04fdd..e7a34b90f 100644 --- a/src/views/comment/components/CommentTab.vue +++ b/src/views/comment/components/CommentTab.vue @@ -422,6 +422,7 @@ > { + return this.comments.map((comment) => { comment.statusProperty = this.commentStatus[comment.status] comment.content = marked(decodeHTML(comment.content)) return comment }) - } + }, }, methods: { handleListComments() { @@ -592,7 +593,7 @@ export default { this.queryParam.sort = this.pagination.sort commentApi .queryComment(this.type, this.queryParam) - .then(response => { + .then((response) => { this.comments = response.data.data.content this.pagination.total = response.data.data.total }) @@ -609,7 +610,7 @@ export default { handleEditStatusClick(commentId, status) { commentApi .updateStatus(this.type, commentId, status) - .then(response => { + .then((response) => { this.$message.success('操作成功!') }) .finally(() => { @@ -619,7 +620,7 @@ export default { handleDeleteClick(commentId) { commentApi .delete(this.type, commentId) - .then(response => { + .then((response) => { this.$message.success('删除成功!') }) .finally(() => { @@ -639,10 +640,13 @@ export default { } else { this.replyComment.postId = comment.sheet.id } + this.$nextTick(() => { + this.$refs.contentInput.focus() + }) }, handleCreateClick() { const _this = this - _this.$refs.replyCommentForm.validate(valid => { + _this.$refs.replyCommentForm.validate((valid) => { if (valid) { _this.replying = true commentApi @@ -687,7 +691,7 @@ export default { } commentApi .updateStatusInBatch(this.type, this.selectedRowKeys, status) - .then(response => { + .then((response) => { this.$log.debug(`commentIds: ${this.selectedRowKeys}, status: ${status}`) this.selectedRowKeys = [] }) @@ -702,7 +706,7 @@ export default { } commentApi .deleteInBatch(this.type, this.selectedRowKeys) - .then(response => { + .then((response) => { this.$log.debug(`delete: ${this.selectedRowKeys}`) this.selectedRowKeys = [] }) @@ -726,14 +730,14 @@ export default { return { props: { disabled: this.queryParam.status == null || this.queryParam.status === '', - name: comment.author - } + name: comment.author, + }, } }, handleShowDetailDrawer(comment) { this.selectedComment = comment this.commentDetailVisible = true - } - } + }, + }, } diff --git a/src/views/comment/components/TargetCommentDrawer.vue b/src/views/comment/components/TargetCommentDrawer.vue index ddb8cc8bd..b5481308e 100644 --- a/src/views/comment/components/TargetCommentDrawer.vue +++ b/src/views/comment/components/TargetCommentDrawer.vue @@ -29,11 +29,11 @@ - - + +
@@ -57,59 +57,42 @@
评论
- - + + - - - - - - - - - - + + @@ -123,111 +106,130 @@ export default { components: { TargetCommentTree }, data() { return { - comments: [], - loading: false, - selectedComment: {}, - replyComment: {}, - replyCommentVisible: false, - commentVisible: false, - pagination: { - page: 1, - size: 10, - sort: null, - total: 1 + list: { + data: [], + loading: false, + selected: {}, + pagination: { + page: 1, + size: 10, + sort: null, + total: 1, + }, + queryParam: { + page: 0, + size: 10, + sort: null, + keyword: null, + }, + }, + replyModal: { + model: {}, + visible: false, + saving: false, + saveErrored: false, + rules: { + content: [{ required: true, message: '* 内容不能为空', trigger: ['change'] }], + }, }, - queryParam: { - page: 0, - size: 10, - sort: null, - keyword: null - } } }, props: { visible: { type: Boolean, required: false, - default: false + default: false, }, title: { type: String, required: false, - default: '' + default: '', }, description: { type: String, required: false, - default: '' + default: '', }, target: { type: String, required: false, - default: '' + default: '', }, id: { type: Number, required: false, - default: 0 - } + default: 0, + }, + }, + computed: { + replyModalTitle() { + return this.list.selected.id ? `回复给:${this.list.selected.author}` : '评论' + }, }, methods: { handleListComments() { - this.loading = true - this.queryParam.page = this.pagination.page - 1 - this.queryParam.size = this.pagination.size - this.queryParam.sort = this.pagination.sort + this.list.loading = true + this.list.queryParam.page = this.list.pagination.page - 1 + this.list.queryParam.size = this.list.pagination.size + this.list.queryParam.sort = this.list.pagination.sort commentApi - .commentTree(this.target, this.id, this.queryParam) - .then(response => { - this.comments = response.data.data.content - this.pagination.total = response.data.data.total + .commentTree(this.target, this.id, this.list.queryParam) + .then((response) => { + this.list.data = response.data.data.content + this.list.pagination.total = response.data.data.total }) .finally(() => { setTimeout(() => { - this.loading = false + this.list.loading = false }, 200) }) }, handlePaginationChange(page, pageSize) { - this.pagination.page = page - this.pagination.size = pageSize + this.list.pagination.page = page + this.list.pagination.size = pageSize this.handleListComments() }, handleCommentReply(comment) { - this.selectedComment = comment - this.replyCommentVisible = true - this.replyComment.parentId = comment.id - this.replyComment.postId = this.id + this.list.selected = comment + this.replyModal.visible = true + this.replyModal.model.parentId = comment.id + this.replyModal.model.postId = this.id + this.$nextTick(() => { + this.$refs.contentInput.focus() + }) }, - handleComment() { - this.replyComment.postId = this.id - this.commentVisible = true + handleReplyClick() { + const _this = this + _this.$refs.replyCommentForm.validate((valid) => { + if (valid) { + _this.replyModal.saving = true + commentApi + .create(_this.target, _this.replyModal.model) + .catch(() => { + _this.replyModal.saveErrored = true + }) + .finally(() => { + setTimeout(() => { + _this.replyModal.saving = false + }, 400) + }) + } + }) }, - handleCreateClick() { - if (!this.replyComment.content) { - this.$notification['error']({ - message: '提示', - description: '评论内容不能为空!' - }) - return + handleReplyCallback() { + if (this.replyModal.saveErrored) { + this.replyModal.saveErrored = false + } else { + this.replyModal.model = {} + this.list.selected = {} + this.replyModal.visible = false + this.handleListComments() } - commentApi - .create(this.target, this.replyComment) - .then(response => { - this.$message.success('回复成功!') - this.replyComment = {} - this.selectedComment = {} - this.replyCommentVisible = false - this.commentVisible = false - }) - .finally(() => { - this.handleListComments() - }) }, handleEditStatusClick(comment, status) { commentApi .updateStatus(this.target, comment.id, status) - .then(response => { + .then((response) => { this.$message.success('操作成功!') }) .finally(() => { @@ -237,28 +239,24 @@ export default { handleCommentDelete(comment) { commentApi .delete(this.target, comment.id) - .then(response => { + .then((response) => { this.$message.success('删除成功!') }) .finally(() => { this.handleListComments() }) }, - onReplyClose() { - this.replyComment = {} - this.selectedComment = {} - this.replyCommentVisible = false - }, - onCommentClose() { - this.replyComment = {} - this.commentVisible = false + onReplyModalClose() { + this.replyModal.model = {} + this.list.selected = {} + this.replyModal.visible = false }, onClose() { - this.comments = [] - this.pagination = { + this.list.data = [] + this.list.pagination = { page: 1, size: 10, - sort: '' + sort: '', } this.$emit('close', false) }, @@ -266,7 +264,7 @@ export default { if (visible) { this.handleListComments() } - } - } + }, + }, } diff --git a/src/views/interface/ThemeList.vue b/src/views/interface/ThemeList.vue index c480559ff..89bad3e8d 100644 --- a/src/views/interface/ThemeList.vue +++ b/src/views/interface/ThemeList.vue @@ -5,7 +5,6 @@ >