fix: kefu store
This commit is contained in:
@@ -5,7 +5,10 @@ import { isEmpty } from '@vben/utils';
|
|||||||
|
|
||||||
import { acceptHMRUpdate, defineStore } from 'pinia';
|
import { acceptHMRUpdate, defineStore } from 'pinia';
|
||||||
|
|
||||||
import * as KeFuConversationApi from '#/api/mall/promotion/kefu/conversation';
|
import {
|
||||||
|
getConversation,
|
||||||
|
getConversationList,
|
||||||
|
} from '#/api/mall/promotion/kefu/conversation';
|
||||||
|
|
||||||
interface MallKefuInfoVO {
|
interface MallKefuInfoVO {
|
||||||
conversationList: MallKefuConversationApi.Conversation[]; // 会话列表
|
conversationList: MallKefuConversationApi.Conversation[]; // 会话列表
|
||||||
@@ -41,9 +44,7 @@ export const useMallKefuStore = defineStore('mall-kefu', {
|
|||||||
// ======================= 会话相关 =======================
|
// ======================= 会话相关 =======================
|
||||||
/** 加载会话缓存列表 */
|
/** 加载会话缓存列表 */
|
||||||
async setConversationList() {
|
async setConversationList() {
|
||||||
// TODO @jave:idea linter 告警,修复下;
|
this.conversationList = await getConversationList();
|
||||||
// TODO @jave:不使用 KeFuConversationApi.,直接用 getConversationList
|
|
||||||
this.conversationList = await KeFuConversationApi.getConversationList();
|
|
||||||
this.conversationSort();
|
this.conversationSort();
|
||||||
},
|
},
|
||||||
/** 更新会话缓存已读 */
|
/** 更新会话缓存已读 */
|
||||||
@@ -51,8 +52,11 @@ export const useMallKefuStore = defineStore('mall-kefu', {
|
|||||||
if (isEmpty(this.conversationList)) {
|
if (isEmpty(this.conversationList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const conversation = this.conversationList.find(
|
const conversationList = this
|
||||||
(item) => item.id === conversationId,
|
.conversationList as MallKefuConversationApi.Conversation[];
|
||||||
|
const conversation = conversationList.find(
|
||||||
|
(item: MallKefuConversationApi.Conversation) =>
|
||||||
|
item.id === conversationId,
|
||||||
);
|
);
|
||||||
conversation && (conversation.adminUnreadMessageCount = 0);
|
conversation && (conversation.adminUnreadMessageCount = 0);
|
||||||
},
|
},
|
||||||
@@ -62,10 +66,16 @@ export const useMallKefuStore = defineStore('mall-kefu', {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const conversation =
|
const conversation = await getConversation(conversationId);
|
||||||
await KeFuConversationApi.getConversation(conversationId);
|
|
||||||
this.deleteConversation(conversationId);
|
this.deleteConversation(conversationId);
|
||||||
conversation && this.conversationList.push(conversation);
|
if (conversation && this.conversationList) {
|
||||||
|
const conversationList = this
|
||||||
|
.conversationList as MallKefuConversationApi.Conversation[];
|
||||||
|
this.conversationList = [
|
||||||
|
...conversationList,
|
||||||
|
conversation as MallKefuConversationApi.Conversation,
|
||||||
|
];
|
||||||
|
}
|
||||||
this.conversationSort();
|
this.conversationSort();
|
||||||
},
|
},
|
||||||
/** 删除会话缓存 */
|
/** 删除会话缓存 */
|
||||||
|
|||||||
Reference in New Issue
Block a user