UnisKB/ui/src/utils/dynamics-api/shared-api.ts

54 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-06-20 19:14:59 +00:00
import knowledgeWorkspaceApi from '@/api/knowledge/knowledge'
import modelWorkspaceApi from '@/api/model/model'
import toolWorkspaceApi from '@/api/tool/tool'
import sharedWorkspaceApi from '@/api/shared-workspace'
2025-06-24 06:49:09 +00:00
import toolSystemShareApi from '@/api/system-shared/tool'
import modelSystemShareApi from '@/api/system-shared/model'
import knowledgeSystemShareApi from '@/api/system-shared/knowledge'
2025-06-20 19:14:59 +00:00
// 普通 API
const workspaceApiMap = {
knowledge: knowledgeWorkspaceApi,
model: modelWorkspaceApi,
tool: toolWorkspaceApi,
} as any
2025-06-24 06:49:09 +00:00
// 系统分享 API
const systemShareApiMap = {
knowledge: knowledgeSystemShareApi,
model: modelSystemShareApi,
tool: toolSystemShareApi,
} as any
// 资源管理 API
const systemManageApiMap = {
// knowledge: knowledgeWorkspaceApi,
// model: modelWorkspaceApi,
// tool: toolSystemShareApi,
} as any
const data = {
systemShare: systemShareApiMap,
workspace: workspaceApiMap,
systemManage: systemManageApiMap,
}
2025-06-20 19:14:59 +00:00
/** API
2025-06-24 06:49:09 +00:00
* loadSharedApi('knowledge', true,'systemShare')
2025-06-20 19:14:59 +00:00
*/
2025-06-24 06:49:09 +00:00
export function loadSharedApi({
type,
isShared,
systemType,
}: {
type: string
isShared?: boolean | undefined
systemType?: 'systemShare' | 'workspace' | 'systemManage'
}) {
2025-06-20 19:14:59 +00:00
if (isShared) {
// 共享 API
return sharedWorkspaceApi
} else {
2025-06-24 06:49:09 +00:00
return data[systemType || 'workspace'][type]
2025-06-20 19:14:59 +00:00
}
}