Skip to content

Commit

Permalink
feat: Own deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
xjh22222228 committed Aug 20, 2024
1 parent 4e3ec3c commit e54256f
Show file tree
Hide file tree
Showing 45 changed files with 12,163 additions and 756 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ Thumbs.db

# build output
src/index.html
nav.config.json
_upload
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
- 🍰 支持从浏览器书签导入
- 🍰 支持将数据导出到浏览器书签
- 🍰 支持用户提交收录
- 🍰 支持自有部署/Fork
- 🍰 丰富的资源配置系统
- 🍰 支持 SEO 搜索引擎
- 🍰 支持网站关联多个网址
Expand All @@ -62,7 +63,6 @@
- 🍰 多种卡片风格设计
- 🍰 完全纯静态, 提供自动化部署功能
- 🍰 三叉树分类、结构清晰、分类清晰
- 🍰 颜值与简约并存,不再是杀马特时代
- 🍰 完全开源,轻松定制化

## 预览
Expand Down Expand Up @@ -93,7 +93,7 @@

4、打开 https://github.com/你的用户名/nav/actions 开启 action 自动部署

5、修改项目根目录配置文件 [nav.config.ts](nav.config.ts) 只需要修改仓库地址
5、修改项目根目录配置文件 [package.json](package.json) 只需要修改仓库地址 `gitRepoUrl` 字段

6、打开 https://你的用户名.github.io/nav 就能看到一个非常强大的导航网站了。

Expand All @@ -109,22 +109,32 @@

[https://github.com/apps/vercel](https://github.com/apps/vercel)

#### 关于自有部署
#### 自有部署

前提服务器必须能访问公网。(内网收益太小,暂时不加入需求,有需要的可以众筹) 也可以将仓库设为私有
自有部署一直不是发现导航的需求目标,但陆续有人问,决定从`v8.8.0`版本开始支持!

将代码拉到服务器 `git clone https://github.com/xjh22222228/nav.git` 还需要安装`Node >= 18`
[成为我们的会员](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/support2.png)

执行 `npm i && npm run build`
#### Fork vs 自有部署

```bash
# 启动 公网IP:7777, 后台系统配置请求地址填写:公网IP:7777/server
npm run server
```
| | 自有部署 | Fork |
| -------- | ---------------- | ---------------- |
| 速度 | 保存即时生效 | 需要等待构建完成 |
| 成本 | 需要自己有服务器 | 免费 |
| 数据存储 | 定时`git push` | 永久存储 |

#### 其他
## 配置说明

如果您有更好的部署方式,请给我们提 PR
只需要修改根目录 `package.json` 以下相关字段
|Fork |自有部署 | 字段 | 说明 |
| --------------------------------------------- | -------- |--- |--- |
|| | gitRepoUrl | 填写您的仓库地址 |
|| | provider | 部署平台,`Github` / `Gitee`, 作者 `Gitee` 仓库地址 [https://gitee.com/xiejiahe/nav](https://gitee.com/xiejiahe/nav) |
|| | branch | 部署分支 |
||| hashMode | 路由是否 Hash 模式, 如果是部署在 `github pages` 务必设为 true |
| || password | 自有部署登录密码,`Fork` 用户无需填写 |
| || address | 自有部署, 一旦填写认为你是自有部署,`https://你的域名或IP:7777` |
||| email | 用户提交收录通知 |

## 后台

Expand All @@ -134,6 +144,8 @@ npm run server

#### 自动

仅限于 `Fork` 用户

[点这里安装 Pull](https://github.com/apps/pull) , 只要有升级会自动给你的仓库提交 `Pull Requests` 点击合并即可。

#### 手动
Expand Down
1 change: 0 additions & 1 deletion data/db.json

Large diffs are not rendered by default.

23 changes: 0 additions & 23 deletions nav.config.ts

This file was deleted.

31 changes: 19 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
{
"gitRepoUrl": "https://github.com/xjh22222228/nav",
"provider": "Github",
"branch": "main",
"hashMode": false,
"address": "http://localhost:7777",
"password": "admin",
"port": 7777,
"email": "",
"----------------": "----------------以下字段无需处理--------------------------",
"================": "网站所有内容都是可以在后台系统配置的,不懂的不要擅自修改源代码,出现异常请自行处理",
"name": "nav",
"version": "8.7.0",
"author": "xiejiahe",
"bugs": {
"url": "https://github.com/xjh22222228/nav/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/xjh22222228/nav.git"
},
"homepage": "https://github.com/xjh22222228/nav",
"scripts": {
"ng": "ng",
"start": "npm run build-internal && ng serve --port=7001",
"build-internal": "ts-node ./scripts/internal.mjs",
"setup": "npm run build-internal && tsc nav.config.ts && ts-node ./scripts/build.mjs",
"start": "npm run build-start && ng serve --port=7001",
"build-start": "ts-node ./scripts/start.mjs",
"setup": "npm run build-start && ts-node ./scripts/build.mjs",
"build-gh-pages": "npm run setup && ng build --base-href ./ --index src/index.html && ts-node ./scripts/done.mjs",
"build": "npm run setup && ng build --index src/index.html && ts-node ./scripts/done.mjs",
"watch": "ng build --watch --configuration development",
"update": "git pull && (git remote add upstream https://gitee.com/xiejiahe/nav.git || true) && git fetch upstream main && git merge upstream/main --allow-unrelated-histories --no-edit && git push",
"pull": "git pull",
"server": "pm2 start server.js",
"restartServer": "pm2 restart server"
"server": "pm2 start server.mjs",
"restartServer": "pm2 restart server",
"stopServer": "pm2 stop server"
},
"private": true,
"dependencies": {
Expand Down Expand Up @@ -58,6 +62,9 @@
"@angular/compiler-cli": "^18.0.1",
"@types/jasmine": "~5.1.4",
"@types/nprogress": "^0.2.3",
"body-parser": "^1.20.2",
"compression": "^1.7.4",
"connect-history-api-fallback": "^2.0.0",
"cors": "^2.8.5",
"info-web": "^0.0.29",
"jasmine-core": "~5.1.2",
Expand Down
Loading

0 comments on commit e54256f

Please sign in to comment.