diff --git a/src/api/base/message.ts b/src/api/base/message.ts index 8910284..0e5559f 100644 --- a/src/api/base/message.ts +++ b/src/api/base/message.ts @@ -11,6 +11,7 @@ export async function addMessage(data: { sort: number roleId?: string modelType: ModelTypeEnum + contextCount?: number | null // 携带上下文数量 }) { return defHttp.post({ url: `/open-chat/chat/conversation/save`, diff --git a/src/components/AppRoleDefault/index.d.ts b/src/components/AppRoleDefault/index.d.ts index 781a89a..4606952 100644 --- a/src/components/AppRoleDefault/index.d.ts +++ b/src/components/AppRoleDefault/index.d.ts @@ -6,6 +6,7 @@ export interface RoleData { remark: string type: number modelType: number + contextCount: number | null } interface RoleInfoAppModel { @@ -16,6 +17,7 @@ interface RoleInfoAppModel { roleImg: string type: number modelType: number + contextCount: number | null } export interface AppGroup { diff --git a/src/components/AppRoleDefault/index.vue b/src/components/AppRoleDefault/index.vue index 07ca7d1..beb005b 100644 --- a/src/components/AppRoleDefault/index.vue +++ b/src/components/AppRoleDefault/index.vue @@ -13,6 +13,8 @@ const typeIndex = ref(0) // 角色 function getRoleData() { getRole(1).then((res) => { + console.log('角色', res) + roleList.value = res }) } @@ -20,6 +22,7 @@ getRoleData() // 应用 function getAppData() { getAppList().then((res) => { + console.log('应用', res) application.value = res }) } diff --git a/src/components/AppSubMenuList/index.vue b/src/components/AppSubMenuList/index.vue index e6f1e0f..73f17aa 100644 --- a/src/components/AppSubMenuList/index.vue +++ b/src/components/AppSubMenuList/index.vue @@ -79,7 +79,7 @@ function handleBlur(index: number, item: SubMenuItem, inputValue?: string) { {{ item.title }} </p> <p class="content truncate"> - {{ item.content }} + {{ item.firstMsg }} </p> <div class="actions absolute"> <SvgIcon diff --git a/src/store/moules/messageStore/index.d.ts b/src/store/moules/messageStore/index.d.ts index d2681ba..ad4a815 100644 --- a/src/store/moules/messageStore/index.d.ts +++ b/src/store/moules/messageStore/index.d.ts @@ -17,9 +17,10 @@ export interface ConversationData { updateTime: string updateUser: string userId: string - content: string actionType: SubMenuActionEnum modelType: string + contextCount: number | null // 上下文数量 + firstMsg: string } export interface MessageStoreType { diff --git a/src/views/conversation/index.vue b/src/views/conversation/index.vue index 99ed242..ff58663 100644 --- a/src/views/conversation/index.vue +++ b/src/views/conversation/index.vue @@ -156,10 +156,10 @@ async function handleSend(value: string) { try { spinning.value = true messageStore.setMessageClear() - await addMessage({ type: MenuTypeEnum.TEXT_TO_TEXT, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value }) + const conversationId = await addMessage({ type: MenuTypeEnum.TEXT_TO_TEXT, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value }) await getConversationList() await nextTick() - subMenuActiveIndex.value = subMenuList.value.length - 1 + subMenuActiveIndex.value = subMenuList.value.findIndex(v => v.id === conversationId) await handleSubMenuChange(subMenuActiveIndex.value) if (!conversationData.value) { message.error('对话发送,请稍后重试!') diff --git a/src/views/conversationNet/index.vue b/src/views/conversationNet/index.vue index 3031c76..6d756dc 100644 --- a/src/views/conversationNet/index.vue +++ b/src/views/conversationNet/index.vue @@ -156,10 +156,10 @@ async function handleSend(value: string) { try { spinning.value = true messageStore.setMessageClear() - await addMessage({ type: MenuTypeEnum.CONVERSATION_NET, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value }) + const conversationId = await addMessage({ type: MenuTypeEnum.CONVERSATION_NET, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value }) await getConversationList() await nextTick() - subMenuActiveIndex.value = subMenuList.value.length - 1 + subMenuActiveIndex.value = subMenuList.value.findIndex(v => v.id === conversationId) await handleSubMenuChange(subMenuActiveIndex.value) if (!conversationData.value) { message.error('对话发送,请稍后重试!') diff --git a/src/views/repository/index.vue b/src/views/repository/index.vue index 46d39d7..04c868c 100644 --- a/src/views/repository/index.vue +++ b/src/views/repository/index.vue @@ -175,10 +175,10 @@ async function handleSend(value: string) { try { spinning.value = true messageStore.setMessageClear() - await addMessage({ type: MenuTypeEnum.REPOSITORY, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value }) + const conversationId = await addMessage({ type: MenuTypeEnum.REPOSITORY, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value }) await getConversationList() await nextTick() - subMenuActiveIndex.value = subMenuList.value.length - 1 + subMenuActiveIndex.value = subMenuList.value.findIndex(v => v.id === conversationId) await handleSubMenuChange(subMenuActiveIndex.value) if (!conversationData.value) { message.error('对话发送,请稍后重试!') diff --git a/src/views/role/index.vue b/src/views/role/index.vue index e23fb06..8b234ba 100644 --- a/src/views/role/index.vue +++ b/src/views/role/index.vue @@ -308,17 +308,24 @@ async function handleRole(item: RoleData) { getHistoryMessage() } else { - await addMessage({ + const conversationId = await addMessage({ type: MenuTypeEnum.ROLE, title: item.roleName, roleId: item.id, sort: subMenuList.value.length + 1, modelType: item.modelType ? item.modelType : ModelTypeEnum.GPT3, + contextCount: item.contextCount, }) await getConversationList() await nextTick() const index = subMenuList.value.findIndex(v => String(v.roleId) === item.id) - subMenuActiveIndex.value = index + if (index === -1) { + subMenuActiveIndex.value = subMenuList.value.findIndex(v => v.id === conversationId) + } + else { + subMenuActiveIndex.value = index + } + await handleSubMenuChange(index) getHistoryMessage() } @@ -335,17 +342,23 @@ async function handleApply(item: RoleInfoAppModel) { getHistoryMessage() } else { - await addMessage({ + const conversationId = await addMessage({ type: MenuTypeEnum.ROLE, title: item.roleName, roleId: item.id, sort: subMenuList.value.length + 1, modelType: item.modelType ? item.modelType : ModelTypeEnum.GPT3, + contextCount: item.contextCount, }) await getConversationList() await nextTick() const index = subMenuList.value.findIndex(v => String(v.roleId) === item.id) - subMenuActiveIndex.value = index + if (index === -1) { + subMenuActiveIndex.value = subMenuList.value.findIndex(v => v.id === conversationId) + } + else { + subMenuActiveIndex.value = index + } await handleSubMenuChange(index) getHistoryMessage() } diff --git a/src/views/textToImage/index.vue b/src/views/textToImage/index.vue index f7d1f0f..338cf3e 100644 --- a/src/views/textToImage/index.vue +++ b/src/views/textToImage/index.vue @@ -160,10 +160,10 @@ async function handleSend(value: string) { try { spinning.value = true messageStore.setMessageClear() - await addMessage({ type: MenuTypeEnum.TEXT_TO_IMAGE, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value }) + const conversationId = await addMessage({ type: MenuTypeEnum.TEXT_TO_IMAGE, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value }) await nextTick() await getConversationList() - subMenuActiveIndex.value = subMenuList.value.length - 1 + subMenuActiveIndex.value = subMenuList.value.findIndex(v => v.id === conversationId) await handleSubMenuChange(subMenuActiveIndex.value) if (!conversationData.value) { return diff --git a/src/views/visualAnalysis/index.vue b/src/views/visualAnalysis/index.vue index 12d63f9..7a57a5a 100644 --- a/src/views/visualAnalysis/index.vue +++ b/src/views/visualAnalysis/index.vue @@ -160,10 +160,10 @@ async function handleSend(value: string, fileUrl: string) { try { spinning.value = true messageStore.setMessageClear() - await addMessage({ type: MenuTypeEnum.VISUAL_ANALYSIS, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value }) + const conversationId = await addMessage({ type: MenuTypeEnum.VISUAL_ANALYSIS, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value }) await getConversationList() await nextTick() - subMenuActiveIndex.value = subMenuList.value.length - 1 + subMenuActiveIndex.value = subMenuList.value.findIndex(v => v.id === conversationId) await handleSubMenuChange(subMenuActiveIndex.value) if (!conversationData.value) { message.error('对话发送,请稍后重试!')