123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688 |
- import type { Fetcher } from 'swr'
- import { del, download, get, patch, post, put, upload } from './base'
- import type {
- AccountIntegrate,
- ApiBasedExtension,
- CodeBasedExtension,
- CommonResponse,
- DataSourceNotion,
- FileUploadConfigResponse,
- ICurrentWorkspace,
- IWorkspace,
- InitValidateStatusResponse,
- InvitationResponse,
- LangGeniusVersionResponse,
- Member,
- ModerateResponse,
- OauthResponse,
- PluginProvider,
- Provider,
- ProviderAnthropicToken,
- ProviderAzureToken,
- SetupStatusResponse,
- UserProfileOriginResponse,
- } from '@/models/common'
- import type {
- UpdateOpenAIKeyResponse,
- ValidateOpenAIKeyResponse,
- } from '@/models/app'
- import type {
- DefaultModelResponse,
- Model,
- ModelItem,
- ModelLoadBalancingConfig,
- ModelParameterRule,
- ModelProvider,
- ModelTypeEnum,
- } from '@/app/components/header/account-setting/model-provider-page/declarations'
- import type { RETRIEVE_METHOD } from '@/types/app'
- import type { SystemFeatures } from '@/types/feature'
- type LoginSuccess = {
- result: 'success'
- data: { access_token: string; refresh_token: string }
- }
- type LoginFail = {
- result: 'fail'
- data: string
- code: string
- message: string
- }
- type LoginResponse = LoginSuccess | LoginFail
- export const login: Fetcher<LoginResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
- return post(url, { body }) as Promise<LoginResponse>
- }
- export const fetchNewToken: Fetcher<CommonResponse & { data: { access_token: string; refresh_token: string } }, { body: Record<string, any> }> = ({ body }) => {
- return post('/refresh-token', { body }) as Promise<CommonResponse & { data: { access_token: string; refresh_token: string } }>
- }
- export const setup: Fetcher<CommonResponse, { body: Record<string, any> }> = ({ body }) => {
- return post<CommonResponse>('/setup', { body })
- }
- export const initValidate: Fetcher<CommonResponse, { body: Record<string, any> }> = ({ body }) => {
- return post<CommonResponse>('/init', { body })
- }
- export const fetchInitValidateStatus = () => {
- return get<InitValidateStatusResponse>('/init')
- }
- export const fetchSetupStatus = () => {
- return get<SetupStatusResponse>('/setup')
- }
- export const fetchUserProfile: Fetcher<UserProfileOriginResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
- return get<UserProfileOriginResponse>(url, params, { needAllResponseContent: true })
- }
- export const updateUserProfile: Fetcher<CommonResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
- return post<CommonResponse>(url, { body })
- }
- export const logout: Fetcher<CommonResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
- return get<CommonResponse>(url, params)
- }
- export const fetchLanggeniusVersion: Fetcher<LangGeniusVersionResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
- return get<LangGeniusVersionResponse>(url, { params })
- }
- export const oauth: Fetcher<OauthResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
- return get<OauthResponse>(url, { params })
- }
- export const oneMoreStep: Fetcher<CommonResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
- return post<CommonResponse>(url, { body })
- }
- export const fetchMembers: Fetcher<{ accounts: Member[] | null }, { url: string; params: Record<string, any> }> = ({ url, params }) => {
- return get<{ accounts: Member[] | null }>(url, { params })
- }
- export const fetchTypes = ({ url, params }: any) => {
- console.log('查询类型列表')
- return get(url, { params })
- // return new Promise((resolve) => {
- // setTimeout(() => {
- // const arr: any = []
- // for (let i = 1; i < 10; i++) {
- // arr.push({
- // id: i,
- // name: `类型${i}`,
- // relation: i % 2,
- // })
- // }
- // resolve({
- // data: arr,
- // })
- // }, 1000)
- // })
- }
- export const fetchKnowledges = ({ url, params }: any) => {
- console.log('查询知识服务', params, url)
- return get(url, { params })
- // return new Promise((resolve) => {
- // setTimeout(() => {
- // const arr: any = []
- // for (let i = 1; i < 10; i++) {
- // arr.push({
- // id: i,
- // serviceType: i % 3 + 1,
- // serviceName: `深圳口岸服务网${i}`,
- // url: '74.10.28.118',
- // status: i % 2,
- // time: '2021-09-22 14:22:22',
- // })
- // }
- // resolve({
- // data: arr,
- // })
- // }, 1000)
- // })
- }
- export const fetchMoulds = ({ url, params }: any) => {
- console.log('查询知识库模板', params, url)
- return get<{ accounts: Member[] | null }>(url, { params })
- // return new Promise((resolve) => {
- // setTimeout(() => {
- // const arr: any = []
- // for (let i = 1; i < 2; i++) {
- // // /files/7be8a2ca-a633-473c-8bcf-b73ee9fd7738/file-preview?timestamp=1744947616&nonce=a4107f3e163bbb0da255914e2ccabaf3&sign=H82Wk2VbWjXXEyzRUhGyNQlR-PG8NEGy5ijCEF0IKgo=
- // arr.push({
- // id: '7be8a2ca-a633-473c-8bcf-b73ee9fd7738',
- // fileName: `文件${i}.doc`,
- // })
- // }
- // resolve({
- // data: arr,
- // })
- // }, 1000)
- // })
- }
- export const fetchProviders: Fetcher<Provider[] | null, { url: string; params: Record<string, any> }> = ({ url, params }) => {
- return get<Provider[] | null>(url, { params })
- }
- export const validateProviderKey: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: { token: string } }> = ({ url, body }) => {
- return post<ValidateOpenAIKeyResponse>(url, { body })
- }
- export const updateProviderAIKey: Fetcher<UpdateOpenAIKeyResponse, { url: string; body: { token: string | ProviderAzureToken | ProviderAnthropicToken } }> = ({ url, body }) => {
- return post<UpdateOpenAIKeyResponse>(url, { body })
- }
- export const fetchAccountIntegrates: Fetcher<{ data: AccountIntegrate[] | null }, { url: string; params: Record<string, any> }> = ({ url, params }) => {
- return get<{ data: AccountIntegrate[] | null }>(url, { params })
- }
- export const inviteMember: Fetcher<InvitationResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
- return post<InvitationResponse>(url, { body })
- }
- export const updateMemberRole: Fetcher<CommonResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
- return put<CommonResponse>(url, { body })
- }
- export const deleteMemberOrCancelInvitation: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
- return del<CommonResponse>(url)
- }
- export const addType = ({ url, body }: any) => {
- console.log('新增类型', url, body)
- return post(url, { body })
- }
- export const editType = ({ url, body }: any) => {
- console.log('编辑类型', url, body)
- return patch(url, { body })
- }
- export const delType = ({ url, body }: any) => {
- console.log('删除类型', url, body)
- return del(url, { body })
- }
- export const addKnowledge = ({ url, body }: any) => {
- console.log('新增知识', body, url)
- return post(url, { body })
- }
- export const editKnowledge = ({ url, body }: any) => {
- console.log('编辑知识', body, url)
- return patch(url, { body })
- }
- export const delKnowledge = ({ url, body }: any) => {
- console.log('删除知识', url, body)
- return del(url, { body })
- }
- export const addMouldFile = ({ url, body }: any) => {
- console.log('新增模板文件', body, url)
- return upload({
- xhr: new XMLHttpRequest(),
- data: body,
- }, false, url)
- }
- export const delMouldFile = ({ url, body }: any) => {
- console.log('删除模板文件', url)
- return del(url)
- }
- export const downloadMouldFile = ({ url, fileName }: any) => {
- console.log('下载模板文件', url, fileName)
- return download(url, {}, { fileName })
- }
- export const handleExamine = ({ url, body }: any) => {
- // return post<InvitationResponse>(url, { body })
- console.log('处理上下线审核', body)
- return new Promise((resolve) => {
- setTimeout(() => {
- resolve({
- result: 'success',
- })
- }, 1000)
- })
- }
- export const applyExamine = ({ url, body }: any) => {
- // return post<InvitationResponse>(url, { body })
- console.log('提交上下线审核', body)
- return new Promise((resolve) => {
- setTimeout(() => {
- resolve({
- result: 'success',
- })
- }, 1000)
- })
- }
- export const fetchFilePreview: Fetcher<{ content: string }, { fileID: string }> = ({ fileID }) => {
- return get<{ content: string }>(`/files/${fileID}/preview`)
- }
- export const fetchCurrentWorkspace: Fetcher<ICurrentWorkspace, { url: string; params: Record<string, any> }> = ({ url, params }) => {
- return get<ICurrentWorkspace>(url, { params })
- }
- export const updateCurrentWorkspace: Fetcher<ICurrentWorkspace, { url: string; body: Record<string, any> }> = ({ url, body }) => {
- return post<ICurrentWorkspace>(url, { body })
- }
- export const fetchWorkspaces: Fetcher<{ workspaces: IWorkspace[] }, { url: string; params: Record<string, any> }> = ({ url, params }) => {
- return get<{ workspaces: IWorkspace[] }>(url, { params })
- }
- export const switchWorkspace: Fetcher<CommonResponse & { new_tenant: IWorkspace }, { url: string; body: Record<string, any> }> = ({ url, body }) => {
- return post<CommonResponse & { new_tenant: IWorkspace }>(url, { body })
- }
- export const fetchDataSource: Fetcher<{ data: DataSourceNotion[] }, { url: string }> = ({ url }) => {
- return get<{ data: DataSourceNotion[] }>(url)
- }
- export const syncDataSourceNotion: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
- return get<CommonResponse>(url)
- }
- export const updateDataSourceNotionAction: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
- return patch<CommonResponse>(url)
- }
- export const fetchPluginProviders: Fetcher<PluginProvider[] | null, string> = (url) => {
- return get<PluginProvider[] | null>(url)
- }
- export const validatePluginProviderKey: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: { credentials: any } }> = ({ url, body }) => {
- return post<ValidateOpenAIKeyResponse>(url, { body })
- }
- export const updatePluginProviderAIKey: Fetcher<UpdateOpenAIKeyResponse, { url: string; body: { credentials: any } }> = ({ url, body }) => {
- return post<UpdateOpenAIKeyResponse>(url, { body })
- }
- export const invitationCheck: Fetcher<CommonResponse & { is_valid: boolean; data: { workspace_name: string; email: string; workspace_id: string } }, { url: string; params: { workspace_id?: string; email?: string; token: string } }> = ({ url, params }) => {
- return get<CommonResponse & { is_valid: boolean; data: { workspace_name: string; email: string; workspace_id: string } }>(url, { params })
- }
- export const activateMember: Fetcher<LoginResponse, { url: string; body: any }> = ({ url, body }) => {
- return post<LoginResponse>(url, { body })
- }
- export const fetchModelProviders: Fetcher<{ data: ModelProvider[] }, string> = (url) => {
- return get<{ data: ModelProvider[] }>(url)
- }
- export type ModelProviderCredentials = {
- credentials?: Record<string, string | undefined | boolean>
- load_balancing: ModelLoadBalancingConfig
- }
- export const fetchModelProviderCredentials: Fetcher<ModelProviderCredentials, string> = (url) => {
- return get<ModelProviderCredentials>(url)
- }
- export const fetchModelLoadBalancingConfig: Fetcher<{
- credentials?: Record<string, string | undefined | boolean>
- load_balancing: ModelLoadBalancingConfig
- }, string> = (url) => {
- return get<{
- credentials?: Record<string, string | undefined | boolean>
- load_balancing: ModelLoadBalancingConfig
- }>(url)
- }
- export const fetchModelProviderModelList: Fetcher<{ data: ModelItem[] }, string> = (url) => {
- return get<{ data: ModelItem[] }>(url)
- }
- export const fetchModelList: Fetcher<{ data: Model[] }, string> = (url) => {
- return get<{ data: Model[] }>(url)
- }
- export const validateModelProvider: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: any }> = ({ url, body }) => {
- return post<ValidateOpenAIKeyResponse>(url, { body })
- }
- export const validateModelLoadBalancingCredentials: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: any }> = ({ url, body }) => {
- return post<ValidateOpenAIKeyResponse>(url, { body })
- }
- export const setModelProvider: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
- return post<CommonResponse>(url, { body })
- }
- export const deleteModelProvider: Fetcher<CommonResponse, { url: string; body?: any }> = ({ url, body }) => {
- return del<CommonResponse>(url, { body })
- }
- export const changeModelProviderPriority: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
- return post<CommonResponse>(url, { body })
- }
- export const setModelProviderModel: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
- return post<CommonResponse>(url, { body })
- }
- export const deleteModelProviderModel: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
- return del<CommonResponse>(url)
- }
- export const getPayUrl: Fetcher<{ url: string }, string> = (url) => {
- return get<{ url: string }>(url)
- }
- export const fetchDefaultModal: Fetcher<{ data: DefaultModelResponse }, string> = (url) => {
- return get<{ data: DefaultModelResponse }>(url)
- }
- export const updateDefaultModel: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
- return post<CommonResponse>(url, { body })
- }
- export const fetchModelParameterRules: Fetcher<{ data: ModelParameterRule[] }, string> = (url) => {
- return get<{ data: ModelParameterRule[] }>(url)
- }
- export const fetchFileUploadConfig: Fetcher<FileUploadConfigResponse, { url: string }> = ({ url }) => {
- return get<FileUploadConfigResponse>(url)
- }
- export const fetchNotionConnection: Fetcher<{ data: string }, string> = (url) => {
- return get(url) as Promise<{ data: string }>
- }
- export const fetchDataSourceNotionBinding: Fetcher<{ result: string }, string> = (url) => {
- return get(url) as Promise<{ result: string }>
- }
- export const fetchApiBasedExtensionList: Fetcher<ApiBasedExtension[], string> = (url) => {
- return get(url) as Promise<ApiBasedExtension[]>
- }
- export const fetchApiBasedExtensionDetail: Fetcher<ApiBasedExtension, string> = (url) => {
- return get(url) as Promise<ApiBasedExtension>
- }
- export const addApiBasedExtension: Fetcher<ApiBasedExtension, { url: string; body: ApiBasedExtension }> = ({ url, body }) => {
- return post(url, { body }) as Promise<ApiBasedExtension>
- }
- export const updateApiBasedExtension: Fetcher<ApiBasedExtension, { url: string; body: ApiBasedExtension }> = ({ url, body }) => {
- return post(url, { body }) as Promise<ApiBasedExtension>
- }
- export const deleteApiBasedExtension: Fetcher<{ result: string }, string> = (url) => {
- return del(url) as Promise<{ result: string }>
- }
- export const fetchCodeBasedExtensionList: Fetcher<CodeBasedExtension, string> = (url) => {
- return get(url) as Promise<CodeBasedExtension>
- }
- export const moderate = (url: string, body: { app_id: string; text: string }) => {
- return post(url, { body }) as Promise<ModerateResponse>
- }
- type RetrievalMethodsRes = {
- retrieval_method: RETRIEVE_METHOD[]
- }
- export const fetchSupportRetrievalMethods: Fetcher<RetrievalMethodsRes, string> = (url) => {
- return get<RetrievalMethodsRes>(url)
- }
- export const getSystemFeatures = () => {
- return get<SystemFeatures>('/system-features')
- }
- export const enableModel = (url: string, body: { model: string; model_type: ModelTypeEnum }) =>
- patch<CommonResponse>(url, { body })
- export const disableModel = (url: string, body: { model: string; model_type: ModelTypeEnum }) =>
- patch<CommonResponse>(url, { body })
- export const sendForgotPasswordEmail: Fetcher<CommonResponse & { data: string }, { url: string; body: { email: string } }> = ({ url, body }) =>
- post<CommonResponse & { data: string }>(url, { body })
- export const verifyForgotPasswordToken: Fetcher<CommonResponse & { is_valid: boolean; email: string }, { url: string; body: { token: string } }> = ({ url, body }) => {
- return post(url, { body }) as Promise<CommonResponse & { is_valid: boolean; email: string }>
- }
- export const changePasswordWithToken: Fetcher<CommonResponse, { url: string; body: { token: string; new_password: string; password_confirm: string } }> = ({ url, body }) =>
- post<CommonResponse>(url, { body })
- export const uploadRemoteFileInfo = (url: string, isPublic?: boolean) => {
- return post<{ id: string; name: string; size: number; mime_type: string; url: string }>('/remote-files/upload', { body: { url } }, { isPublicAPI: isPublic })
- }
- export const sendEMailLoginCode = (email: string, language = 'en-US') =>
- post<CommonResponse & { data: string }>('/email-code-login', { body: { email, language } })
- export const emailLoginWithCode = (data: { email: string; code: string; token: string }) =>
- post<LoginResponse>('/email-code-login/validity', { body: data })
- export const sendResetPasswordCode = (email: string, language = 'en-US') =>
- post<CommonResponse & { data: string; message?: string; code?: string }>('/forgot-password', { body: { email, language } })
- export const verifyResetPasswordCode = (body: { email: string; code: string; token: string }) =>
- post<CommonResponse & { is_valid: boolean }>('/forgot-password/validity', { body })
- export const sendDeleteAccountCode = () =>
- get<CommonResponse & { data: string }>('/account/delete/verify')
- export const verifyDeleteAccountCode = (body: { code: string; token: string }) =>
- post<CommonResponse & { is_valid: boolean }>('/account/delete', { body })
- export const submitDeleteAccountFeedback = (body: { feedback: string; email: string }) =>
- post<CommonResponse>('/account/delete/feedback', { body })
- export const getDocDownloadUrl = (doc_name: string) =>
- get<{ url: string }>('/compliance/download', { params: { doc_name } }, { silent: true })
- export const fetchStatistic = ({ url, params }: any) => {
- console.log('查询知识总览', url, params)
- return get(url, { params })
- }
- export const fetchLog = ({ url, params }: any) => {
- console.log('查询训练日志列表', url, params)
- // return get(url, { params })
- return new Promise((resolve) => {
- setTimeout(() => {
- const arr: any = []
- for (let i = 1; i < 10; i++) {
- arr.push({
- id: i,
- version: `${i}.${i}.${i}`,
- time: '2022-02-02 02:21:23',
- })
- }
- resolve({
- data: arr,
- has_more: false,
- limit: 10,
- total: 100,
- page: 1,
- })
- }, 1000)
- })
- }
- export const fetchIntentType = ({ url, params }: any) => {
- console.log('查询意图类型', url, params)
- // return get(url, { params })
- return new Promise((resolve) => {
- setTimeout(() => {
- const arr: any = []
- for (let i = 1; i < 10; i++) {
- arr.push({
- id: i,
- name: `意图类型_${i}`,
- binding_count: i,
- })
- }
- resolve({
- data: arr,
- has_more: false,
- limit: 10,
- total: 100,
- page: 1,
- })
- }, 1000)
- })
- }
- export const fetchIntentName = ({ url, params }: any) => {
- console.log('查询意图名称', url, params)
- // return get(url, { params })
- return new Promise((resolve) => {
- setTimeout(() => {
- const arr: any = []
- for (let i = 1; i < 10; i++) {
- arr.push({
- id: i,
- name: `意图名称_${i}`,
- })
- }
- resolve({
- data: arr,
- has_more: false,
- limit: 10,
- total: 100,
- page: 1,
- })
- }, 1000)
- })
- }
- export const fetchCorpus = ({ url, params }: any) => {
- console.log('查询训练语料列表', url, params)
- // return get(url, { params })
- return new Promise((resolve) => {
- setTimeout(() => {
- const arr: any = []
- for (let i = 1; i < 10; i++) {
- arr.push({
- id: i,
- name: `语料_${i}`,
- relation: i % 2,
- })
- }
- resolve({
- data: arr,
- has_more: false,
- limit: 10,
- total: 100,
- page: 1,
- })
- }, 1000)
- })
- }
- export const addCorpus = ({ url, body }: any) => {
- console.log('新增训练语料', url, body)
- return post(url, { body })
- }
- export const editCorpus = ({ url, body }: any) => {
- console.log('编辑训练语料', url, body)
- return patch(url, { body })
- }
- export const delCorpus = ({ url, body }: any) => {
- console.log('删除训练语料', url, body)
- return del(url, { body })
- }
- export const addCorpusQuestion = ({ url, body }: any) => {
- console.log('新增训练语料-相似问题', url, body)
- return post(url, { body })
- }
- export const editCorpusQuestion = ({ url, body }: any) => {
- console.log('编辑训练语料-相似问题', url, body)
- return patch(url, { body })
- }
- export const delCorpusQuestion = ({ url, body }: any) => {
- console.log('删除训练语料-相似问题', url, body)
- return del(url, { body })
- }
- export const fetchDepts = ({ url, params }: any) => {
- console.log('查询部门列表', params, url)
- // return get(url, { params })
- return new Promise((resolve) => {
- setTimeout(() => {
- const arr: any = []
- for (let i = 1; i < 3; i++) {
- const dept1: any = {
- id: `${i}`,
- name: `部门_${i}`,
- children: [],
- }
- for (let j = 1; j < 4; j++) {
- const dept2: any = {
- id: `${i}_${j}`,
- name: `部门_${i}-${j}`,
- children: [],
- }
- for (let k = 1; k < 5; k++) {
- const dept3: any = {
- id: `${i}_${j}_${k}`,
- name: `部门_${i}-${j}-${k}`,
- relation: k % 2,
- }
- dept2.children.push(dept3)
- }
- dept1.children.push(dept2)
- }
- arr.push(dept1)
- }
- resolve({
- data: arr,
- })
- }, 1000)
- })
- }
- export const fetchDeptUsers = ({ url, params }: any) => {
- console.log('查询部门用户列表', params, url)
- // return get(url, { params })
- return new Promise((resolve) => {
- setTimeout(() => {
- const arr: any = []
- for (let i = 1; i < 3; i++) {
- const dept1: any = {
- id: `${i}`,
- name: `部门_${i}`,
- children: [],
- }
- for (let j = 1; j < 4; j++) {
- const dept2: any = {
- id: `${i}_${j}`,
- name: `部门_${i}-${j}`,
- children: [],
- }
- for (let k = 1; k < 5; k++) {
- const dept3: any = {
- id: `${i}_${j}_${k}`,
- name: `用户_${i}-${j}-${k}`,
- relation: k % 2,
- }
- dept2.children.push(dept3)
- }
- dept1.children.push(dept2)
- }
- arr.push(dept1)
- }
- resolve({
- data: arr,
- })
- }, 1000)
- })
- }
|