修复云端数据一致性问题
This commit is contained in:
@@ -80,7 +80,7 @@
|
||||
<view class="rank-list">
|
||||
<view
|
||||
wx:for="{{rankedList}}"
|
||||
wx:key="openid"
|
||||
wx:key="rank"
|
||||
wx:if="{{rankedList.length < 3 || index >= 3}}"
|
||||
class="rank-item {{item.isMe ? 'is-me' : ''}} rank-item--enter"
|
||||
style="animation-delay: {{index < 10 ? index * 60 : 0}}ms;"
|
||||
|
||||
@@ -351,9 +351,15 @@ Page({
|
||||
wx.removeStorageSync('custom_plans')
|
||||
wx.removeStorageSync('user_profile')
|
||||
|
||||
// 3. Clear cloud doc (awaited — order matters: clear cloud
|
||||
// after cancelling push, before resetting defaults)
|
||||
try { await cloud.clearAll() } catch (e) {}
|
||||
// 3. Clear every cloud doc for this openid. Local data is already gone
|
||||
// even if this fails, so surface that partial failure honestly.
|
||||
let cloudClearFailed = false
|
||||
try {
|
||||
await cloud.clearAll()
|
||||
} catch (e) {
|
||||
cloudClearFailed = true
|
||||
console.warn('[settings] cloud clear failed:', e)
|
||||
}
|
||||
|
||||
// 4. Reinstate default settings and streak
|
||||
wx.setStorageSync('user_settings', {
|
||||
@@ -379,7 +385,11 @@ Page({
|
||||
})
|
||||
themeMod.applyThemeToPage(this)
|
||||
this.setData({ plans: buildPlansList(storage.getCustomPlans()) })
|
||||
wx.showToast({ title: '已清除', icon: 'success', duration: 1500 })
|
||||
wx.showToast({
|
||||
title: cloudClearFailed ? '本地已清除,云端未清除' : '已清除',
|
||||
icon: cloudClearFailed ? 'none' : 'success',
|
||||
duration: cloudClearFailed ? 2200 : 1500
|
||||
})
|
||||
},
|
||||
|
||||
// -------- Plan editor --------
|
||||
|
||||
Reference in New Issue
Block a user