fix: 榜单云函数失败时仅无数据才提示toast,避免已有数据时误弹
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
module.exports = {
|
||||
/** 应用版本号,外显在设置页「关于」 */
|
||||
version: 'v1.5',
|
||||
version: 'v2.0',
|
||||
|
||||
/** 最后更新日期,外显在设置页「关于」 */
|
||||
updatedAt: '2026-06-24',
|
||||
|
||||
@@ -66,10 +66,14 @@ Page({
|
||||
if (cb) cb()
|
||||
}).catch((err) => {
|
||||
// Cloud function not deployed or network error — fall back to
|
||||
// local data but let the user know the leaderboard is degraded.
|
||||
// local data. Only show a toast if we have nothing to display
|
||||
// yet (avoid confusing toast when a retry already has data).
|
||||
console.warn('[leaderboard] cloud function failed, using local fallback:', err)
|
||||
wx.showToast({ title: '云端榜单暂不可用', icon: 'none', duration: 2000 })
|
||||
const hadData = this.data.rankedList && this.data.rankedList.length > 0
|
||||
this._applyLocal()
|
||||
if (!hadData && (!this.data.rankedList || this.data.rankedList.length === 0)) {
|
||||
wx.showToast({ title: '云端榜单暂不可用', icon: 'none', duration: 2000 })
|
||||
}
|
||||
if (cb) cb()
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user