feat
This commit is contained in:
@@ -318,7 +318,6 @@ import {
|
||||
moveToTrash,
|
||||
favoriteDocument,
|
||||
unfavoriteDocument,
|
||||
checkFavorite,
|
||||
} from '@/api/kb/document'
|
||||
import { fetchCategoryList } from '@/api/kb/category'
|
||||
import { documentTypeOptions } from './config/options'
|
||||
@@ -454,12 +453,15 @@ const fetchData = async () => {
|
||||
const loadCategories = async () => {
|
||||
try {
|
||||
const res: any = await fetchCategoryList({ type: 'document' })
|
||||
if (res?.code === 0) {
|
||||
categoryOptions.value = res.details.data.map((item: any) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}))
|
||||
// 兼容多种API响应格式
|
||||
let categoryList: any[] = []
|
||||
if (res?.code === 0 && Array.isArray(res.details)) {
|
||||
categoryList = res.details
|
||||
}
|
||||
categoryOptions.value = categoryList.map((item: any) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}))
|
||||
} catch (error) {
|
||||
console.error('加载分类失败:', error)
|
||||
}
|
||||
@@ -501,15 +503,8 @@ const handleSelectDocument = async (doc: Document) => {
|
||||
const docData = res.details.resource || res.details
|
||||
currentDocument.value = docData
|
||||
|
||||
// 检查收藏状态
|
||||
if (docData.status === 'reviewed') {
|
||||
try {
|
||||
const favRes: any = await checkFavorite(doc.id)
|
||||
isFavorited.value = favRes?.details?.is_favorited || false
|
||||
} catch {
|
||||
isFavorited.value = false
|
||||
}
|
||||
}
|
||||
// 从文档详情中获取收藏状态
|
||||
isFavorited.value = docData.is_favorited || false
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取文档详情失败:', error)
|
||||
|
||||
Reference in New Issue
Block a user