@pisell/pisellos
Version:
一个可扩展的前端模块化SDK框架,支持插件系统
50 lines (49 loc) • 1.4 kB
TypeScript
export declare enum ResourceHooks {
OnResourceSelect = "resource:onResourceSelect",
OnResourceChange = "resource:onResourceChange",
OnAvailabilityCheck = "resource:onAvailabilityCheck"
}
/**
* 资源可用时间段
*/
export interface ResourceTimeSlot {
start: Date;
end: Date;
capacity: number;
availableCapacity: number;
}
/**
* 资源信息
*/
export interface Resource {
id: string | number;
main_field: string;
form_id: string | number;
type: string;
capacity: number;
timeSlots: ResourceTimeSlot[];
metadata?: Record<string, any>;
startTime?: string;
endTime?: string;
resourceType?: string;
children?: Resource[];
}
/**
* 资源列表状态
*/
export interface ResourceState {
list: Resource[];
selectedResource: Resource | null;
}
/**
* 资源列表模块 API
*/
export interface ResourceListModuleAPI {
getResources: () => Promise<Resource[]>;
selectResource: (resourceId: string) => Promise<void>;
getSelectedResource: () => Resource | null;
checkAvailability: (resourceId: string, start: Date, end: Date) => Promise<boolean>;
getAvailableTimeSlots: (resourceId: string) => Promise<ResourceTimeSlot[]>;
getAvailableCapacity: (resourceId: string, timeSlot: ResourceTimeSlot) => number;
updateResource: (resourceId: string, updates: Partial<Resource>) => Promise<void>;
}