plugin.d.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { DrawPosterResult, NonPick } from '.';
  2. export interface DrawPosterLifeCycle<I = DrawPosterResult, O = Record<string, any>> {
  3. (instance: I, options?: O): void;
  4. }
  5. export interface DrawPosterLifeCycles {
  6. /** 创建实例前 */
  7. beforeMount?: DrawPosterLifeCycle<Partial<DrawPosterResult>>;
  8. /** 创建实例后 */
  9. mounted?: DrawPosterLifeCycle;
  10. /** 卸载实例前 */
  11. beforeUnmount?: DrawPosterLifeCycle;
  12. /** 卸载实例后 */
  13. unmounted?: DrawPosterLifeCycle;
  14. /** 创建绘图前 */
  15. beforeCreate?: DrawPosterLifeCycle;
  16. /** 创建绘图后 */
  17. created?: DrawPosterLifeCycle;
  18. }
  19. export interface DrawPosterPlugin extends DrawPosterLifeCycles {
  20. /** 扩展名称 */
  21. name: string;
  22. [key: string]: any;
  23. }
  24. export interface DrawPosterUse {
  25. (name: string, lifeCycle: DrawPosterLifeCycle): void;
  26. (name: string, options: NonPick<DrawPosterPlugin, 'name'>): void;
  27. (options: DrawPosterPlugin): void;
  28. }
  29. export declare const globalUse: DrawPosterUse;
  30. export declare class Plugins {
  31. dp: Partial<DrawPosterResult>;
  32. $plugins: DrawPosterPlugin[];
  33. get plugins(): DrawPosterPlugin[];
  34. constructor(dp: Partial<DrawPosterResult>);
  35. use: (...args: any[]) => void;
  36. run: (lifeCycleName: keyof DrawPosterLifeCycles) => void;
  37. }