bugfix:loginfiled
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
"navigationStyle": "custom",
|
||||
"backgroundColor": "#F2F2F7"
|
||||
},
|
||||
"renderer": "webview",
|
||||
"style": "v2",
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"lazyCodeLoading": "requiredComponents"
|
||||
|
||||
@@ -21,10 +21,12 @@ Component({
|
||||
|
||||
lifetimes: {
|
||||
attached() {
|
||||
// 先用缓存渲染红点;未登录时不再发请求(否则会批量 401 并触发重定向)
|
||||
// 首帧渲染流程结束后再更新:先用缓存渲染红点,未登录时不再发请求(否则会批量 401 并触发重定向)
|
||||
const cached = (wx.getStorageSync(STORAGE_KEYS.UNREAD) as number) || 0
|
||||
this.setData({ unread: cached })
|
||||
this.syncUnread()
|
||||
wx.nextTick(() => {
|
||||
this.setData({ unread: cached })
|
||||
this.syncUnread()
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -59,7 +59,9 @@ Page({
|
||||
wx.switchTab({ url: '/pages/wardrobe/wardrobe' })
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
.catch(() => {})
|
||||
.then(() => {
|
||||
// 无论成功还是失败都复位:分支走向礼包/生日引导时若不复位,登录按钮会永久点不动
|
||||
this.setData({ loading: false })
|
||||
})
|
||||
},
|
||||
@@ -71,7 +73,8 @@ Page({
|
||||
},
|
||||
|
||||
showWelcomeGift(userInfo: UserInfo) {
|
||||
request<{ quotas: QuotaItem[] }>({ url: '/quota/info', showError: false })
|
||||
// 额度只用于礼包展示:失败静默降级,绝不能触发登出/清 token
|
||||
request<{ quotas: QuotaItem[] }>({ url: '/quota/info', showError: false, silentAuth: true })
|
||||
.then((res) => this.setData({ giftItems: this.buildGift(userInfo, res.quotas), giftVisible: true }))
|
||||
.catch(() => this.setData({ giftItems: this.buildGift(userInfo, []), giftVisible: true }))
|
||||
},
|
||||
|
||||
@@ -76,7 +76,7 @@ Page({
|
||||
},
|
||||
|
||||
fetchQuota() {
|
||||
request<{ quotas: QuotaItem[] }>({ url: '/quota/info', showError: false })
|
||||
request<{ quotas: QuotaItem[] }>({ url: '/quota/info', showError: false, silentAuth: true })
|
||||
.then((res) => {
|
||||
const quotas = res.quotas.map((q) => ({
|
||||
...q,
|
||||
|
||||
@@ -72,7 +72,7 @@ Page({
|
||||
},
|
||||
|
||||
fetchQuota() {
|
||||
request<{ quotas: QuotaItem[] }>({ url: '/quota/info', showError: false })
|
||||
request<{ quotas: QuotaItem[] }>({ url: '/quota/info', showError: false, silentAuth: true })
|
||||
.then((res) => {
|
||||
const upload = res.quotas.find((q) => q.quota_type === QuotaType.UPLOAD)
|
||||
if (upload) this.setData({ uploadRemain: upload.remain })
|
||||
|
||||
@@ -87,7 +87,7 @@ Page({
|
||||
},
|
||||
|
||||
fetchQuota(): Promise<void> {
|
||||
return request<{ quotas: QuotaItem[] }>({ url: '/quota/info', showError: false })
|
||||
return request<{ quotas: QuotaItem[] }>({ url: '/quota/info', showError: false, silentAuth: true })
|
||||
.then((res) => {
|
||||
const upload = res.quotas.find((q) => q.quota_type === QuotaType.UPLOAD)
|
||||
if (upload) this.setData({ uploadRemain: upload.remain })
|
||||
|
||||
@@ -174,9 +174,10 @@ export function request<T = any>(options: RequestOptions): Promise<T> {
|
||||
doCall()
|
||||
return
|
||||
}
|
||||
auth.clearTokens()
|
||||
// 非关键请求(红点轮询等)静默失败,不打断用户当前页面
|
||||
// 非关键请求(红点轮询、额度展示等)静默失败:
|
||||
// 只 reject,不动登录态、不跳转,避免把已登录用户悄悄踢成未登录
|
||||
if (!silentAuth) {
|
||||
auth.clearTokens()
|
||||
handleAuthExpired()
|
||||
if (showError) showToast('登录已过期,请重新登录')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user