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

This commit is contained in:
cherishsince 2024-05-16 23:20:44 +08:00
parent 6fc5f8c685
commit 7ab9aa77b8

View File

@ -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) // 角色仓库抽屉
// 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 = () => {
/** /**
* 对话 - 点击 * 对话 - 点击
*/ */
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) => {
message.success('会话已删除') message.success('会话已删除')
// //
await getChatConversationList() await getChatConversationList()
//
emits('onConversationDelete', conversation)
} catch { } catch {
} }
} }
@ -276,10 +278,16 @@ const handleClearConversation = async () => {
// ============ onMounted // ============ onMounted
onMounted(async () => { const { activeId } = toRefs(props)
// watch(activeId, async (newValue, oldValue) => {
if (props.activeId != null) { //
activeConversationId.value = newValue as string
})
onMounted(async () => {
//
if (props.activeId != null) {
activeConversationId.value = props.activeId
} }
// //
await getChatConversationList() await getChatConversationList()