Skip to content

Commit

Permalink
Merge pull request #9 from TTB-Network/i18n
Browse files Browse the repository at this point in the history
New Crowdin updates
  • Loading branch information
SilianZ authored Jun 22, 2024
2 parents 814f2c5 + 8d203c9 commit f08954e
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 200 deletions.
2 changes: 1 addition & 1 deletion i18n/en/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"message": "Getting started"
},
"homepage.button.info": {
"message": "Learn More"
"message": "Learn more"
},
"homepage.feature.easy-to-use.title": {
"message": "Easy to use"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ title: 配置文件
sidebar_position: 1
---

````mdx-code-block
```mdx-code-block
import "@site/src/css/table.css";
````
```

## 配置文件 {#configuration-file}

Expand Down Expand Up @@ -68,83 +68,75 @@ web:

该部分为进阶配置,仅作调试使用,在正常使用 python-openbmclapi 时**不需要**更改该部分的配置项。

````mdx-code-block
<div className="apiTable">

| 参数 | 类型 | 默认值 | 是否必填 | 描述 |
| ------------------------- | --------- | --------------------------------------- | -------- | ------------------------------------------------------------ |
| `auto_update` | `boolean` | `false` | 否 | 是否启用自动更新(自动更新时会下载最新版本的 Release 压缩包)。 |
| `copy_from_other_storage` | `boolean` | `true` | 否 | 是否在同步文件时使用已配置储存进行同步。 |
| `debug` | `boolean` | `false` | 否 | 是否启用调试模式。 |
| `download_threads` | `int` | `64` | 否 | 最高下载线程。 |
| `header_bytes` | `int` | `4096` | 否 | 新连接读取数据头大小。 |
| `io_buffer` | `int` | `16777216` | 否 | 数据传输缓存大小。 |
| `language` | `string` | `'zh_cn'` | 否 | 语言。 |
| `min_rate` | `int` | `500` | 否 | 最小读取速率(Bytes)。 |
| `min_rate_timestamp` | `int` | `1000` | 否 | 最小读取速率时间。 |
| `request_buffer` | `int` | `8192` | 否 | 请求缓存大小。 |
| `skip_sign` | `boolean` | `false` | 否 | 是否跳过签名检测。 |
| `timeout` | `int` | `30` | 否 | 超时时间。 |
| 参数 | 类型 | 默认值 | 是否必填 | 描述 |
| ------------------------- | --------- | --------------------------------------- | ------- | ---------------------------------------------------------- |
| `auto_update` | `boolean` | `false` | 否 | 是否启用自动更新(自动更新时会下载最新版本的 Release 压缩包)。 |
| `copy_from_other_storage` | `boolean` | `true` | 否 | 是否在同步文件时使用已配置储存进行同步。 |
| `debug` | `boolean` | `false` | 否 | 是否启用调试模式。 |
| `download_threads` | `int` | `64` | 否 | 最高下载线程。 |
| `header_bytes` | `int` | `4096` | 否 | 新连接读取数据头大小。 |
| `io_buffer` | `int` | `16777216` | 否 | 数据传输缓存大小。 |
| `language` | `string` | `'zh_cn'` | 否 | 语言。 |
| `min_rate` | `int` | `500` | 否 | 最小读取速率(Bytes)。 |
| `min_rate_timestamp` | `int` | `1000` | 否 | 最小读取速率时间。 |
| `request_buffer` | `int` | `8192` | 否 | 请求缓存大小。 |
| `skip_sign` | `boolean` | `false` | 否 | 是否跳过签名检测。 |
| `timeout` | `int` | `30` | 否 | 超时时间。 |
| `url` | `string` | `'https://openbmclapi.bangbang93.com/'` | 否 | OpenBMCLAPI 的 BaseURL。 |

</div>
````

### `cache` {#cache}

该部分为对文件缓存的配置。

````mdx-code-block
<div className="apiTable">

| 参数 | 类型 | 默认值 | 是否必填 | 描述 |
| -------- | --------- | ----------- | -------- | ------------------------ |
| `buffer` | `int` | `536870912` | 否 | 缓存大小(Bytes)。 |
| `check` | `int` | `360` | 否 | 检查过时文件时间(秒)。 |
| `enable` | `boolean` | `true` | 否 | 是否启用缓存。 |
| `time` | `int` | `1800` | 否 | 缓存保留时间(秒)。 |
| 参数 | 类型 | 默认值 | 是否必填 | 描述 |
| -------- | --------- | ----------- | ------- | ---------------------- |
| `buffer` | `int` | `536870912` | 否 | 缓存大小(Bytes)。 |
| `check` | `int` | `360` | 否 | 检查过时文件时间(秒)。 |
| `enable` | `boolean` | `true` | 否 | 是否启用缓存。 |
| `time` | `int` | `1800` | 否 | 缓存保留时间(秒)。 |

</div>
````

### `cluster` {#cluster}

该部分为节点配置。

````mdx-code-block
<div className="apiTable">

| 参数 | 类型 | 默认值 | 是否必填 | 描述 |
| ------------------- | --------- | ------- | -------- | -------------------------------------------------- |
| `byoc` | `boolean` | `false` | 否 | 是否不使用 BMCLAPI 分发的证书, 同 `CLUSTER_BYOC`。 |
| `enable` | `boolean` | `true` | 否 | 是否启用节点。 |
| 参数 | 类型 | 默认值 | 是否必填 | 描述 |
| ------------------- | --------- | ------- | ------- | ------------------------------------------------ |
| `byoc` | `boolean` | `false` | 否 | 是否不使用 BMCLAPI 分发的证书, 同 `CLUSTER_BYOC`。 |
| `enable` | `boolean` | `true` | 否 | 是否启用节点。 |
| `id` | `string` | `''` | 是 | OpenBMCLAPI 的 `CLUSTER_ID`。 |
| `public_host` | `boolean` | `''` | 否 | 实际开放的公网主机名, 同 `CLUSTER_IP`。 |
| `public_port` | `int` | `8800` | 否 | 实际开放的公网端口, 同 `CLUSTER_PUBLIC_PORT`。 |
| `reconnect.delay` | `int` | `60` | 否 | 重连间隔。 |
| `reconnect.retry` | `int` | `-1` | 否 | 重连次数,`-1` 为无限次数。 |
| `public_host` | `boolean` | `''` | 否 | 实际开放的公网主机名, 同 `CLUSTER_IP`。 |
| `public_port` | `int` | `8800` | 否 | 实际开放的公网端口, 同 `CLUSTER_PUBLIC_PORT`。 |
| `reconnect.delay` | `int` | `60` | 否 | 重连间隔。 |
| `reconnect.retry` | `int` | `-1` | 否 | 重连次数,`-1` 为无限次数。 |
| `secret` | `string` | `''` | 是 | OpenBMCLAPI 的 `CLUSTER_SECRET`。 |
| `timeout.enable` | `int` | `120` | 否 | 发送启用数据包超时时间。 |
| `timeout.keepalive` | `int` | `300` | 否 | 发送保活数据包超时时间。 |
| `timeout.enable` | `int` | `120` | 否 | 发送启用数据包超时时间。 |
| `timeout.keepalive` | `int` | `300` | 否 | 发送保活数据包超时时间。 |

</div>
````

### `dashboard` {#dashboard}

该部分为仪表盘配置。

````mdx-code-block
<div className="apiTable">

| 参数 | 类型 | 默认值 | 是否必填 | 说明 |
| ----------- | --------- | ----------- | -------- | ---------------------------------------- |
| `password` | `string` | `undefined` | 否 | 仪表盘的密码(若未配置程序会自动生成)。 |
| `username` | `string` | `'admin'` | 否 | 仪表盘用户名。 |
| `websocket` | `boolean` | `true` | 否 | 是否启用 WebSocket。 |
| 参数 | 类型 | 默认值 | 是否必填 | 说明 |
| ----------- | --------- | ----------- | ------- | -------------------------------------- |
| `password` | `string` | `undefined` | 否 | 仪表盘的密码(若未配置程序会自动生成)。 |
| `username` | `string` | `'admin'` | 否 | 仪表盘用户名。 |
| `websocket` | `boolean` | `true` | 否 | 是否启用 WebSocket。 |

</div>
````

### `storages` {#storages}

Expand All @@ -161,17 +153,15 @@ bmclapi: # 你的存储名字,可以使用任何英文名称
width: 0
```

````mdx-code-block
<div className="apiTable">

| 参数 | 类型 | 是否必填 | 说明 |
| ------- | -------- | -------- | ------------------------------------------------------------ |
| `path` | `string` | 是 | 存储路径。 |
| `type` | `string` | 是 | 储存类型,可选值为 `file`(本地存储)和 `webdav`(WebDAV)。 |
| `width` | `int` | 是 | 选用存储下载权重,`-1` 为禁用,不选择,但会下载文件。 |
| 参数 | 类型 | 是否必填 | 说明 |
| ------- | -------- | ------- | ---------------------------------------------------------- |
| `path` | `string` | 是 | 存储路径。 |
| `type` | `string` | 是 | 储存类型,可选值为 `file`(本地存储)和 `webdav`(WebDAV)。 |
| `width` | `int` | 是 | 选用存储下载权重,`-1` 为禁用,不选择,但会下载文件。 |

</div>
````

#### 使用 WebDAV 储存

Expand All @@ -185,33 +175,29 @@ bmclapi_webdav:
password: password
```

````mdx-code-block
<div className="apiTable">

| 参数 | 类型 | 是否必填 | 说明 |
| ---------- | -------- | -------- | ------------------------------------------------------------ |
| `path` | `string` | 是 | 存储路径。 |
| `type` | `string` | 是 | 储存类型,可选值为 `file`(本地存储)和 `webdav`(WebDAV)。 |
| `width` | `int` | 是 | 选用存储下载权重,`-1` 为禁用,不选择,但会下载文件。 |
| `endpoint` | `string` | 是 | 你的 WebDAV 端点。 |
| `username` | `string` | 是 | WebDAV 用户名。 |
| `password` | `string` | 是 | WebDAV 用户密码。 |
| 参数 | 类型 | 是否必填 | 说明 |
| ---------- | -------- | ------- | ---------------------------------------------------------- |
| `path` | `string` | 是 | 存储路径。 |
| `type` | `string` | 是 | 储存类型,可选值为 `file`(本地存储)和 `webdav`(WebDAV)。 |
| `width` | `int` | 是 | 选用存储下载权重,`-1` 为禁用,不选择,但会下载文件。 |
| `endpoint` | `string` | 是 | 你的 WebDAV 端点。 |
| `username` | `string` | 是 | WebDAV 用户名。 |
| `password` | `string` | 是 | WebDAV 用户密码。 |

</div>
````

### `web` {#web}

该部分为 Web 相关的配置。

````mdx-code-block
<div className="apiTable">

| 参数 | 类型 | 默认值 | 是否必填 |
| ------------- | --------- | ------------- | -------- |
| 参数 | 类型 | 默认值 | 是否必填 |
| ------------- | --------- | ------------- | ------- |
| `force_ssl` | `boolean` | `false` | 否 |
| `port` | `int` | `8080` | 否 |
| `server_name` | `string` | `TTB-Network` | 否 |

</div>
````
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ __NAME__ = "Example Plugin"

**变量说明:**

| 参数 | 类型 | 说明 |
| ------------- | -------- | ------ |
| `__VERSION__` | `string` | 插件的版本。 |
| `__AUTHOR__` | `string` | 插件的作者。 |
| `__NAME__` | `string` | 插件的名称。 |
| 参数 | 类型 | 说明 |
| ------------- | -------- | ---------- |
| `__VERSION__` | `string` | 插件的版本。 |
| `__AUTHOR__` | `string` | 插件的作者。 |
| `__NAME__` | `string` | 插件的名称。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: 使用 Docker
---

1. 在你的机器上安装好 [Docker](https://docker.com/)

2. 拉取镜像:

```sh
docker pull silianz/python-openbmclapi:latest
```

::::info

你也可使用镜像源进行拉取:

```sh
docker pull registry.cn-hangzhou.aliyuncs.com/silianz/python-openbmclapi:latest
```

::::

3. 创建容器:

```sh
docker run -d \
-v /path/to/your/cache:/opt/python-openbmclapi/bmclapi \
-e cluster.id=${cluster.id} \
-e cluster.secret=${cluster.secret} \
-e cluster.public_port=${cluster.public_port} \
-p ${cluster.public_port}:8080 \
--restart always \
--name python-openbmclapi \
silianz/python-openbmclapi
```

**参数说明:**

`cluster.public_port` - 对外开放的端口。

`cluster.id` - 即 `CLUSTER_ID`

`cluster.secret` - 即 `CLUSTER_SECRET`

::::info

其他配置参数请参见[配置文件](/docs/advanced/configuration),请使用**命名空间 ID** 将相应的配置项作为环境变量传入到 Docker 容器中。

在某些特定的情况下,你可能无法将某些配置参数传入容器,此时你可以尝试挂载配置文件,只需在容器启动命令中加上这条参数:

```sh
-v /path/to/your/config/file:/opt/python-openbmclapi/config/config.yml
```

:::tip 命名空间 ID

命名空间 ID 是将配置项传入 Docker 容器的一种方法。

```yml title="config/config.yml"
dashboard:
password: ""
username: admin
websocket: true
```
这是一段示例的配置项,将这些配置项转化为命名空间 ID 分别为:
```properties
dashboard.password=""
dashboard.user=admin
dashboard.websocker=true
```

在转化配置项为命名空间 ID 时,使用 `.` 连接配置项的键与值。

:::
::::
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,41 @@ title: 配置
sidebar_position: 2
---

````mdx-code-block
```mdx-code-block
import Asciinema from "@site/src/components/Asciinema";
````
```

1. 运行一次主程序生成配置文件:

```sh
python main.py
```

````mdx-code-block
<Asciinema
url="https://asciinema.org/a/655202.cast"
options={{
theme: "monokai",
poster: "npt:21.5",
cols: 100,
rows: 30,
idleTimeLimit: 0.2,
}}
/>
````


如果你看到以下报错信息:`core.exceptions.ClusterIdNotSet`,恭喜你!你可以进行下一步的配置了。
```sh
python main.py
```

```mdx-code-block
<Asciinema
url="https://asciinema.org/a/655202.cast"
options={{
theme: "monokai",
poster: "npt:21.5",
cols: 100,
rows: 30,
idleTimeLimit: 0.2,
}}
/>
```

如果你看到以下报错信息:`core.exceptions.ClusterIdNotSet`,恭喜你!你可以进行下一步的配置了。

2.`config/config.yml` 中,填写你的 `id`(即 `CLUSTER_ID`)和 `secret`(即 `CLUSTER_SECRET`)。

```yml title="config/config.yml" {3,6}
cluster:
byoc: false
id: '' # OpenBMCLAPI 的 CLUSTER_ID
public_host: ''
...
secret: '' # OpenBMCLAPI 的 CLUSTER_SECRET
skip_sign: false
```
```yml title="config/config.yml" {3,6}
cluster:
byoc: false
id: '' # OpenBMCLAPI 的 CLUSTER_ID
public_host: ''
...
secret: '' # OpenBMCLAPI 的 CLUSTER_SECRET
skip_sign: false
```
3. 重新启动程序以应用最新配置。
Loading

0 comments on commit f08954e

Please sign in to comment.