Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ jobs:
PREVIEW_ALIAS="b-${BRANCH_SLUG}"
PREVIEW_SUMMARY_FILE="cloudflare-preview-summary.md"

echo "Building OpenNext bundle for preview URLs"
npx opennextjs-cloudflare build
echo "Building ViNext bundle for preview URLs"
pnpm build

echo "Uploading Worker version with preview alias: $PREVIEW_ALIAS"
npx wrangler versions upload \
--config wrangler.jsonc \
--config dist/server/wrangler.json \
--preview-alias "$PREVIEW_ALIAS" \
--message "Preview for $GITHUB_REF_NAME @ $GITHUB_SHA" | \
tee wrangler-preview-output.log
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ __pycache__/

# Shadcn UI components
components/ui/*
/dist/
.vinext/
39 changes: 28 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ GoodAction Hub 是一个聚合公益活动信息与无障碍餐饮指南的开

### 环境准备

**Bun**: 本项目使用 [Bun][8] 作为包管理器和运行时。
本项目使用 PNPM 管理依赖,使用 [ViNext][14] 在 Vite 和 Cloudflare Workers 上运行 Next.js App router。Node.js 和 PNPM 版本请与 [部署工作流](.github/workflows/deploy.yml) 保持一致。

### 本地启动

Expand All @@ -80,35 +80,51 @@ GoodAction Hub 是一个聚合公益活动信息与无障碍餐饮指南的开
2. **安装依赖**

```bash
bun install
pnpm install
```

3. **激活 Git Hook(此步骤会在安装依赖后自动执行)**

```bash
bun run prepare
pnpm run prepare
```

4. **启动开发服务器**

```bash
bun run dev
pnpm dev
```

5. **(可选)剪枝**

```bash
bun run knip
pnpm knip
```

现在,在浏览器中打开 http://localhost:3000 即可看到项目页面。
在浏览器中打开 Vite 输出的本地地址即可看到项目页面。语言路径为
`/zh-CN/`、`/zh-TW/` 和 `/en-US/`;搜索、筛选和分页仍由服务端渲染。

### 部署与运维

- 推荐平台:Netlify(已集成 `@netlify/plugin-nextjs`)
- 构建命令:`npm run build`
- 如遇到路由大小写或缓存相关问题,建议在 Netlify 后台执行 “Clear cache and deploy site” 重新构建
- 也可选择 GitHub Pages 或华为云部署(参考仓库根目录的相关文档与脚本)
- 构建:`pnpm build`,生成 ViNext 客户端资源和 Cloudflare worker。
- 本地验证生产 worker:`npm start`;构建并预览:`pnpm preview`。
- 类型检查:`npm test`。
- 构建并部署:`pnpm deploy`。
- Cloudflare GitHub app 构建命令:`pnpm build`。
- Cloudflare GitHub app 生产部署命令:
`pnpm exec wrangler deploy --config dist/server/wrangler.json`。
- Cloudflare GitHub app 非生产分支部署命令:
`pnpm exec wrangler versions upload --config dist/server/wrangler.json`。

GitHub actions 默认分支部署生产版本,其他分支上传带别名的预览版本。
部署必须使用构建生成的 `dist/server/wrangler.json`,不要部署源码配置中的入口。
不要同时启用两个集成的生产自动部署,以免重复构建与相互覆盖。

静态 JS、CSS、图片和字体由 `dist/client` 资源层优先处理。ViNext 的静态资源缓存
适配器会打包可预渲染页面;`run_worker_first` 仅针对内部
`/_vinext/static-cache/*` 路径,避免绕过适配器的缓存访问检查,并非全站 worker 优先。
搜索页、API 和未预渲染的详情页仍需要 worker;迁移框架不代表这些请求不再消耗额度。
未配置额外付费缓存存储或 Cloudflare images 绑定,图片保持原样提供。

### 反馈与支持

Expand All @@ -118,7 +134,7 @@ GoodAction Hub 是一个聚合公益活动信息与无障碍餐饮指南的开

### 技术栈

- **框架**: [Next.js][9]
- **框架**: [ViNext][14] / Vite,兼容 [Next.js App router][9]
- **UI**: [Tailwind CSS][10] & [shadcn/ui][11]
- **状态管理**: [Zustand][12]
- **搜索**: [Fuse.js][13]
Expand All @@ -136,3 +152,4 @@ GoodAction Hub 是一个聚合公益活动信息与无障碍餐饮指南的开
[11]: https://ui.shadcn.com/
[12]: https://github.com/pmndrs/zustand
[13]: https://github.com/krisk/fuse
[14]: https://github.com/cloudflare/vinext
2 changes: 1 addition & 1 deletion lib/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ExternalDeadlineItem {
}

export async function fetchActivitiesCatalog() {
const res = await fetch(ACTIVITIES_API_URL, { cache: 'force-cache' });
const res = await fetch(ACTIVITIES_API_URL, { next: { revalidate: false } });
if (!res.ok) throw new URIError(`Failed to fetch activities: ${res.status}`);
return (await res.json()) as ExternalDeadlineItem[];
}
Expand Down
4 changes: 3 additions & 1 deletion lib/bitesCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ let _catalogCache: BitesRestaurant[] | null = null;
export async function fetchBitesCatalog(): Promise<BitesRestaurant[]> {
if (_catalogCache) return _catalogCache;
try {
const res = await fetch(RESTAURANTS_API_URL, { cache: 'force-cache' });
const res = await fetch(RESTAURANTS_API_URL, {
next: { revalidate: false },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = (await res.json()) as ExternalRestaurant[];
_catalogCache = data.map(transformRestaurant);
Expand Down
3 changes: 0 additions & 3 deletions open-next.config.ts

This file was deleted.

38 changes: 24 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
"name": "@goodaction-hub/goodaction-hub.github.io",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"install": "npx shadcn-helper install",
"dev": "next dev",
"build": "next build",
"start": "next start",
"preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview",
"deploy": "opennextjs-cloudflare build && opennextjs-cloudflare deploy",
"dev": "vite dev",
"build": "vite build",
"start": "wrangler dev --config dist/server/wrangler.json",
"preview": "npm run build && npm start",
"deploy": "vinext-cloudflare deploy --config dist/server/wrangler.json",
"cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts",
"test": "next typegen && lint-staged && git add . && tsc --noEmit",
"test": "tsc --noEmit",
"knip": "knip",
"prepare": "husky"
},
Expand All @@ -23,7 +24,6 @@
},
"dependencies": {
"@giscus/react": "^3.1.0",
"@opennextjs/cloudflare": "^1.20.14",
"@radix-ui/react-dialog": "^1.3.1",
"@radix-ui/react-dropdown-menu": "^2.2.1",
"@radix-ui/react-icons": "^1.3.2",
Expand All @@ -36,45 +36,55 @@
"calendar-link": "^2.11.6",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cn": "^0.5.0",
"cn": "^0.5.1",
"fuse.js": "^7.5.0",
"lucide-react": "^1.64.0",
"leaflet": "^1.9.4",
"lucide-react": "^1.65.0",
"luxon": "^3.7.2",
"mobx": "^6.16.1",
"mobx": "^7.1.3",
"mobx-i18n": "^0.7.9",
"mobx-react": "^9.2.2",
"mobx-react": "^10.0.3",
"mobx-restful": "^2.1.5",
"next": "^16.4.3",
"open-react-map": "^0.9.1",
"radix-ui": "^1.8.1",
"react": "^19.3.1",
"react-dom": "^19.3.1",
"react-markdown": "^10.1.0",
"react-server-dom-webpack": "^19.3.1",
"remark-gfm": "^4.0.1",
"tailwind-merge": "^3.7.0",
"web-utility": "^4.8.1",
"ws": "^8.22.0",
"zustand": "^5.0.16"
},
"devDependencies": {
"@cloudflare/vite-plugin": "^1.66.0",
"@tailwindcss/postcss": "^4.3.3",
"@types/luxon": "^3.7.6",
"@types/node": "^26.6.6",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"@types/ws": "^8.18.2",
"@vinext/cloudflare": "^1.3.0",
"@vitejs/plugin-react": "^6.1.2",
"@vitejs/plugin-rsc": "^0.5.38",
"eslint": "^10.13.0",
"eslint-config-next": "^16.4.3",
"husky": "^9.1.7",
"jiti": "^2.7.0",
"knip": "^6.43.0",
"knip": "^6.44.0",
"lint-staged": "^17.6.0",
"postcss": "^8.5.32",
"prettier": "^3.9.10",
"shadcn": "^4.23.0",
"shadcn-helper": "^0.5.10",
"tailwindcss": "^4.3.3",
"tw-animate-css": "^1.4.0",
"typescript": "^5.9.3",
"wrangler": "^4.155.0"
"typescript": "^6.0.3",
"vinext": "^1.4.0",
"vite": "^8.3.5",
"vite-css-modules": "^1.16.1",
"wrangler": "^4.156.0"
}
}
Loading
Loading