refactor: 统一知识库接口公共类型

This commit is contained in:
zxr
2026-07-22 04:55:36 +08:00
parent c2c5afa82d
commit dbda9f76fb
8 changed files with 19 additions and 108 deletions

View File

@@ -1,5 +1,5 @@
import { request } from '@/api/request'
import type { KbReply } from './faq'
import type { KbReply } from './types'
/** 公共分类状态。 */
export type CategoryStatus = 'active' | 'inactive'

View File

@@ -1,5 +1,5 @@
import { request } from '@/api/request'
import type { KbReply } from './faq'
import type { KbReply } from './types'
/** 文档状态。 */
export type DocumentStatus = 'draft' | 'published' | 'reviewed' | 'rejected'

View File

@@ -1,4 +1,9 @@
import { request } from '@/api/request'
import type { KbReply } from './types'
export { fetchCategoryTree as fetchGeneralCategoryTree } from './category'
export type { CategoryTreeNode } from './category'
export type { KbReply } from './types'
/** FAQ 审核状态。 */
export type FaqStatus = 'draft' | 'published' | 'reviewed' | 'rejected'
@@ -7,14 +12,6 @@ export type FaqPriority = 'low' | 'medium' | 'high'
/** FAQ 列表可见范围。 */
export type FaqScope = 'my' | 'all'
/** 知识库服务统一响应。 */
export interface KbReply<T> {
code: number
message: string
details: T
timeseq: number
}
/** FAQ 资源。 */
export interface Faq {
id: number
@@ -96,24 +93,6 @@ export interface UpdateFaqData extends FaqFormData {
id: number
}
/** 公共分类树节点。 */
export interface CategoryTreeNode {
id: number
name: string
description: string
type: 'general'
icon: string
color: string
parent_id: number
level: number
path: string
sort_order: number
status: 'active' | 'inactive'
doc_count: number
faq_count: number
children: CategoryTreeNode[]
}
/** FAQ 状态筛选项。 */
export const faqStatusOptions: Array<{ label: string; value: FaqStatus }> = [
{ label: '草稿', value: 'draft' },
@@ -196,6 +175,3 @@ export const unfavoriteFaq = (id: number) =>
resource_type: 'faq',
resource_id: id,
})
/** 获取公共分类树。 */
export const fetchGeneralCategoryTree = () => request.get<KbReply<CategoryTreeNode[]>>('/Kb/v1/category/tree')

View File

@@ -1,6 +1,7 @@
import { request } from '@/api/request'
import type { Document } from './document'
import type { Faq, KbReply } from './faq'
import type { Faq } from './faq'
import type { KbReply } from './types'
export type ResourceType = 'document' | 'faq'

View File

@@ -1,6 +1,7 @@
import { request } from '@/api/request'
import type { Document } from './document'
import type { Faq, KbReply } from './faq'
import type { Faq } from './faq'
import type { KbReply } from './types'
export type ReviewResourceType = 'all' | 'document' | 'faq'

View File

@@ -1,5 +1,5 @@
import { request } from '@/api/request'
import type { KbReply } from './faq'
import type { KbReply } from './types'
export type TrashResourceType = 'document' | 'faq'

7
src/api/kb/types.ts Normal file
View File

@@ -0,0 +1,7 @@
/** 知识库服务统一响应。 */
export interface KbReply<T> {
code: number
message: string
details: T
timeseq: number
}