Skip to content

Commit 01d6dca

Browse files
committed
chore() 增加同步时间
1 parent 3008d08 commit 01d6dca

File tree

4 files changed

+275
-48
lines changed

4 files changed

+275
-48
lines changed

.github/workflows/sync-official-docs.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,23 @@ jobs:
190190
npm run fix-all
191191
echo "✅ Code formatting completed"
192192
193-
- name: Check for changes
193+
- name: Update README sync time and check for changes
194194
id: changes
195195
run: |
196+
# 如果有内容同步或翻译更新,更新 README 中的同步时间
197+
if [ "${{ steps.sync-content.outputs.content_changed }}" == "true" ] || [ "${{ steps.translate-content.outputs.translation_changed }}" == "true" ] || [ "${{ steps.sync-assets.outputs.assets_changed }}" == "true" ]; then
198+
echo "📅 Updating sync time in README.md..."
199+
200+
# 获取当前时间(北京时间)- 格式: 2025年07月01日 17:48
201+
SYNC_TIME=$(TZ='Asia/Shanghai' date '+%Y年%m月%d日 %H:%M')
202+
203+
# 更新 README.md 中的同步时间标记
204+
sed -i "s|<!-- LAST_SYNC_TIME -->.*<!-- /LAST_SYNC_TIME -->|<!-- LAST_SYNC_TIME --> $SYNC_TIME <!-- /LAST_SYNC_TIME -->|g" README.md
205+
206+
echo "✅ Sync time updated to: $SYNC_TIME"
207+
fi
208+
209+
# 检查是否有变更需要提交
196210
git add .
197211
if git diff --cached --quiet; then
198212
echo "No changes detected"

README.md

Lines changed: 189 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1-
# 介绍
1+
<div align="center">
2+
<h1>🎯 NestJS 中文文档</h1>
3+
<p>
4+
<strong>构建高效、可扩展的 Node.js Web 应用程序框架</strong>
5+
</p>
6+
<p>
7+
<a href="https://docs.nestjs.cn/">
8+
<img src="https://img.shields.io/badge/📖-查看文档-brightgreen?style=for-the-badge&logo=nestjs&logoColor=white" alt="查看文档">
9+
</a>
10+
<a href="https://github.com/nestjs/docs.nestjs.cn/actions/workflows/sync-official-docs.yml">
11+
<img src="https://img.shields.io/github/actions/workflow/status/nestjs/docs.nestjs.cn/sync-official-docs.yml?branch=main&style=for-the-badge&logo=github&label=同步状态" alt="同步状态">
12+
</a>
13+
<a href="https://github.com/nestjs/docs.nestjs.cn/blob/main/LICENSE">
14+
<img src="https://img.shields.io/github/license/nestjs/docs.nestjs.cn?style=for-the-badge" alt="License">
15+
</a>
16+
</p>
17+
18+
<blockquote>
19+
<p>
20+
📅 <strong>最近同步时间:</strong> <!-- LAST_SYNC_TIME --> 2025年07月01日 09:48 <!-- /LAST_SYNC_TIME -->
21+
<br>
22+
<em>文档每日自动同步并翻译,确保与官方保持同步</em>
23+
</p>
24+
</blockquote>
25+
</div>
26+
27+
---
228

329
Nest是构建高效,可扩展的 Node.js Web 应用程序的框架。 它使用现代的 JavaScript 或 TypeScript(保留与纯 JavaScript 的兼容性),并结合 OOP(面向对象编程),FP(函数式编程)和FRP(函数响应式编程)的元素。。
430

@@ -10,6 +36,10 @@ Nest 旨在提供一个开箱即用的应用程序体系结构,允许轻松创
1036

1137
## [查看文档](https://docs.nestjs.cn/)
1238

39+
40+
41+
## 💬 社区交流
42+
1343
### 中文交流QQ群:
1444

1545
二群:1031015552 (禁止广告)
@@ -25,11 +55,8 @@ Nest 旨在提供一个开箱即用的应用程序体系结构,允许轻松创
2555

2656
### 微信群:
2757

28-
微信三群:
29-
30-
<img src="https://ghproxy.net/https://raw.githubusercontent.com/zuohuadong/imgbed/main/pic/siqun.jpg" alt="加微信" width="260" height="260" align="bottom" />
31-
32-
如果二维码过期,请添加:
58+
微信一群、微信二群、微信三群、微信四群
59+
群二维码过期,请添加:
3360

3461

3562
![](https://ghproxy.net/https://raw.githubusercontent.com/zuohuadong/imgbed/main/pic/68747470733a2f2f7069632e646f776e6b2e63632f6974656d2f3566386336633334316364316262623836623732666339612e6a7067.jpg)
@@ -38,6 +65,7 @@ Nest 旨在提供一个开箱即用的应用程序体系结构,允许轻松创
3865

3966
微信一二群,目前只接受 开源项目作者、nestjs 文档贡献者、捐赠者。
4067

68+
4169
## 贡献者
4270
<!-- readme: collaborators,contributors -start -->
4371
<table>
@@ -1214,6 +1242,68 @@ Nest 旨在提供一个开箱即用的应用程序体系结构,允许轻松创
12141242
<!-- readme: collaborators,contributors -end -->
12151243

12161244

1245+
## 🤝 如何贡献
1246+
1247+
<div align="center">
1248+
<h3>🌟 欢迎各种形式的贡献!</h3>
1249+
<p>让我们一起让 NestJS 中文文档变得更好</p>
1250+
</div>
1251+
1252+
<table>
1253+
<tr>
1254+
<td align="center" width="25%">
1255+
<img src="https://img.shields.io/badge/📝-文档改进-brightgreen?style=flat-square" />
1256+
<br>
1257+
<strong>📝 文档改进</strong>
1258+
<ul>
1259+
<li>发现翻译错误或不准确的地方</li>
1260+
<li>改进文档的表达和可读性</li>
1261+
<li>补充遗漏的内容或示例</li>
1262+
</ul>
1263+
</td>
1264+
<td align="center" width="25%">
1265+
<img src="https://img.shields.io/badge/🔧-技术贡献-blue?style=flat-square" />
1266+
<br>
1267+
<strong>🔧 技术贡献</strong>
1268+
<ul>
1269+
<li>优化 AI 翻译脚本</li>
1270+
<li>改进构建和部署流程</li>
1271+
<li>修复 Bug 或添加新功能</li>
1272+
</ul>
1273+
</td>
1274+
<td align="center" width="25%">
1275+
<img src="https://img.shields.io/badge/🎯-翻译贡献-orange?style=flat-square" />
1276+
<br>
1277+
<strong>🎯 翻译贡献</strong>
1278+
<ul>
1279+
<li>参与 AI 翻译结果的人工校对</li>
1280+
<li>为翻译系统提供术语对照表</li>
1281+
<li>优化翻译质量和一致性</li>
1282+
</ul>
1283+
</td>
1284+
<td align="center" width="25%">
1285+
<img src="https://img.shields.io/badge/💡-建议反馈-purple?style=flat-square" />
1286+
<br>
1287+
<strong>💡 建议反馈</strong>
1288+
<ul>
1289+
<li>提出改进建议</li>
1290+
<li>报告问题和 Bug</li>
1291+
<li>分享使用体验</li>
1292+
</ul>
1293+
</td>
1294+
</tr>
1295+
</table>
1296+
1297+
<div align="center">
1298+
<p>
1299+
<strong>📖 详细贡献指南</strong>
1300+
<br>
1301+
<a href="https://github.com/nestjs/docs.nestjs.cn/blob/main/CONTRIBUTING.md">
1302+
<img src="https://img.shields.io/badge/📋-查看贡献指南-success?style=for-the-badge" />
1303+
</a>
1304+
</p>
1305+
</div>
1306+
12171307
## 赞助商广告:
12181308

12191309
[京东云 产品6折起](https://partner.jdcloud.com/partner/notice/39c68afb71a544e4883b6cd79bb5dffd)
@@ -1307,65 +1397,117 @@ SSL 证书:
13071397
<img src="https://ghproxy.com/https://raw.githubusercontent.com/zuohuadong/imgbed/main/pic/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20211213154942.jpg" alt="支付宝" width="260" height="400" align="bottom" />
13081398

13091399

1400+
## 🚀 技术栈
13101401

1311-
# NestJS 中文文档站点
1402+
本项目使用现代化的技术栈构建,为用户提供优秀的阅读体验:
13121403

1313-
这是基于 [Next.js](https://nextjs.org)[Nextra](https://nextra.site) 构建的 NestJS 中文文档站点,使用 Turbopack 进行优化。
1404+
### 📖 文档构建
13141405

1406+
- **[Rspress](https://rspress.dev/)** - 基于 Rspack 的静态站点生成器
1407+
- ⚡ 极速构建:基于 Rust 的 Rspack 打包器
1408+
- 🎨 现代界面:支持暗黑模式,响应式设计
1409+
- 🔍 全文搜索:内置搜索功能,快速定位内容
1410+
- 📱 移动友好:完美适配移动设备
13151411

1412+
### 🤖 AI 翻译
13161413

1317-
## 开始使用
1414+
- **[Cloudflare Workers AI](https://ai.cloudflare.com/)** - 免费的 AI 翻译服务
1415+
- 💰 完全免费:无需付费即可使用
1416+
- 🌍 全球加速:Cloudflare 全球 CDN 网络
1417+
- 🔒 数据安全:不存储用户数据
1418+
- ⚡ 响应迅速:毫秒级响应时间
1419+
- 🎯 专业翻译:针对技术文档优化的翻译效果
13181420

1319-
首先,运行开发服务器:
1421+
### 🔧 开发工具链
13201422

1321-
```bash
1322-
# 使用 Turbopack(推荐)
1323-
bun run dev
1324-
# 或者
1325-
bun run dev:turbo
1423+
- **Bun** - 现代化的 JavaScript 运行时和包管理器
13261424

1327-
# 或使用其他包管理器
1328-
npm run dev
1329-
yarn dev
1330-
pnpm dev
1425+
- **GitHub Actions** - 自动化 CI/CD 工作流
1426+
- **TypeScript** - 类型安全的开发体验
1427+
- **Tailwind CSS** - 实用优先的 CSS 框架
1428+
1429+
1430+
## AI 自动同步翻译系统
1431+
1432+
本项目实现了完全自动化的文档同步和翻译流程:
1433+
1434+
### ✨ 核心特性
1435+
1436+
- **📚 智能同步**: 每日自动检测官方文档更新
1437+
- **🤖 AI 翻译**: 使用 Cloudflare Workers AI 智能翻译新增内容
1438+
- **🔒 代码保护**: 自动保护代码块、链接、HTML 标签不被翻译
1439+
- **📈 增量更新**: 只翻译变更的部分,提高效率
1440+
- **💾 智能缓存**: 避免重复翻译,节省资源
1441+
- **🔧 格式修复**: 自动处理官方文档的特殊标记和格式
1442+
1443+
### 🎯 工作流程
1444+
1445+
```mermaid
1446+
graph TD
1447+
A[官方 NestJS 文档更新] --> B[GitHub Actions 自动检测]
1448+
B --> C[同步英文内容到 content 目录]
1449+
C --> D[Cloudflare Workers AI 翻译]
1450+
D --> E[格式处理和修复]
1451+
E --> F[更新到 docs 目录]
1452+
F --> G[自动提交到仓库]
1453+
G --> H[触发网站重新构建]
13311454
```
13321455

1333-
打开 [http://localhost:3000](http://localhost:3000) 在浏览器中查看结果。
1456+
### 📋 配置指南
1457+
1458+
- 📚 [Cloudflare Workers AI 配置指南](CLOUDFLARE_AI_SETUP.md)
1459+
- ⚙️ [GitHub Actions 自动翻译配置](GITHUB_ACTIONS_SETUP.md)
1460+
- 🛠️ [翻译脚本使用说明](scripts/README.md)
13341461

1335-
## Turbopack 支持
1462+
### 🎉 翻译质量
13361463

1337-
本项目已配置为使用 Next.js 的 Turbopack 打包工具,提供
1464+
我们的 AI 翻译系统专门针对 NestJS 技术文档进行了优化
13381465

1339-
- 🚀 更快的开发服务器启动
1340-
- ⚡ 更快的热重载
1341-
- 📦 优化的 MDX 文件处理
1342-
- 🔄 增量编译
1466+
- **术语一致性**: 保持 Controller、Service、Module 等技术术语的一致性
1467+
- **代码完整性**: 确保代码示例和变量名保持原样
1468+
- **格式准确性**: 维护 Markdown 格式和链接的完整性
1469+
- **上下文理解**: 基于 NestJS 生态系统的专业翻译
13431470

1344-
### 可用脚本
1471+
### 📊 项目状态
13451472

1346-
- `bun run dev` - 启动开发服务器(已启用 Turbopack)
1347-
- `bun run dev:turbo` - 明确使用 Turbopack 启动开发服务器
1348-
- `bun run build` - 构建生产版本
1349-
- `bun run build:turbo` - 使用实验性编译模式构建
1350-
- `bun run start` - 启动生产服务器
1351-
- `bun run lint` - 运行代码检查
1473+
[![同步状态](https://github.com/nestjs/docs.nestjs.cn/actions/workflows/sync-official-docs.yml/badge.svg)](https://github.com/nestjs/docs.nestjs.cn/actions/workflows/sync-official-docs.yml)
1474+
[![构建状态](https://github.com/nestjs/docs.nestjs.cn/actions/workflows/deploy.yml/badge.svg)](https://github.com/nestjs/docs.nestjs.cn/actions/workflows/deploy.yml)
13521475

1353-
## 功能特性
1476+
- 🔄 **自动同步**: 每日北京时间 10:00 自动同步官方文档
1477+
- 🤖 **AI 翻译**: 使用 Cloudflare Workers AI 提供高质量翻译
1478+
- 📈 **实时更新**: 文档更新后自动部署到生产环境
1479+
- 🚀 **快速访问**: 基于 Rspress 的极速加载体验
13541480

1355-
- 📚 完整的 NestJS 中文文档
1356-
- 🔍 全文搜索支持(中文优化)
1357-
- 🌙 深色/浅色主题切换
1358-
- 📱 响应式设计
1359-
- ⚡ Turbopack 性能优化
1360-
- 🎨 NestJS 官方主题样式
1481+
### 🚀 快速开始
13611482

1362-
## 技术栈
1483+
如果你想在本地运行此项目或贡献翻译:
1484+
1485+
```bash
1486+
# 克隆仓库
1487+
git clone https://github.com/nestjs/docs.nestjs.cn.git
1488+
cd docs.nestjs.cn
1489+
1490+
# 安装依赖
1491+
npm install
1492+
1493+
# 本地开发
1494+
npm run dev
1495+
1496+
# 构建生产版本
1497+
npm run build
1498+
```
13631499

1364-
- **Next.js 15** - React 框架
1365-
- **Nextra** - 文档站点生成器
1366-
- **Turbopack** - 下一代打包工具
1367-
- **TypeScript** - 类型安全
1368-
- **Tailwind CSS** - 样式框架
1369-
- **Flexsearch** - 全文搜索
1500+
#### 配置 AI 翻译(可选)
13701501

1502+
如果你想使用 AI 翻译功能:
13711503

1504+
1. 获取 [Cloudflare Workers AI](CLOUDFLARE_AI_SETUP.md) 凭据
1505+
2. 设置环境变量:
1506+
```bash
1507+
export CLOUDFLARE_API_TOKEN="your-token"
1508+
export CLOUDFLARE_ACCOUNT_ID="your-account-id"
1509+
```
1510+
3. 运行翻译:
1511+
```bash
1512+
npm run translate-docs:verbose
1513+
```

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"translate-docs:openchat": "node scripts/translate-docs.js --model @cf/openchat/openchat-3.5-0106 --verbose",
1818
"sync-and-translate": "npm run translate-docs && npm run fix-all",
1919
"sync-and-translate:no-ai": "npm run translate-docs:no-ai && npm run fix-all",
20+
"update-sync-time": "node scripts/update-sync-time.js",
2021
"test-cloudflare": "node test-cloudflare-translate.js"
2122
},
2223
"dependencies": {

scripts/update-sync-time.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* 更新 README.md 中的最近同步时间
5+
*
6+
* 使用方法:
7+
* node scripts/update-sync-time.js
8+
*/
9+
10+
const fs = require('fs');
11+
const path = require('path');
12+
13+
const README_PATH = path.join(__dirname, '..', 'README.md');
14+
15+
function updateSyncTime() {
16+
try {
17+
// 读取 README.md 文件
18+
const readme = fs.readFileSync(README_PATH, 'utf-8');
19+
20+
// 获取当前时间(北京时间)
21+
const now = new Date();
22+
23+
// 使用 toLocaleString 获取北京时间
24+
const beijingTimeString = now.toLocaleString('zh-CN', {
25+
timeZone: 'Asia/Shanghai',
26+
year: 'numeric',
27+
month: '2-digit',
28+
day: '2-digit',
29+
hour: '2-digit',
30+
minute: '2-digit',
31+
hour12: false
32+
});
33+
34+
// 解析并重新格式化为我们需要的格式:2025年07月01日 17:48
35+
const [datePart, timePart] = beijingTimeString.split(' ');
36+
const [year, month, day] = datePart.split('/');
37+
const syncTime = `${year}${month}${day}${timePart}`;
38+
39+
// 更新同步时间标记
40+
const updatedReadme = readme.replace(
41+
/<!-- LAST_SYNC_TIME -->.*?<!-- \/LAST_SYNC_TIME -->/g,
42+
`<!-- LAST_SYNC_TIME --> ${syncTime} <!-- /LAST_SYNC_TIME -->`
43+
);
44+
45+
// 写回文件
46+
fs.writeFileSync(README_PATH, updatedReadme);
47+
48+
console.log('✅ 同步时间已更新:', syncTime);
49+
50+
// 如果内容有变更,返回 0,否则返回 1
51+
if (readme !== updatedReadme) {
52+
return 0;
53+
} else {
54+
console.log('📋 同步时间无变更');
55+
return 1;
56+
}
57+
58+
} catch (error) {
59+
console.error('❌ 更新同步时间失败:', error.message);
60+
return 2;
61+
}
62+
}
63+
64+
// 如果直接运行此脚本
65+
if (require.main === module) {
66+
const exitCode = updateSyncTime();
67+
process.exit(exitCode);
68+
}
69+
70+
module.exports = { updateSyncTime };

0 commit comments

Comments
 (0)