Commit 7ab9aa77 by cherishsince

【增加】Chat 对话增加更新选中

parent 6fc5f8c6
...@@ -87,7 +87,7 @@ const message = useMessage() // 消息弹窗 ...@@ -87,7 +87,7 @@ const message = useMessage() // 消息弹窗
// 定义属性 // 定义属性
const searchName = ref<string>('') // 对话搜索 const searchName = ref<string>('') // 对话搜索
const activeConversationId = ref<number | null>(null) // 选中的对话,默认为 null const activeConversationId = ref<string | null>(null) // 选中的对话,默认为 null
const conversationList = ref([] as ChatConversationVO[]) // 对话列表 const conversationList = ref([] as ChatConversationVO[]) // 对话列表
const conversationMap = ref<any>({}) // 对话分组 (置顶、今天、三天前、一星期前、一个月前) const conversationMap = ref<any>({}) // 对话分组 (置顶、今天、三天前、一星期前、一个月前)
const drawer = ref<boolean>(false) // 角色仓库抽屉 const drawer = ref<boolean>(false) // 角色仓库抽屉
...@@ -95,13 +95,13 @@ const drawer = ref<boolean>(false) // 角色仓库抽屉 ...@@ -95,13 +95,13 @@ const drawer = ref<boolean>(false) // 角色仓库抽屉
// 定义组件 props // 定义组件 props
const props = defineProps({ const props = defineProps({
activeId: { activeId: {
type: Number || null, type: String || null,
required: true required: true
} }
}) })
// 定义钩子 // 定义钩子
const emits = defineEmits(['onConversationClick', 'onConversationClear']) const emits = defineEmits(['onConversationClick', 'onConversationClear', 'onConversationDelete'])
/** /**
* 对话 - 搜索 * 对话 - 搜索
...@@ -113,7 +113,7 @@ const searchConversation = () => { ...@@ -113,7 +113,7 @@ const searchConversation = () => {
/** /**
* 对话 - 点击 * 对话 - 点击
*/ */
const handleConversationClick = async (id: number) => { const handleConversationClick = async (id: string) => {
// 切换对话 // 切换对话
activeConversationId.value = id activeConversationId.value = id
const filterConversation = conversationList.value.filter(item => { const filterConversation = conversationList.value.filter(item => {
...@@ -227,6 +227,8 @@ const deleteChatConversation = async (conversation: ChatConversationVO) => { ...@@ -227,6 +227,8 @@ const deleteChatConversation = async (conversation: ChatConversationVO) => {
message.success('会话已删除') message.success('会话已删除')
// 刷新列表 // 刷新列表
await getChatConversationList() await getChatConversationList()
// 回调
emits('onConversationDelete', conversation)
} catch { } catch {
} }
} }
...@@ -276,10 +278,16 @@ const handleClearConversation = async () => { ...@@ -276,10 +278,16 @@ const handleClearConversation = async () => {
// ============ 组件 onMounted // ============ 组件 onMounted
const { activeId } = toRefs(props)
watch(activeId, async (newValue, oldValue) => {
// 更新选中
activeConversationId.value = newValue as string
})
onMounted(async () => { onMounted(async () => {
// // 默认选中
if (props.activeId != null) { if (props.activeId != null) {
activeConversationId.value = props.activeId
} }
// 获取 对话列表 // 获取 对话列表
await getChatConversationList() await getChatConversationList()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment