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) {