From bf4c4df93990e0700542427f07da565fef8df453 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 21 Nov 2024 21:02:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=BB=E5=8A=A1=E9=A6=96=E6=AC=A1?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=8F=91=E8=A1=A8=E6=83=85=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/functions/web.js | 11 +++++++++++ .../manage/components/ChatInput/index.vue | 14 ++++---------- .../js/pages/manage/components/TaskDetail.vue | 18 +++++++++++++++--- resources/assets/js/store/actions.js | 1 + 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js index 46234f102..0e0fe1c48 100755 --- a/resources/assets/js/functions/web.js +++ b/resources/assets/js/functions/web.js @@ -600,6 +600,17 @@ import {convertLocalResourcePath} from "../components/Replace/utils"; return 0; }, + /** + * 去除html内容中无效的部分 + * @param content + * @returns {string} + */ + filterInvalidLine(content) { + return `${content}` + .replace(/^(

\s*<\/p>)+|(

\s*<\/p>)+$/gi, '') + .replace(/^(

<\/p>)+|(

<\/p>)+$/gi, '') + }, + /** * 加载 VConsole 日志组件 * @param key diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue index cbd652387..031f8ff6c 100755 --- a/resources/assets/js/pages/manage/components/ChatInput/index.vue +++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue @@ -521,7 +521,7 @@ export default { }, sendClass() { - if (this.filterInvalidLine(this.value)) { + if ($A.filterInvalidLine(this.value)) { return 'sender'; } if (this.recordReady) { @@ -590,7 +590,7 @@ export default { } } if (!this.simpleMode) { - this.$store.dispatch("saveDialogDraft", {id: this.dialogId, extra_draft_content: this.filterInvalidLine(val)}) + this.$store.dispatch("saveDialogDraft", {id: this.dialogId, extra_draft_content: val}) } }, @@ -1157,7 +1157,7 @@ export default { this.emojiQuickShow = false; // setTimeout(_ => { - if (this.filterInvalidLine(this.value) === '') { + if ($A.filterInvalidLine(this.value) === '') { return } this.hidePopover('send') @@ -1270,12 +1270,11 @@ export default { onEmojiQuick(item) { if (item.type === 'online') { - this.$emit('input', "") this.$emit('on-send', ``) } else { - this.$emit('input', "") this.$emit('on-send', ``) } + this.$emit('input', "") this.emojiQuickShow = false this.focus() }, @@ -1830,11 +1829,6 @@ export default { } }, - filterInvalidLine(content) { - let value = (content + '').replace(/^(

\s*<\/p>)+|(

\s*<\/p>)+$/gi, '') - return value.replace(/^(

<\/p>)+|(

<\/p>)+$/gi, '') - }, - updateTools() { if (this.showEmoji) { this.$refs.emoji?.updatePopper() diff --git a/resources/assets/js/pages/manage/components/TaskDetail.vue b/resources/assets/js/pages/manage/components/TaskDetail.vue index 67c4be4f7..f88123c28 100755 --- a/resources/assets/js/pages/manage/components/TaskDetail.vue +++ b/resources/assets/js/pages/manage/components/TaskDetail.vue @@ -1540,7 +1540,11 @@ export default { }, sendDialogMsg(msgText = null) { - if (this.msgFile.length > 0) { + if (typeof msgText === 'string' && msgText) { + this.autoSaveTextDraft(); + this.$refs.dialog.sendMsg(msgText); + } else if (this.msgFile.length > 0) { + this.autoSaveTextDraft(); this.$refs.dialog.sendFileMsg(this.msgFile.map(file => Object.assign(file, { ajaxExtraData: { image_attachment: this.imageAttachment ? 1 : 0 @@ -1548,13 +1552,21 @@ export default { }))); } else if (this.msgText) { this.$refs.dialog.sendMsg(this.msgText); - } else if (typeof msgText === 'string' && msgText) { - this.$refs.dialog.sendMsg(msgText); } this.msgFile = []; this.msgText = ""; }, + autoSaveTextDraft() { + if (!this.msgText) { + return; + } + this.$store.dispatch("saveDialogDraft", { + id: this.taskDetail.dialog_id, + extra_draft_content: this.msgText + }) + }, + taskPasteDrag(e, type) { this.dialogDrag = false; if ($A.dataHasFolder(type === 'drag' ? e.dataTransfer : e.clipboardData)) { diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 83465918d..246e7a227 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -3044,6 +3044,7 @@ export default { * @param data {id, extra_draft_content} */ saveDialogDraft({state, dispatch}, data) { + data.extra_draft_content = $A.filterInvalidLine(data.extra_draft_content) state.dialogDraftTimer[data.id] && clearInterval(state.dialogDraftTimer[data.id]) state.dialogDraftTimer[data.id] = setTimeout(_ => { if (state.dialogId != data.id) {