Эх сурвалжийг харах

feat:登录初始化异步处理

Signed-off-by: tangshizhe <48740614+tangshizhe@users.noreply.github.com>
tangshizhe 5 сар өмнө
parent
commit
d4f619cc77

+ 9 - 6
plugins/login-auth/src/lib/pluginLogin.ts

@@ -1,5 +1,5 @@
 import { doChangeTabActive } from '@/module-model/tab'
-import { openDialog, closeDialog, canShowDialog } from '@/module-model/dialog'
+import { canShowDialog, closeDialog, openDialog } from '@/module-model/dialog'
 import loginCookie from '@/module-model/loginCookies'
 import { ScanCodeLoginDetection } from '@/utils/Login'
 import { doSetPageShareId } from '@/module-model/wxQrcode'
@@ -31,7 +31,7 @@ class PluginLogin {
     this.emitter.$on('user-info-update', this.setState.bind(this))
   }
 
-  init(options) {
+  async init(options) {
     if (this.hasInited) {
       console.warn('pluginLogin hasInited')
       return
@@ -62,7 +62,7 @@ class PluginLogin {
 
     if (this.options.preloadLoginState) {
       this.initPoll()
-      this.poll.preload()
+      await this.poll.preload()
     }
 
     if (this.options.preloadWeChatImage) {
@@ -109,7 +109,8 @@ class PluginLogin {
   emit(type, data = null) {
     if (typeof this.options[type] === 'function') {
       this.options[type](data)
-    } else {
+    }
+    else {
       console.warn('[plugin-login]: not find emit function:', type)
     }
   }
@@ -235,6 +236,7 @@ class PluginLogin {
       cross: true
     })
   }
+
   /**
    * 广播用户设置密码事件(暂不设置、设置成功)
    * @param data
@@ -244,7 +246,8 @@ class PluginLogin {
     const { status } = data
     if (status === 1) {
       this.emitter.$emit('user-set-pass-success', data)
-    } else {
+    }
+    else {
       this.emitter.$emit('user-not-set-pass', data)
     }
   }
@@ -259,7 +262,7 @@ function addHook(hook) {
 }
 
 // 注入 hooks
-;['open', 'doSignOut', 'close', 'init', 'getState'].forEach((hook) =>
+;['open', 'doSignOut', 'close', 'init', 'getState'].forEach(hook =>
   addHook(hook)
 )