foundation.ts 986 B

1234567891011121314151617181920212223242526272829303132333435
  1. import BaseFoundation, { DefaultAdapter } from '../base/foundation';
  2. export interface AvatarAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
  3. notifyImgState(isImgExist: boolean): void;
  4. notifyLeave(event: any): void;
  5. notifyEnter(event: any): void;
  6. }
  7. export default class AvatarFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<AvatarAdapter<P, S>, P, S> {
  8. constructor(adapter: AvatarAdapter<P, S>) {
  9. super({ ...adapter });
  10. }
  11. init() { } // eslint-disable-line
  12. destroy() { } // eslint-disable-line
  13. handleImgLoadError() {
  14. const { onError } = this.getProps();
  15. const errorFlag = onError ? onError() : undefined;
  16. if (errorFlag !== false) {
  17. this._adapter.notifyImgState(false);
  18. }
  19. }
  20. handleEnter(e: any) {
  21. this._adapter.notifyEnter(e);
  22. }
  23. handleLeave(e: any) {
  24. this._adapter.notifyLeave(e);
  25. }
  26. }