fix: 恢复知识库正确版本(纯硬编码+MyDialog)
This commit is contained in:
@@ -173,49 +173,8 @@ const activeTab = ref("knowledge")
|
|||||||
const search = ref("")
|
const search = ref("")
|
||||||
const showDetail = ref(false)
|
const showDetail = ref(false)
|
||||||
const detailItem = ref<any>(null)
|
const detailItem = ref<any>(null)
|
||||||
const loading = ref(true)
|
|
||||||
|
|
||||||
// 从API加载知识库文章
|
|
||||||
const categories = ref<any[]>([])
|
|
||||||
const allArticles = ref<any[]>([])
|
|
||||||
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<string, any[]> = {}
|
|
||||||
for (const a of articles) {
|
|
||||||
const cat = a.category || '其他'
|
|
||||||
if (!groupMap[cat]) groupMap[cat] = []
|
|
||||||
groupMap[cat].push(a)
|
|
||||||
}
|
|
||||||
const catIcons: Record<string, string> = {
|
|
||||||
'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<any[]>([])
|
|
||||||
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",
|
name: "术语解释", icon: "📖", key: "term",
|
||||||
items: [
|
items: [
|
||||||
|
|||||||
Reference in New Issue
Block a user