优化:提升小程序全链路性能
This commit is contained in:
@@ -3,6 +3,7 @@ const auth = require('../../utils/auth')
|
||||
const { chooseImageFilePath, uploadProfileImage } = require('../../utils/upload')
|
||||
const { buildProfileCard, normalizeAvatar } = require('../../utils/profile-card')
|
||||
const { BRAND_CONFIG } = require('../../utils/config')
|
||||
const profileCache = require('../../utils/profile-cache')
|
||||
|
||||
function resolveRoleText(type) {
|
||||
const role = Number(type)
|
||||
@@ -56,10 +57,10 @@ Page({
|
||||
this.loadProfile()
|
||||
},
|
||||
|
||||
async loadProfile() {
|
||||
async loadProfile(options = {}) {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const profile = await userApi.info()
|
||||
const profile = await profileCache.getProfile(options)
|
||||
this.syncProfileToSession(profile)
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '个人信息加载失败', icon: 'none' })
|
||||
@@ -163,7 +164,8 @@ Page({
|
||||
wechatId: String(form.wechatId || '').trim(),
|
||||
signature: String(form.signature || '').trim()
|
||||
})
|
||||
const profile = await userApi.info()
|
||||
profileCache.invalidate()
|
||||
const profile = await profileCache.getProfile({ force: true })
|
||||
this.syncProfileToSession(profile)
|
||||
wx.showToast({ title: '已保存', icon: 'success' })
|
||||
setTimeout(() => wx.navigateBack(), 350)
|
||||
|
||||
Reference in New Issue
Block a user