mirror of
https://github.com/kuaifan/dootask.git
synced 2026-06-07 07:59:10 +00:00
fix(chat): 修复 AI 助手(userid=-1)在多处显示异常的问题
在 UserAvatar 组件中统一处理 AI 助手虚拟用户,避免各组件重复判断; 同时修复 @提及、回复引用、转发消息等场景下的 undefined 和空白显示问题, 并过滤批量用户请求中的无效 userid。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0ecaf9740f
commit
8def4addc4
BIN
public/images/avatar/default_assistant.png
Normal file
BIN
public/images/avatar/default_assistant.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
@ -151,6 +151,11 @@ export default {
|
||||
if (!this.$store.state.userId) {
|
||||
return;
|
||||
}
|
||||
// AI 助手虚拟用户
|
||||
if (this.userid === -1) {
|
||||
this.setUser({userid: -1, nickname: this.$L('AI 助手'), bot: false, userimg: $A.mainUrl('images/avatar/default_assistant.png'), online: false});
|
||||
return;
|
||||
}
|
||||
const tempUser = this.$store.state.cacheUserBasic.find(({userid}) => userid == this.userid);
|
||||
if (tempUser) {
|
||||
this.setUser(tempUser);
|
||||
|
||||
@ -2259,6 +2259,7 @@ export default {
|
||||
this.quoteUpdate || // 修改消息
|
||||
!this.quoteData || // 无引用消息
|
||||
!this.replyMsgAutoMention || // 不自动@
|
||||
userData.userid === -1 || // AI 助手
|
||||
this.userId === userData.userid || // 自己
|
||||
this.quoteData.userid !== userData.userid // 不同人
|
||||
) {
|
||||
|
||||
@ -2,9 +2,7 @@
|
||||
<div class="dialog-view" :class="viewClass" :data-id="msgData.id">
|
||||
<!--昵称-->
|
||||
<div v-if="dialogType === 'group'" class="dialog-username" @pointerdown="handleOperation($event, 'mention')">
|
||||
<!-- AI 助手只显示名称 -->
|
||||
<span v-if="msgData.userid === -1" class="ai-assistant-name">{{ $L('AI 助手') }}</span>
|
||||
<UserAvatar v-else :userid="msgData.userid" :show-icon="false" :show-name="true" click-open-detail/>
|
||||
<UserAvatar :userid="msgData.userid" :show-icon="false" :show-name="true" :click-open-detail="msgData.userid !== -1"/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@ -20,7 +18,7 @@
|
||||
<div class="reply-desc" v-html="$A.getMsgSimpleDesc(msgData.msg.reply_data, 'image-preview')"></div>
|
||||
</div>
|
||||
<!--转发-->
|
||||
<div v-if="!hideForward && msgData.forward_id && showForwardData(msgData.msg.forward_data)" class="dialog-reply no-dark-content" @click="openDialog(msgData.msg.forward_data.userid)">
|
||||
<div v-if="!hideForward && msgData.forward_id && showForwardData(msgData.msg.forward_data)" class="dialog-reply no-dark-content" @click="msgData.msg.forward_data.userid !== -1 && openDialog(msgData.msg.forward_data.userid)">
|
||||
<div class="reply-avatar">
|
||||
<UserAvatar :userid="msgData.msg.forward_data.userid" :show-icon="false" :show-name="true"/>
|
||||
</div>
|
||||
|
||||
@ -3237,6 +3237,10 @@ export default {
|
||||
switch (type) {
|
||||
// 长按触发提及
|
||||
case "mention":
|
||||
if (data.userid === -1) {
|
||||
// AI 助手不支持@提及
|
||||
break;
|
||||
}
|
||||
const user = this.cacheUserBasic.find(({userid}) => userid == data.userid);
|
||||
if (user) {
|
||||
this.$refs.input?.addMention({
|
||||
|
||||
2
resources/assets/js/store/actions.js
vendored
2
resources/assets/js/store/actions.js
vendored
@ -645,7 +645,7 @@ export default {
|
||||
dispatch("dialogMsgRead");
|
||||
dispatch("updateMicroAppsStatus");
|
||||
//
|
||||
const allIds = Object.values(state.userAvatar).map(({userid}) => userid);
|
||||
const allIds = Object.values(state.userAvatar).map(({userid}) => userid).filter(id => id > 0);
|
||||
[...new Set(allIds)].some(userid => dispatch("getUserBasic", {userid}))
|
||||
},
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
Loading…
x
Reference in New Issue
Block a user