优化:提升小程序全链路性能
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const auth = require('./utils/auth')
|
||||
const authApi = require('./api/auth')
|
||||
const { BRAND_CONFIG } = require('./utils/config')
|
||||
const loginFlow = require('./utils/login-flow')
|
||||
const profileCache = require('./utils/profile-cache')
|
||||
|
||||
App({
|
||||
globalData: {
|
||||
@@ -37,10 +37,10 @@ App({
|
||||
|
||||
async runWechatBootstrap() {
|
||||
try {
|
||||
const status = await authApi.wechatStatus(await this.getWechatCode())
|
||||
this.publishWechatLoginState(status)
|
||||
const preference = auth.getLoginPreference()
|
||||
if (!loginFlow.shouldAutoLogin(preference, status)) {
|
||||
if (!preference || !preference.rememberMe) {
|
||||
const status = await authApi.wechatStatus(await this.getWechatCode())
|
||||
this.publishWechatLoginState(status)
|
||||
auth.clearSession()
|
||||
this.globalData.userInfo = null
|
||||
this.goLogin()
|
||||
@@ -103,11 +103,13 @@ App({
|
||||
|
||||
clearSession() {
|
||||
auth.clearSession()
|
||||
profileCache.invalidate()
|
||||
this.globalData.userInfo = null
|
||||
},
|
||||
|
||||
logoutDevice() {
|
||||
auth.clearDeviceLoginState()
|
||||
profileCache.invalidate()
|
||||
this.globalData.userInfo = null
|
||||
this.globalData.wechatLoginState = null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user