Files
shizhui_website/docs/DEVELOP.md
ShiZhui 2ebabcf276
All checks were successful
Build and Deploy / build-deploy (push) Successful in 26s
docs: 新增日常开发流程文档(多机协作/凭据/自检)
2026-06-16 15:26:37 +08:00

83 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 日常开发流程
> 本网站采用「本地开发 → 推送 Gitea → 自动构建部署」的流程。
> Gitea 远端是必须的:推送上去才会触发自动部署、更新线上网站。
## 一、Git 远端
- 远端名:`gitea`
- 地址:`http://8.137.165.96:3000/shizhui/shizhui_website.git`
- 本地 `main` 已跟踪 `gitea/main`
## 二、日常流程(同一台电脑)
```bash
# 1. 开工前先拉最新(同步其他设备 / CMS 在线编辑的改动)
git pull
# 2. 改代码 …… 本地预览
npm run dev # http://localhost:4321
# 3. 构建自测可选CI 也会构建)
npm run build
# 4. 提交并推送 → 自动触发构建部署
git add -A
git commit -m "说明本次改动"
git push
```
推送后约 30~60 秒Gitea Actions 自动完成构建并发布到 `/var/www/shizhui`
线上网站随即更新。
## 三、换一台新电脑开发
```bash
git clone http://8.137.165.96:3000/shizhui/shizhui_website.git
cd shizhui_website
npm install
# 之后照「日常流程」即可
```
## 四、Git 凭据(重要)
远端走 HTTPpush/pull 需要 Gitea 账号密码(用户 `shizhui``developer`)。
为避免每次输入,二选一:
**方式 A缓存凭据推荐简单**
```bash
git config --global credential.helper store
# 第一次 push 时输入一次账号密码,之后会记住
```
**方式 B在 URL 里带用户名(仍会提示输密码)**
```bash
git remote set-url gitea http://shizhui@8.137.165.96:3000/shizhui/shizhui_website.git
```
> 注意:`credential.helper store` 会把密码明文存到 `~/.git-credentials`
> 个人电脑可接受;公用电脑慎用。
## 五、多设备协作的纪律
- **开工先 `git pull`,完工再 `git push`**。
- 这样本地、其他电脑、CMS 在线编辑三方都能和谐共存。
- 若 push 被拒(提示 rejected / non-fast-forward`git pull --rebase` 再 push。
## 六、备案完成后
域名 ICP 备案通过后,可把访问与远端从 IP 切回域名:
- 网站https://shizhui.xyz
- Gitea可改回 https://git.shizhui.xyz需相应调整 Gitea ROOT_URL 与反代)
- 届时通知我,我来切换并收尾(关闭 8080 测试端口等)。
## 七、状态自检(怀疑线上与代码不一致时)
```bash
# 本地与远端是否一致(输出为空即一致)
git fetch gitea && git log gitea/main..main --oneline
# 线上标题是否为最新
curl -s http://8.137.165.96:8080/ | grep -o "<title>[^<]*</title>"
```