mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-09 16:05:37 +00:00
fix: 任务首次聊天发表情失败的情况
This commit is contained in:
parent
51efb07c17
commit
bf4c4df939
11
resources/assets/js/functions/web.js
vendored
11
resources/assets/js/functions/web.js
vendored
@ -600,6 +600,17 @@ import {convertLocalResourcePath} from "../components/Replace/utils";
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* 去除html内容中无效的部分
|
||||
* @param content
|
||||
* @returns {string}
|
||||
*/
|
||||
filterInvalidLine(content) {
|
||||
return `${content}`
|
||||
.replace(/^(<p>\s*<\/p>)+|(<p>\s*<\/p>)+$/gi, '')
|
||||
.replace(/^(<p><br\/*><\/p>)+|(<p><br\/*><\/p>)+$/gi, '')
|
||||
},
|
||||
|
||||
/**
|
||||
* 加载 VConsole 日志组件
|
||||
* @param key
|
||||
|
||||
@ -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', `<img src="${item.src}"/>`)
|
||||
} else {
|
||||
this.$emit('input', "")
|
||||
this.$emit('on-send', `<img class="emoticon" data-asset="${item.asset}" data-name="${item.name}" src="${item.src}"/>`)
|
||||
}
|
||||
this.$emit('input', "")
|
||||
this.emojiQuickShow = false
|
||||
this.focus()
|
||||
},
|
||||
@ -1830,11 +1829,6 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
filterInvalidLine(content) {
|
||||
let value = (content + '').replace(/^(<p>\s*<\/p>)+|(<p>\s*<\/p>)+$/gi, '')
|
||||
return value.replace(/^(<p><br\/*><\/p>)+|(<p><br\/*><\/p>)+$/gi, '')
|
||||
},
|
||||
|
||||
updateTools() {
|
||||
if (this.showEmoji) {
|
||||
this.$refs.emoji?.updatePopper()
|
||||
|
||||
@ -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)) {
|
||||
|
||||
1
resources/assets/js/store/actions.js
vendored
1
resources/assets/js/store/actions.js
vendored
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user