From 5375d44452bcfd2d039feb83d0f8dd0f1453e74c Mon Sep 17 00:00:00 2001 From: lipenghui Date: Fri, 2 Feb 2024 11:17:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E8=A7=92=E8=89=B2modelTy?= =?UTF-8?q?oe=E5=AD=97=E6=AE=B5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/base/message.ts | 4 ++-- src/components/AppRoleDefault/index.d.ts | 2 +- src/views/role/index.vue | 22 +++++++++++++--------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/api/base/message.ts b/src/api/base/message.ts index c161226..8910284 100644 --- a/src/api/base/message.ts +++ b/src/api/base/message.ts @@ -40,9 +40,9 @@ export async function removeMessage(ids: string) { /** * @description 对话列表 */ -export async function conversationList(type: number) { +export async function conversationList(menuType: number) { return defHttp.get({ - url: `/open-chat/chat/conversation/list?type=${type}`, + url: `/open-chat/chat/conversation/list?type=${menuType}`, }) } diff --git a/src/components/AppRoleDefault/index.d.ts b/src/components/AppRoleDefault/index.d.ts index 5fe7c68..781a89a 100644 --- a/src/components/AppRoleDefault/index.d.ts +++ b/src/components/AppRoleDefault/index.d.ts @@ -9,7 +9,7 @@ export interface RoleData { } interface RoleInfoAppModel { - id: number + id: string roleName: string roleType: string roleInfo: string diff --git a/src/views/role/index.vue b/src/views/role/index.vue index d1b8217..e23fb06 100644 --- a/src/views/role/index.vue +++ b/src/views/role/index.vue @@ -129,12 +129,16 @@ async function handleSubMenuChange(index: number, item?: SubMenuItem) { historyMessageParams.value.total = 0 messageStore.setConversationData(subMenuList.value[subMenuActiveIndex.value]) messageStore.setMessageClear() - const modelIdx = modelOptions.findIndex(v => v.value === Number(subMenuList.value[subMenuActiveIndex.value].modelType)) - if (modelIdx === -1) { - message.warn('未找到该对话下的模型信息') - return + if (subMenuActiveIndex.value !== -1) { + const modelIdx = modelOptions.findIndex((v) => { + return v.value === Number(subMenuList.value[subMenuActiveIndex.value].modelType) + }) + if (modelIdx === -1) { + message.warn('未找到该对话下的模型信息') + return + } + modelIndex.value = modelIdx } - modelIndex.value = modelIdx useMqtt().end() useMqtt().connect() @@ -324,9 +328,9 @@ async function handleRole(item: RoleData) { * @description: 选择应用 */ async function handleApply(item: RoleInfoAppModel) { - const obj = subMenuList.value.find(v => v.roleId === item.id) + const obj = subMenuList.value.find(v => String(v.roleId) === item.id) if (obj) { - const index = subMenuList.value.findIndex(v => v.roleId === item.id) + const index = subMenuList.value.findIndex(v => String(v.roleId) === item.id) await handleSubMenuChange(index) getHistoryMessage() } @@ -334,13 +338,13 @@ async function handleApply(item: RoleInfoAppModel) { await addMessage({ type: MenuTypeEnum.ROLE, title: item.roleName, - roleId: String(item.id), + roleId: item.id, sort: subMenuList.value.length + 1, modelType: item.modelType ? item.modelType : ModelTypeEnum.GPT3, }) await getConversationList() await nextTick() - const index = subMenuList.value.findIndex(v => v.roleId === item.id) + const index = subMenuList.value.findIndex(v => String(v.roleId) === item.id) subMenuActiveIndex.value = index await handleSubMenuChange(index) getHistoryMessage()