Update cn doc (#840)

update cn doc for pr #835, fix some other problems.

---------

Co-authored-by: Mattes Mohr <mail@mattesmohr.de>
This commit is contained in:
JIN 2023-07-05 02:05:37 +08:00 committed by GitHub
parent 82894c6d41
commit e2260b0a0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 19 deletions

View File

@ -13,7 +13,7 @@ Heroku 是一个一站式程序托管平台,你可以通过[heroku.com](https:
### HomeBrew
```bash
brew install heroku/brew/heroku
brew tap heroku/brew && brew install heroku
```
### 其他安装方式
@ -52,7 +52,7 @@ git init
#### Master
默认情况下Heroku 部署 **master** 分支。 确保在推送之前将所有更改都加入此分支。
你应该选择一个分支,并坚持将其用于部署到 Heroku比如 **main****master** 分支。确保在推送之前将所有更改都加入此分支。
通过以下命令检查你当前的分支:
@ -63,7 +63,7 @@ git branch
星号表示当前分支。
```bash
* master
* main
commander
other-branches
```
@ -71,10 +71,10 @@ git branch
> **提示**:如果你没有看到任何输出并且你刚刚执行了 `git init`。 你需要先提交commit你的代码然后你会看到 `git branch` 命令的输出。
如果你当前 _不在_ **master** 上,请输入以下命令来切换
如果你当前 _不在_ 正确的分支上,请输入以下命令来切换(针对 **main** 分支来说)
```bash
git checkout master
git checkout main
```
#### 提交更改
@ -110,13 +110,13 @@ heroku buildpacks:set vapor/vapor
### Swift 版本文件
我们添加的运行包会查找 **.swift-version** 文件以了解要使用的 swift 版本。 (将 5.2.1 替换为你的项目需要的任何版本。)
我们添加的运行包会查找 **.swift-version** 文件以了解要使用的 swift 版本。 (将 5.8.1 替换为你的项目需要的任何版本。)
```bash
echo "5.2.1" > .swift-version
echo "5.8.1" > .swift-version
```
这将创建 **.swift-version** ,内容为 `5.2.1`。
这将创建 **.swift-version** ,内容为 `5.8.1`。
### Procfile
@ -150,12 +150,12 @@ git commit -m "adding heroku build files"
你已准备好开始部署,从终端运行以下命令。 构建过程可能会需要一些时间,不必担心。
```none
git push heroku master
git push heroku main
```
### 扩展
成功构建后,你需要添加至少一台服务器,一个网站服务是免费的,你可以通过以下方式获得它
成功构建后,你需要添加至少一台服务器,Eco 计划的价格从每月$5起参见[定价](https://www.heroku.com/pricing#containers)),请确保在 Heroku 上配置了付款方式。然后,针对单个 web worker 执行下面命令
```bash
heroku ps:scale web=1
@ -163,7 +163,7 @@ heroku ps:scale web=1
### 继续部署
当你想更新时只需将最新的更改推入 master 分支并推送到 heroku它就会重新部署。
当你想更新时只需将最新的更改推入 main 分支并推送到 heroku它就会重新部署。
## Postgres
@ -171,9 +171,9 @@ heroku ps:scale web=1
在 dashboard.heroku.com 上访问你的应用程序,然后转到 **Add-ons** 部分。
从这里输入`postgress`,你会看到`Heroku Postgres`的选项。 选择它。
从这里输入`postgres`,你会看到`Heroku Postgres`的选项。 选择它。
选择爱好开发免费计划hobby dev free plan。 Heroku 将自动完成剩下的工作
选择每月$5的 Eco 计划(参见[定价](https://www.heroku.com/pricing#data-services)),并进行预配。剩下的交给 Heroku 处理
完成后,你会看到数据库出现在 **Resources** 选项卡下。

View File

@ -38,7 +38,7 @@ app.middleware.use(fileMiddleware)
## Sources
此文件夹包含项目的所有 Swift 源文件。 顶级文件夹“App”反映了您的包的模块,如 [SwiftPM](spm.md) 清单中声明的那样。
此文件夹包含项目的所有 Swift 源文件。 顶级文件夹 `App` 反映了你的包的模块,如 [SwiftPM](spm.md) 清单中声明的那样。
### App
@ -62,11 +62,11 @@ models 文件夹常用于存放 `Content` 和 Fluent `Model` 的类或结构体
#### entrypoint.swift
该文件包含用于设置、配置和运行 Vapor 应用程序的应用程序的“@main”入口点
该文件包含应用程序的 `@main` 入口点,用于设置、配置和运行 Vapor 应用程序。
#### routes.swift
这个文件包含 `routes(_:)` 方法,它会在 `configure(_:)` 结尾处被调用,用以将路由注册到你的`Application`。
这个文件包含 `routes(_:)` 方法,它会在 `configure(_:)` 结尾处被调用,用以将路由注册到你的 `Application`
## Tests

View File

@ -17,7 +17,7 @@ vapor new hello -n
```
!!! tip "建议"
使用 `-n` 为所有的问题自动选择 no 来为提供一个基本的模板。
使用 `-n` 为所有的问题自动选择 no 来为提供一个基本的模板。
!!! tip "建议"
你也可以不使用 Vapor Toolbox直接从 GitHub 克隆[模板库](https://github.com/vapor/template-bare)来获取最新的模板。

View File

@ -49,13 +49,13 @@ let package = Package(
### Platforms
`platforms` 数组指定此程序包支持的平台和版本。通过指定 `.macOS.v12`,说明此软件包需要 macOS 12 或更高版本。 Xcode 加载该项目时,它将最低部署版本设置为 macOS 12以便你可以使用所有可用的 API。
`platforms` 数组指定此程序包支持的平台和版本。通过指定 `.macOS.v12)`,说明此软件包需要 macOS 12 或更高版本。 Xcode 加载该项目时,它将最低部署版本设置为 macOS 12以便你可以使用所有可用的 API。
### Dependencies
dependencies 字段代表项目需要依赖的 package。所有 Vapor 应用都依赖 Vapor package ,但是你也可以添加其它想要的依赖库。
如上面这个示例,[vapor/vapor](https://github.com/vapor/vapor) 4.0 或以上版本是这个 package 的 dependency。当在 package 中添加了 dependency 后,接下来你必须设置是哪个 targets 依赖了新的可用模块。
如上面这个示例,[vapor/vapor](https://github.com/vapor/vapor) 4.76.0 或以上版本是这个 package 的 dependency。当在 package 中添加了 dependency 后,接下来你必须设置是哪个 targets 依赖了新的可用模块。
### Targets