sysmgr-admin/src/api/resource.ts
liuyun f1cb5723b2 feat: wire all management pages to backend (config/dict/org/resource/role/audit/login-log)
- 401 自动登出:http 会话过期回调 + main.ts 注册(清 menu/tabs + 跳登录)
- 参数配置/字典/组织/资源/角色/操作日志/登录日志对接真实接口
- 角色管理新增权限分配树(el-tree 勾选资源,/roles/:code/resources)
- 操作日志/登录日志只读页(ty-search-form + ty-table + useRequest)
- listOrgs 迁到 api/org.ts

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-11 12:45:53 +08:00

52 lines
1.2 KiB
TypeScript

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<Resource[]> {
return http.get<Resource[]>('/resources', { signal })
}
export function createResource(data: ResourceUpsertData): Promise<Resource> {
return http.post<Resource>('/resources', data)
}
export function updateResource(id: string, data: ResourceUpsertData): Promise<Resource> {
return http.patch<Resource>(`/resources/${id}`, data)
}
export function deleteResource(id: string): Promise<unknown> {
return http.delete(`/resources/${id}`)
}