Commit ee1c0330 authored by nick zheng's avatar nick zheng

fix: 应用AI自动新配置后重置应用预览

parent 208d2056
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { inject, onMounted, onUnmounted, ref } from 'vue'
import Preamble from './preamble.vue' import Preamble from './preamble.vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { Emitter } from 'mitt'
import MessageList from './message-list.vue' import MessageList from './message-list.vue'
import FooterInput from './footer-input.vue' import FooterInput from './footer-input.vue'
import { fetchCreateContinueQuestions } from '@/apis/agent-application' import { fetchCreateContinueQuestions } from '@/apis/agent-application'
...@@ -16,6 +17,8 @@ const router = useRouter() ...@@ -16,6 +17,8 @@ const router = useRouter()
const personalAppConfigStore = usePersonalAppConfigStore() const personalAppConfigStore = usePersonalAppConfigStore()
const emitter = inject<Emitter<MittEvents>>('emitter')
const messageListRef = ref<InstanceType<typeof MessageList> | null>(null) const messageListRef = ref<InstanceType<typeof MessageList> | null>(null)
const footerInputRef = ref<InstanceType<typeof FooterInput> | null>(null) const footerInputRef = ref<InstanceType<typeof FooterInput> | null>(null)
...@@ -27,6 +30,17 @@ const continuousQuestionList = ref<string[]>([]) ...@@ -27,6 +30,17 @@ const continuousQuestionList = ref<string[]>([])
const isShowMemoryPreviewModal = ref(false) const isShowMemoryPreviewModal = ref(false)
const selectedMemoryTabName = ref('memoryVariable') const selectedMemoryTabName = ref('memoryVariable')
onMounted(() => {
emitter?.on('resetAgent', () => {
footerInputRef.value?.blockMessageResponse()
messageList.value = []
})
})
onUnmounted(() => {
emitter?.off('resetAgent')
})
function handleAddMessageItem(messageItem: ConversationMessageItem) { function handleAddMessageItem(messageItem: ConversationMessageItem) {
messageList.value.push(messageItem) messageList.value.push(messageItem)
} }
......
...@@ -103,6 +103,7 @@ onMounted(async () => { ...@@ -103,6 +103,7 @@ onMounted(async () => {
onUnmounted(() => { onUnmounted(() => {
handleStopGenerate() handleStopGenerate()
emitter?.off('isGetAgentDetail')
}) })
const handleSavePersonalAppConfig = useThrottleFn( const handleSavePersonalAppConfig = useThrottleFn(
...@@ -251,6 +252,7 @@ async function handleSettingAgent(autoConfigInputValue: string) { ...@@ -251,6 +252,7 @@ async function handleSettingAgent(autoConfigInputValue: string) {
handleAIGenerateAgentSystem(), handleAIGenerateAgentSystem(),
]).finally(() => { ]).finally(() => {
isFullScreenLoading.value = false isFullScreenLoading.value = false
emitter?.emit('resetAgent')
}) })
}) })
.catch(() => { .catch(() => {
......
declare type MittEvents = { declare type MittEvents = {
selectQuestion: string selectQuestion: string
isGetAgentDetail: void isGetAgentDetail: void
resetAgent: void
} }
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 to comment