GoogleImpl.ts 908 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { Node } from "cc";
  2. export interface IGoogleLoginRes {
  3. accessToken: string;
  4. userId?: string;
  5. name?: string;
  6. email?: string;
  7. isCancel: boolean;
  8. status?: string;
  9. reason?: string;
  10. }
  11. export interface IGoogleBtnLogin {
  12. active: boolean,
  13. setActive: (active: boolean) => void,
  14. clear: () => void,
  15. }
  16. export abstract class GoogleImpl {
  17. private _isInitialized = false;
  18. public get isInitialized() { return this._isInitialized; }
  19. abstract init();
  20. protected onInited() {
  21. this._isInitialized = true;
  22. }
  23. async login(): Promise<IGoogleLoginRes> {
  24. const res = await this.onLogin();
  25. return res;
  26. }
  27. protected abstract onLogin(): Promise<IGoogleLoginRes>;
  28. abstract logOut(): Promise<boolean>;
  29. createLoginBtn(node: Node, callback: (res: IGoogleLoginRes) => void): IGoogleBtnLogin {
  30. return null;
  31. }
  32. }