import { http } from '@/api/http' export type ResourceType = 'menu' | 'button' | 'api' export interface Resource { id: string tenantCode: string parentCode: string | null type: ResourceType code: string name: string path: string | null component: string | null method: string | null apiPath: string | null icon: string | null sort: number status: 'enabled' | 'disabled' createdAt: string } export interface ResourceUpsertData { type?: ResourceType code?: string name?: string parentCode?: string | null path?: string component?: string method?: string apiPath?: string icon?: string sort?: number status?: string } /** 资源列表(后端按 sort 升序返回普通数组,前端自行组树)。 */ export function listResources(signal?: AbortSignal): Promise { return http.get('/resources', { signal }) } export function createResource(data: ResourceUpsertData): Promise { return http.post('/resources', data) } export function updateResource(id: string, data: ResourceUpsertData): Promise { return http.patch(`/resources/${id}`, data) } export function deleteResource(id: string): Promise { return http.delete(`/resources/${id}`) }