feat(viewer): likes, bubbles, visit reporting and hot sorting

Task 10 viewer 互动化:

- 点赞:useLikes 批次状态机(500ms 防抖 / 5 次满额即冲 / 失败同 batchId
  退避重试 3 次后回滚丢弃),乐观计数 + 服务端 total 权威校准
  (countVersion 单调),大图与格子双入口;
- WS 实时:RealtimeClient 纯状态机(半频心跳、指数退避重连、三败降级、
  重连成功 resync 第 1 页重取),消息路由器做 likes.burst 自身过滤
  (originBatchIds 求交)、隐藏页暂停与减少动画下仅校准不出气泡;
  photo.hidden/deleted 即时移出序列并回退邻居大图;降级后 8s 轮询接管;
- 浏览上报:visitorId 跨标签 BroadcastChannel first-writer-wins 协调,
  可见时上报、requestId 持久幂等、网络失败指数重试;
- 排序:最新/热门 chips(热门走 ov 冷快照),大图打开期间禁用切换;
  顶栏「减少动画」偏好开关;
- 契约包新增 ./realtime 子路径出口(浏览器面不可引桶出口——其连带
  internal-sync 的 node:crypto 会被 Vite 外置化致整页崩溃);
- e2e 注入钩子 __viewerWsUrl/__viewerWsRetryBaseMs/__viewerRealtimePollMs/
  __viewerBubbleMs 与 .activity[data-connection] 连接态锚。

vitest:viewer 105(新增 36:likes 批次 8、visitor 协调 5、上报门控 4、
路由 8、WS 状态机 7、排序 4);Playwright:viewer 21(新增 likes.spec 7、
journey 补互动腿断言)。

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-18 19:52:27 +08:00
parent 955bea49b5
commit cdead49838
29 changed files with 2581 additions and 29 deletions
+7
View File
@@ -7,20 +7,27 @@ export default {
emptyNotice: 'Photos coming soon',
time: 'Time',
venue: 'Venue',
views: 'Views',
categories: 'Categories',
all: 'All',
sortLabel: 'Sort',
sortLatest: 'Latest',
sortHot: 'Popular',
end: 'You have reached the end',
newPhotos: 'New photos — tap to refresh',
retry: 'Retry',
},
lang: { switch: 'Switch language' },
prefs: { reduceMotion: 'Reduce motion' },
viewer: {
title: 'Photo viewer',
close: 'Close',
previous: 'Previous photo',
next: 'Next photo',
counter: '{current} / {total}',
like: 'Like',
likeCount: '{count} likes',
bubbleOpen: 'Open the liked photo',
loadFailed: 'Failed to load image',
// PHOTO_NOT_PUBLIC 专用:not found / unpublished / hidden share one code (anti-enumeration).
photoUnavailable: 'Photo not found or unavailable',
+7
View File
@@ -7,20 +7,27 @@ export default {
emptyNotice: '照片即将上线',
time: '时间',
venue: '地点',
views: '浏览次数',
categories: '分类',
all: '全部',
sortLabel: '排序',
sortLatest: '最新',
sortHot: '热门',
end: '已经到底了',
newPhotos: '有新照片,点击查看',
retry: '重试',
},
lang: { switch: '切换语言' },
prefs: { reduceMotion: '减少动画' },
viewer: {
title: '照片查看',
close: '关闭',
previous: '上一张',
next: '下一张',
counter: '{current} / {total}',
like: '点赞',
likeCount: '{count} 次点赞',
bubbleOpen: '查看被点赞的照片',
loadFailed: '图片加载失败',
photoRemoved: '照片已被移除',
// PHOTO_NOT_PUBLIC 专用:不存在/未发布/已隐藏同码(防枚举),文案覆盖两种成因。