Skip to content

同步 v0.1.5:性能与交互体验优化 - #4

Merged
AlexWei2020 merged 3 commits into
mainfrom
feature
Aug 2, 2026
Merged

同步 v0.1.5:性能与交互体验优化#4
AlexWei2020 merged 3 commits into
mainfrom
feature

Conversation

@AlexWei2020

Copy link
Copy Markdown
Owner

概述

将 feature 分支的 v0.1.3 → v0.1.5 改动同步到 main。

改动

  • perf (v0.1.3):连接池按 serverless 调优、批量 ensureSchema() 一次建齐列与索引、首屏与热路径并行查询、首图 priority + React.memo、新增 db/migrations.sql
  • feat (v0.1.4):认领/签收/翻页改乐观更新 + 后台静默对齐(不再整格变灰、不跳顶部),图片 shimmer 占位 + 淡入
  • fix (v0.1.5):「待认领」徽标改实体主色背景,提升可读性

验证

  • tsc --noEmit 通过
  • next build 生产构建通过

部署提醒

上线后建议将 Vercel 的 DATABASE_URL 指向 Supabase 事务型 pooler(端口 6543),并将函数 region 设为与数据库同区。

🤖 Generated with Claude Code

AlexWei2020 and others added 3 commits August 2, 2026 12:16
- 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>
Copilot AI review requested due to automatic review settings August 2, 2026 05:04
@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
post-back Ready Ready Preview Aug 2, 2026 5:04am

@AlexWei2020
AlexWei2020 merged commit 0bafdfa into main Aug 2, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 占位 + 淡入;首图 prioritymemo 包装以减少重渲染
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 thread app/home-client.tsx
Comment on lines +84 to 85
if (!silent) setLoadingPage(true);
setError(null);
Comment thread app/mine/mine-client.tsx
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 thread db/migrations.sql
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 thread lib/schema.ts
Comment on lines +50 to +53
} catch (err) {
console.error("Failed to ensure schema:", err);
return { metadata: false, hidden: false, hash: false };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants