{"id":21418951,"url":"https://github.com/hal-wang/navigation","last_synced_at":"2025-09-10T01:39:56.501Z","repository":{"id":45727336,"uuid":"365505205","full_name":"hal-wang/navigation","owner":"hal-wang","description":"用于自定义域名跳转，无需服务器，一键搭建至腾讯云。可以任意域名跳转到任意链接，也可以让域名返回特定消息","archived":false,"fork":false,"pushed_at":"2023-04-20T14:30:36.000Z","size":309,"stargazers_count":12,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-28T03:15:12.094Z","etag":null,"topics":["halsp"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hal-wang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-08T12:10:31.000Z","updated_at":"2023-12-02T19:37:57.000Z","dependencies_parsed_at":"2023-01-17T22:15:51.868Z","dependency_job_id":null,"html_url":"https://github.com/hal-wang/navigation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hal-wang%2Fnavigation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hal-wang%2Fnavigation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hal-wang%2Fnavigation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hal-wang%2Fnavigation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hal-wang","download_url":"https://codeload.github.com/hal-wang/navigation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225953820,"owners_count":17550768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["halsp"],"created_at":"2024-11-22T19:30:46.986Z","updated_at":"2024-11-22T19:32:20.029Z","avatar_url":"https://github.com/hal-wang.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# navigation\n\n用于自定义域名跳转，无需服务器，一键搭建\n\n可以任意域名跳转到任意链接\n\n也可以让域名返回特定消息\n\n一键部署：\n[![](https://main.qcloudimg.com/raw/67f5a389f1ac6f3b4d04c7256438e44f.svg)](https://console.cloud.tencent.com/tcb/env/index?action=CreateAndDeployCloudBaseProject\u0026appUrl=https%3A%2F%2Fgithub.com%2Fhal-wang%2Fnavigation\u0026branch=main)\n\n## 配置\n\n### 配置默认链接\n\n添加环境变量 `DEFAULT_URL`，值为默认链接\n\nGET 请求找不到跳转目标时，会跳转到默认链接，否则返回 404\n\n### 添加访问服务\n\n添加想要跳转的域名至访问服务\n\n- 触发路径为 `/`\n- 关联资源为云函数 `navigation`\n\n### 添加跳转\n\n在云数据库中的集合 `navigation` 添加文档\n\n```JSON\n{\n  \"_id\": \"domain\",\n  \"to\": \"to url\",\n  \"type\": 1,\n  \"code\": \"status code\"\n}\n```\n\n- \\_id: 要跳转的域名，通过这个域名访问将会跳转请求，与前面访问服务添加的域名相同\n- to: 跳转目标，内容与 type 有关\n- type: 类型\n  - 0 域名跳转，to 是域名，会传递路由参数\n  - 1 路径跳转，跳转到 to 指定的路径\n  - 2 返回消息，结构为 `{\"message\":\"to\"}`\n  - 3 返回消息，内容是 to\n- code: 跳转的状态码\n\n  - type 为 0，1 时，状态码 `code` 应为 `30x`，如 `301`,`302`,`306`,`307` 等\n\n## 二次开发\n\n如果现有功能不能满足，你可以进行二次开发\n\n### 本地运行\n\n在项目下创建文件 `.env.local`，内容如下\n\n```\nENV_ID=cloudbase环境id\nSECRET_KEY=腾讯云 secret key\nSECRET_ID=腾讯云 secret id\nDEFAULT_URL=默认跳转链接\n```\n\n安装依赖，在项目下执行\n\n```sh\nnpm install\n```\n\n再使用 vscode 打开项目，直接 F5 开始调试\n\n或在项目下执行\n\n```sh\nnpm start\n```\n\n### 发布\n\n可以本地使用 `@cloudbase/cli` 发布，也可以使用 GitHub Actions 持续集成\n\n#### cli 发布\n\n确保项目根目录下有文件 `.env.local`，内容包含\n\n```\nENV_ID=cloudbase环境id\nDEFAULT_URL=默认链接\n```\n\n在项目根目录下运行以下命令发布\n\n```sh\nnpm install @cloudbase/cli -g\nnpm run deploy\n```\n\n#### GitHub Actions\n\n仓库增加 Secrets，在 `Settings -\u003e Secrets -\u003e Actions`，点击 `New repository secret` 按钮\n\n增加如下记录\n\n- TENCENT_SECRET_ID: 腾讯云 secret id\n- TENCENT_SECRET_KEY: 腾讯云 secret key\n- ENV: 与 `cli 发布` 的 `.env.local` 文件内容相同\n\n配置完成后，每次 main 分支提交代码就会自动发布到 CloudBase\n\n发布进度可在仓库 `Actions` 中看到\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhal-wang%2Fnavigation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhal-wang%2Fnavigation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhal-wang%2Fnavigation/lists"}