mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 12:02:51 +00:00
perf: 优化从任务页面发送消息
This commit is contained in:
parent
f931567f56
commit
b7c2ddd59d
@ -2061,3 +2061,6 @@ AI开启新会话失败
|
|||||||
客户端
|
客户端
|
||||||
是否在该设备上退出登录?
|
是否在该设备上退出登录?
|
||||||
登录设备
|
登录设备
|
||||||
|
|
||||||
|
按工作流
|
||||||
|
按状态
|
||||||
|
|||||||
@ -1313,19 +1313,23 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
dialogMsgTransfer: {
|
dialogMsgTransfer: {
|
||||||
handler({time, msgFile, msgRecord, msgText, dialogId}) {
|
handler({time, msgFile, msgRecord, msgText, sendType, dialogId}) {
|
||||||
if (time > $A.dayjs().unix() && dialogId == this.dialogId) {
|
if (time < $A.dayjs().unix()) {
|
||||||
this.$store.state.dialogMsgTransfer.time = 0;
|
return
|
||||||
this.$nextTick(() => {
|
|
||||||
if ($A.isArray(msgFile) && msgFile.length > 0) {
|
|
||||||
this.sendFileMsg(msgFile);
|
|
||||||
} else if ($A.isJson(msgRecord) && msgRecord.duration > 0) {
|
|
||||||
this.sendRecord(msgRecord);
|
|
||||||
} else if (msgText) {
|
|
||||||
this.sendMsg(msgText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
if (dialogId != this.dialogId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$store.state.dialogMsgTransfer.time = 0;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if ($A.isArray(msgFile) && msgFile.length > 0) {
|
||||||
|
this.sendFileMsg(msgFile);
|
||||||
|
} else if ($A.isJson(msgRecord) && msgRecord.duration > 0) {
|
||||||
|
this.sendRecord(msgRecord);
|
||||||
|
} else if (msgText) {
|
||||||
|
this.sendMsg(msgText, sendType);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
@ -1537,11 +1541,10 @@ export default {
|
|||||||
if (typeof text === "string" && text) {
|
if (typeof text === "string" && text) {
|
||||||
textBody = text;
|
textBody = text;
|
||||||
} else {
|
} else {
|
||||||
textBody = this.msgText;
|
textBody = type === "md" ? this.$refs.input.getText() : this.msgText;
|
||||||
emptied = true;
|
emptied = true;
|
||||||
}
|
}
|
||||||
if (type === "md") {
|
if (type === "md") {
|
||||||
textBody = this.$refs.input.getText()
|
|
||||||
textType = "md"
|
textType = "md"
|
||||||
} else if (type === "silence") {
|
} else if (type === "silence") {
|
||||||
silence = "yes"
|
silence = "yes"
|
||||||
@ -2258,10 +2261,6 @@ export default {
|
|||||||
if (e.dataTransfer.effectAllowed === 'move') {
|
if (e.dataTransfer.effectAllowed === 'move') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const postFiles = Array.prototype.slice.call(e.dataTransfer.files);
|
|
||||||
if (postFiles.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.dialogDrag = true;
|
this.dialogDrag = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -427,7 +427,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<div v-if="navActive=='dialog' && taskDetail.msg_num > 0" class="menu-item" @click.stop="onSend('open')">
|
<div v-if="navActive=='dialog' && taskDetail.msg_num > 0" class="menu-item" @click.stop="onOpen">
|
||||||
<div v-if="openLoad > 0" class="menu-load"><Loading/></div>
|
<div v-if="openLoad > 0" class="menu-load"><Loading/></div>
|
||||||
{{$L('任务聊天')}}
|
{{$L('任务聊天')}}
|
||||||
<em>({{taskDetail.msg_num > 999 ? '999+' : taskDetail.msg_num}})</em>
|
<em>({{taskDetail.msg_num > 999 ? '999+' : taskDetail.msg_num}})</em>
|
||||||
@ -455,7 +455,6 @@
|
|||||||
:loading="sendLoad > 0"
|
:loading="sendLoad > 0"
|
||||||
:maxlength="200000"
|
:maxlength="200000"
|
||||||
:placeholder="$L('输入消息...')"
|
:placeholder="$L('输入消息...')"
|
||||||
:send-menu="false"
|
|
||||||
@on-focus="onFocus"
|
@on-focus="onFocus"
|
||||||
@on-more="onEventMore"
|
@on-more="onEventMore"
|
||||||
@on-file="onSelectFile"
|
@on-file="onSelectFile"
|
||||||
@ -1617,17 +1616,17 @@ export default {
|
|||||||
this.$refs.upload.handleClick()
|
this.$refs.upload.handleClick()
|
||||||
},
|
},
|
||||||
|
|
||||||
msgDialog(msgText = null, onlyOpen = false) {
|
msgDialog(sendType = null) {
|
||||||
if (this.sendLoad > 0 || this.openLoad > 0) {
|
if (this.sendLoad > 0 || this.openLoad > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (this.taskDetail.dialog_id) {
|
if (this.taskDetail.dialog_id) {
|
||||||
this.openDialogBefore(this.taskDetail.dialog_id, msgText, onlyOpen)
|
this.openDialogBefore(this.taskDetail.dialog_id, sendType)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (onlyOpen === true) {
|
if (sendType === true) {
|
||||||
this.openLoad++;
|
this.openLoad++;
|
||||||
} else {
|
} else {
|
||||||
this.sendLoad++;
|
this.sendLoad++;
|
||||||
@ -1641,11 +1640,11 @@ export default {
|
|||||||
}).then(async ({data}) => {
|
}).then(async ({data}) => {
|
||||||
await this.$store.dispatch("saveTask", {id: data.id, dialog_id: data.dialog_id});
|
await this.$store.dispatch("saveTask", {id: data.id, dialog_id: data.dialog_id});
|
||||||
await this.$store.dispatch("saveDialog", data.dialog_data);
|
await this.$store.dispatch("saveDialog", data.dialog_data);
|
||||||
await this.openDialogBefore(data.dialog_id, msgText, onlyOpen)
|
this.openDialogBefore(data.dialog_id, sendType)
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
}).finally(_ => {
|
}).finally(_ => {
|
||||||
if (onlyOpen === true) {
|
if (sendType === true) {
|
||||||
this.openLoad--;
|
this.openLoad--;
|
||||||
} else {
|
} else {
|
||||||
this.sendLoad--;
|
this.sendLoad--;
|
||||||
@ -1653,62 +1652,34 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async openDialogBefore(dialogId, msgText, onlyOpen) {
|
openDialogBefore(dialogId, sendType) {
|
||||||
|
if (sendType !== true) {
|
||||||
|
const transferData = {
|
||||||
|
time: $A.dayjs().unix() + 10,
|
||||||
|
msgRecord: this.msgRecord,
|
||||||
|
msgFile: this.msgFile,
|
||||||
|
msgText: sendType === 'md' ? this.$refs.chatInput?.getText() : this.msgText,
|
||||||
|
sendType,
|
||||||
|
dialogId,
|
||||||
|
};
|
||||||
|
this.msgRecord = {};
|
||||||
|
this.msgFile = [];
|
||||||
|
this.msgText = "";
|
||||||
|
this.$store.state.dialogMsgTransfer = transferData
|
||||||
|
this.$store.dispatch("saveDialogDraft", {id: `t_${this.taskId}`, content: ""})
|
||||||
|
}
|
||||||
|
|
||||||
if ($A.isSubElectron) {
|
if ($A.isSubElectron) {
|
||||||
await this.resizeDialog()
|
this.resizeDialog()
|
||||||
this.sendDialogMsg(msgText);
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$nextTick(() => {
|
|
||||||
if (this.windowPortrait) {
|
|
||||||
const openSuccess = () => {
|
|
||||||
const transferData = {
|
|
||||||
time: $A.dayjs().unix() + 10,
|
|
||||||
msgRecord: this.msgRecord,
|
|
||||||
msgFile: this.msgFile,
|
|
||||||
msgText: typeof msgText === 'string' && msgText ? msgText : this.msgText,
|
|
||||||
dialogId,
|
|
||||||
};
|
|
||||||
this.msgRecord = {};
|
|
||||||
this.msgFile = [];
|
|
||||||
this.msgText = "";
|
|
||||||
this.$store.state.dialogMsgTransfer = transferData
|
|
||||||
}
|
|
||||||
this.$store.dispatch('openDialog', dialogId).then(_ => {
|
|
||||||
!onlyOpen && openSuccess()
|
|
||||||
}).catch(({msg}) => {
|
|
||||||
$A.modalError(msg);
|
|
||||||
})
|
|
||||||
$A.eeuiAppKeyboardHide();
|
|
||||||
} else {
|
|
||||||
this.sendDialogMsg(msgText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
sendDialogMsg(msgText = null) {
|
if (this.windowPortrait) {
|
||||||
if (typeof msgText === 'string' && msgText) {
|
this.$store.dispatch('openDialog', dialogId).catch(({msg}) => {
|
||||||
this.autoSaveTextDraft();
|
$A.modalError(msg);
|
||||||
this.$refs.dialog.sendMsg(msgText);
|
})
|
||||||
} else if (this.msgFile.length > 0) {
|
$A.eeuiAppKeyboardHide();
|
||||||
this.autoSaveTextDraft();
|
|
||||||
this.$refs.dialog.sendFileMsg(this.msgFile.map(file => Object.assign(file, {
|
|
||||||
ajaxExtraData: {
|
|
||||||
image_attachment: this.imageAttachment ? 1 : 0
|
|
||||||
}
|
|
||||||
})));
|
|
||||||
} else if (this.msgText) {
|
|
||||||
this.$refs.dialog.sendMsg(this.msgText);
|
|
||||||
}
|
}
|
||||||
this.msgFile = [];
|
|
||||||
this.msgText = "";
|
|
||||||
},
|
|
||||||
|
|
||||||
autoSaveTextDraft() {
|
|
||||||
if (!this.msgText) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$store.dispatch("saveDialogDraft", {id: this.taskDetail.dialog_id, content: this.msgText})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
taskPasteDrag(e, type) {
|
taskPasteDrag(e, type) {
|
||||||
@ -1752,13 +1723,17 @@ export default {
|
|||||||
this.msgDialog()
|
this.msgDialog()
|
||||||
},
|
},
|
||||||
|
|
||||||
onSend(msgText) {
|
onOpen() {
|
||||||
this.$refs.chatInput?.hidePopover();
|
this.$refs.chatInput?.hidePopover();
|
||||||
if (msgText === 'open') {
|
this.msgDialog(true);
|
||||||
this.msgDialog(null, true);
|
},
|
||||||
} else {
|
|
||||||
this.msgDialog(msgText);
|
onSend(text, type) {
|
||||||
|
this.$refs.chatInput?.hidePopover();
|
||||||
|
if (typeof text === "string" && text) {
|
||||||
|
this.msgText = text;
|
||||||
}
|
}
|
||||||
|
this.msgDialog(type);
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteFile(file) {
|
deleteFile(file) {
|
||||||
|
|||||||
4
resources/assets/sass/pages/common.scss
vendored
4
resources/assets/sass/pages/common.scss
vendored
@ -123,6 +123,10 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ivu-select-group-wrap {
|
||||||
|
padding: 0 8px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.ivu-tooltip-popper {
|
.ivu-tooltip-popper {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user