diff --git a/frontend/src/views/CMAKnowledge.vue b/frontend/src/views/CMAKnowledge.vue index 8f489373..50374623 100644 --- a/frontend/src/views/CMAKnowledge.vue +++ b/frontend/src/views/CMAKnowledge.vue @@ -173,49 +173,8 @@ const activeTab = ref("knowledge") const search = ref("") const showDetail = ref(false) const detailItem = ref(null) -const loading = ref(true) - -// 从API加载知识库文章 -const categories = ref([]) -const allArticles = ref([]) -async function loadArticles() { - try { - const { knowledgeArticleApi } = await import('../api/index') - const r: any = await knowledgeArticleApi.list() - const articles = r.data || r || [] - allArticles.value = articles - // 按category分组 - const groupMap: Record = {} - for (const a of articles) { - const cat = a.category || '其他' - if (!groupMap[cat]) groupMap[cat] = [] - groupMap[cat].push(a) - } - const catIcons: Record = { - 'CMA完整文档': '📘', '管理会计方法': '📊', 'KPI设定': '🎯', - 'OKR': '📋', '其他': '📄', - } - categories.value = Object.entries(groupMap).map(([key, items]) => ({ - name: key, icon: catIcons[key] || '📄', key, items, - })) - } catch (e) { - console.error('加载知识库失败', e) - } - loading.value = false -} - - // 搜索 - const searchResults = ref([]) - watch(search, (val) => { - if (!val) { searchResults.value = []; return } - const kw = val.toLowerCase() - searchResults.value = allArticles.value.filter((a: any) => - (a.title || '').toLowerCase().includes(kw) || (a.category || '').toLowerCase().includes(kw) - ) - }) - -const renderedContent = computed(() => detailItem.value?.content || '') +const categories = ref([ { name: "术语解释", icon: "📖", key: "term", items: [