2026-07-27 00:18:42 +08:00
|
|
|
import { request } from './http';
|
|
|
|
|
import { resourceApi } from './resource';
|
|
|
|
|
|
|
|
|
|
/** 平台角色、菜单、账号和工作台接口。 */
|
2026-07-29 13:18:52 +08:00
|
|
|
export type PlatformRole = { identity: string; role_code: string; name: string; data_scope: string; is_system: boolean; status: number };
|
2026-07-27 09:26:52 +08:00
|
|
|
export type PlatformMenu = { identity: string; parent_identity?: string; menu_code: string; name: string; icon: string; path: string; sort_no: number };
|
2026-07-27 00:18:42 +08:00
|
|
|
|
|
|
|
|
export const platformApi = {
|
|
|
|
|
overview: () => request<Record<string, number>>('/dashboard/overview'),
|
2026-07-28 13:35:59 +08:00
|
|
|
listAccount: () => request<{ total: number; list: Record<string, unknown>[] }>('/platform_account'),
|
2026-07-28 11:08:47 +08:00
|
|
|
listRole: () => resourceApi.list<PlatformRole>('/platform_role'),
|
|
|
|
|
createRole: (data: Record<string, unknown>) => resourceApi.create<PlatformRole>('/platform_role', data),
|
|
|
|
|
listMenu: () => request<{ total: number; list: PlatformMenu[] }>('/platform_menu'),
|
2026-07-27 12:48:35 +08:00
|
|
|
listRoleMenuIdentities: (identity: string) =>
|
|
|
|
|
request<{ menu_identities: string[] }>(
|
2026-07-28 11:08:47 +08:00
|
|
|
`/platform_role/${identity}/menu`,
|
2026-07-27 12:48:35 +08:00
|
|
|
),
|
|
|
|
|
replaceRoleMenus: (identity: string, menuIdentities: string[]) =>
|
|
|
|
|
request<{ updated: boolean }>(
|
2026-07-28 11:08:47 +08:00
|
|
|
`/platform_role/${identity}/menu`,
|
2026-07-27 12:48:35 +08:00
|
|
|
{
|
|
|
|
|
method: 'PUT',
|
|
|
|
|
body: JSON.stringify({ menu_identities: menuIdentities }),
|
|
|
|
|
},
|
|
|
|
|
),
|
2026-07-26 18:06:14 +08:00
|
|
|
};
|