Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/presenter/knowledgePresenter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ export class KnowledgePresenter implements IKnowledgePresenter {
this.storePresenterCache.clear()
}

/**
* @returns return true if user confirmed to destroy knowledge, otherwise false
*/
async beforeDestroy(): Promise<boolean> {
const status = this.taskP.getStatus()
if (status.totalTasks === 0) {
Expand All @@ -326,9 +329,6 @@ export class KnowledgePresenter implements IKnowledgePresenter {
return choice === 'confirm'
}

/**
* @returns return true if user confirmed to destroy knowledge, otherwise false
*/
async destroy(): Promise<void> {
await this.closeAll()
}
Expand Down
38 changes: 33 additions & 5 deletions src/renderer/src/components/settings/BuiltinKnowledgeSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@
</template>

<script setup lang="ts">
import { ref, onMounted, toRaw, computed, watch } from 'vue'
import { ref, onMounted, toRaw, computed, watch, onUnmounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { Icon } from '@iconify/vue'
import { Button } from '@/components/ui/button'
Expand Down Expand Up @@ -862,10 +862,6 @@ const loadBuiltinConfigFromMcp = async () => {
}
}

onMounted(async () => {
await loadBuiltinConfigFromMcp()
})

const route = useRoute()

// 监听URL查询参数,设置活动标签页
Expand All @@ -878,4 +874,36 @@ watch(
},
{ immediate: true }
)

// 监听MCP全局状态变化
watch(
() => mcpStore.mcpEnabled,
async (enabled) => {
if (!enabled && isBuiltinMcpEnabled.value) {
await mcpStore.toggleServer('builtinKnowledge')
}
}
)

// 组件挂载时加载配置
let unwatch: (() => void) | undefined
onMounted(async () => {
unwatch = watch(
() => mcpStore.config.ready,
async (ready) => {
if (ready) {
unwatch?.() // only run once to avoid multiple calls
await loadBuiltinConfigFromMcp()
}
},
{ immediate: true }
)
})

// cancel the watch to avoid memory leaks
onUnmounted(() => {
if (unwatch) {
unwatch?.()
}
})
</script>