同步 v0.1.5:性能与交互体验优化 - #4
Merged
Merged
Conversation
- lib/db.ts: 连接池按 serverless 调优(max 3、idle 10s、allowExitOnIdle), 并注明改用 Supabase 事务型 pooler(6543) - lib/schema.ts: 新增批量 ensureSchema(),一次往返建齐列与索引, 补 created_at/status/claimer/uploader/image_hash 及广场部分索引 - app/page.tsx & api/postcards: 首屏与热路径改为并行查询 - postcard-card: 首屏首图 priority + React.memo - db/migrations.sql: 幂等迁移脚本,供 Supabase 一次性预建索引 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- 认领/签收/取消/删除:先本地即时改状态(乐观),弹窗立即关闭, 再后台静默与服务器对齐——不再整格变灰、不再跳回顶部 - loadPage 新增 silent 模式:静默重同步不打断滚动、不显示遮罩 - postcard-card: 图片加载完成前显示 shimmer 占位,加载后淡入,消除"闪现" - 广场与"我的"两处列表交互保持一致 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
原 bg-primary/10 + text-primary 对比度过低几乎看不清, 改为 bg-primary + text-primary-foreground 实体色,卡片与详情弹窗一致。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
将 feature 分支 v0.1.3→v0.1.5 的改动同步到 main,重点覆盖数据库热路径性能优化(schema/index 一次性 ensure、连接池参数)与前端交互体验优化(乐观更新、图片加载体验、徽标可读性)。
Changes:
- 新增/整合数据库 schema 与索引初始化:
ensureSchema()单次批量建列/建索引/初始化site_stats,并新增可手工执行的db/migrations.sql - 首页/我的列表交互改为“乐观更新 + 后台静默对齐”,减少整格变灰与滚动跳动
- 首图优先加载 + 图片 shimmer/淡入效果;“待认领”徽标样式提升对比度
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | 版本号同步到 0.1.5 |
| lib/schema.ts | 新增 ensureSchema(),将热路径 schema/index 检查合并为一次 round trip |
| lib/db.ts | 针对 serverless 调整连接池参数并启用 allowExitOnIdle |
| db/migrations.sql | 新增幂等迁移脚本(列/索引/site_stats)供部署后预建索引 |
| components/postcard-detail.tsx | “待认领”状态徽标配色调整为主色实底以增强可读性 |
| components/postcard-card.tsx | 图片 shimmer 占位 + 淡入;首图 priority;memo 包装以减少重渲染 |
| app/page.tsx | 并行执行 getCurrentUser() 与 ensureSchema();并行拉取首页所需数据 |
| app/mine/mine-client.tsx | 我的页面引入静默对齐参数 silent,动作改乐观更新减少 UI 抖动 |
| app/home-client.tsx | 广场引入静默对齐 + 乐观状态补丁;首屏前几张卡片图片优先加载 |
| app/api/postcards/route.ts | GET 并行 schema ensure;POST 使用 ensureSchema() 返回的 flags 决定写入字段 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+84
to
85
| if (!silent) setLoadingPage(true); | ||
| setError(null); |
Comment on lines
+79
to
80
| if (!silent) setLoadingPage(true); | ||
| setError(null); |
Comment on lines
+65
to
+68
| onLoad={() => setImgLoaded(true)} | ||
| className={`object-cover transition-opacity duration-500 ${ | ||
| imgLoaded ? "opacity-100" : "opacity-0" | ||
| }`} |
Comment on lines
+162
to
+164
| // Lists re-render on every claim/receive/paging action; memo skips cards whose | ||
| // props are unchanged so only the affected card (and its image) touch the DOM. | ||
| export default memo(PostcardCard); |
Comment on lines
+3
to
+5
| -- The app also applies all of this automatically on first request via | ||
| -- lib/schema.ts `ensureSchema()`, so pushing the code is enough to keep the site | ||
| -- working. Running this once by hand in the Supabase SQL editor is still |
Comment on lines
+50
to
+53
| } catch (err) { | ||
| console.error("Failed to ensure schema:", err); | ||
| return { metadata: false, hidden: false, hash: false }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
将 feature 分支的 v0.1.3 → v0.1.5 改动同步到 main。
改动
ensureSchema()一次建齐列与索引、首屏与热路径并行查询、首图 priority +React.memo、新增db/migrations.sql验证
tsc --noEmit通过next build生产构建通过部署提醒
上线后建议将 Vercel 的
DATABASE_URL指向 Supabase 事务型 pooler(端口 6543),并将函数 region 设为与数据库同区。🤖 Generated with Claude Code