feat(r2): 阶段4 store 降级为离线兜底缓存层

- designList/address 两页缓存优先渲染(冷启动不空屏),联网后以服务端为准覆盖
- store/design.ts、store/address.ts 文件头注明缓存层语义(回写/兜底/旧数据不合并)
- 流程文档勾选阶段 1-4 进度

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-12 03:58:55 +08:00
co-authored by Claude
parent e557dbcb89
commit 954cddfc22
5 changed files with 30 additions and 10 deletions
+3 -1
View File
@@ -28,7 +28,9 @@ export default function AddressPage() {
const [isDefault, setIsDefault] = useState(false)
const load = () => {
// API 优先,成功后回写本地缓存;失败降级读缓存
// 缓存优先展示(冷启动不空屏),再拉服务端刷新;
// 刷新成功回写缓存并以服务端为准覆盖(旧本地数据不自动合并,route-r2 风险节)
setList(getAddressList())
fetchAddresses()
.then(data => {
setList(data)
+3 -1
View File
@@ -41,7 +41,9 @@ export default function DesignListPage() {
const [selected, setSelected] = useState<Set<string>>(new Set())
const load = useCallback(() => {
// API 优先,成功后回写本地缓存(checkout 等页面仍读缓存);失败降级读缓存
// 缓存优先展示(冷启动不空屏),再拉服务端刷新;
// 刷新成功回写缓存并以服务端为准覆盖(旧本地数据不自动合并,route-r2 风险节)
setList(getDesignList())
fetchDesignList()
.then(data => {
setList(data)
+7
View File
@@ -1,3 +1,10 @@
/**
* 收货地址本地存储 —— R2 后降级为「离线兜底缓存」层(按 openid 隔离,见 keys.ts)。
* 真实 CRUD 已走 utils/api/address.ts;本层职责:
* - 页面 API 成功 → 回写缓存,供冷启动先展示与未迁移页面(checkout 等)读取;
* - API 失败/断网 → 页面读缓存正常浏览;
* - 联网刷新以服务端为准覆盖缓存,旧本地数据不做自动合并(route-r2 风险节:默认忽略)。
*/
import Taro from '@tarojs/taro'
import type { AddressItem } from '../../types'
import { key } from './keys'
+7
View File
@@ -1,3 +1,10 @@
/**
* 设计清单本地存储 —— R2 后降级为「离线兜底缓存」层(按 openid 隔离,见 keys.ts)。
* 真实 CRUD 已走 utils/api/design.ts;本层职责:
* - 页面 API 成功 → 回写缓存,供冷启动先展示与未迁移页面(checkout 等)读取;
* - API 失败/断网 → 页面读缓存正常浏览;
* - 联网刷新以服务端为准覆盖缓存,旧本地数据不做自动合并(route-r2 风险节:默认忽略)。
*/
import Taro from '@tarojs/taro'
import type { DesignItem } from '../../types'
import { assetUrl } from '../asset'