优化: AI Chat全栈多批审查修复与架构清理(risk_level清理/路由解耦/工具渲染/测试补测/死代码)

This commit is contained in:
2026-06-18 22:57:19 +08:00
parent 0ca5d9805f
commit a2871a66e0
87 changed files with 5720 additions and 3012 deletions

View File

@@ -68,7 +68,7 @@
<span class="kn-card-title">{{ item.title }}</span>
<span class="kn-card-status" :class="'st-' + item.status">{{ statusLabel(item.status) }}</span>
</div>
<div class="kn-card-desc">{{ item.content }}</div>
<div class="kn-card-desc">{{ stripMd(item.content) }}</div>
<div class="kn-card-meta">
<span class="meta-kind">{{ kindLabel(item.kind) }}</span>
<span v-if="item.confidence" :class="'conf-' + item.confidence">{{ confidenceLabel(item.confidence) }}</span>
@@ -238,10 +238,11 @@
</template>
<script setup lang="ts">
import { ref, computed, onMounted, watch } from 'vue'
import { ref, computed, onMounted, onUnmounted, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useKnowledgeStore, KNOWLEDGE_KINDS, parseTags } from '@/stores/knowledge'
import { useRendered } from '@/composables/useMarkdown'
import { stripMd } from '@/utils/markdown'
import type { KnowledgeDetailPayload, KnowledgeEventRecord } from '@/api/types'
const { t } = useI18n()
@@ -277,6 +278,15 @@ function onSearchInput() {
}, 300)
}
// 组件卸载清搜索 debounce timer:防卸载后 300ms 内 timer 触发,向单例 store 写入
// 已离开视图的搜索结果/列表(污染下次进入时的列表态)。对齐 Settings.vue toast timer 清理模式。
onUnmounted(() => {
if (searchTimer) {
clearTimeout(searchTimer)
searchTimer = null
}
})
function switchTopTab(tab: 'library' | 'inbox') {
topTab.value = tab
selectedId.value = null
@@ -422,7 +432,9 @@ function parseContext(e: KnowledgeEventRecord): Record<string, any> {
}
function refConvTitle(e: KnowledgeEventRecord): string {
return parseContext(e).conv_title || parseContext(e).conv_id || ''
// 解析一次复用:原两次 parseContext 调用会重复 JSON.parse,引用列表项越多浪费越大
const ctx = parseContext(e)
return ctx.conv_title || ctx.conv_id || ''
}
function refQuery(e: KnowledgeEventRecord): string {
return parseContext(e).query || ''