wip(docs): i18n (#12681)
This commit is contained in:
142
packages/web/src/content/docs/zh-cn/web.mdx
Normal file
142
packages/web/src/content/docs/zh-cn/web.mdx
Normal file
@@ -0,0 +1,142 @@
|
||||
---
|
||||
title: 網路
|
||||
description: 在浏览器中使用OpenCode。
|
||||
---
|
||||
|
||||
OpenCode 可以在浏览器中作为 Web 应用程序执行,消耗终端可以提供同样强大的 AI 编码体验。
|
||||
|
||||

|
||||
|
||||
## 入門
|
||||
|
||||
绕过执行以下命令启动 Web 简介:
|
||||
|
||||
```bash
|
||||
opencode web
|
||||
```
|
||||
|
||||
这将在 `127.0.0.1` 上启动一个具有随机可用端口的本地服务器,并自动在默认浏览器中开启 OpenCode。
|
||||
|
||||
:::警告
|
||||
如果未设置`OPENCODE_SERVER_PASSWORD`,服务器将不安全。这对于本地使用来说很好,但应该针对网路访问进行设置。
|
||||
:::
|
||||
|
||||
:::tip[Windows 使用者]
|
||||
For the best experience, run `opencode web` from [WSL](/docs/windows-wsl) rather than PowerShell. This ensures proper file system access and terminal integration.
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
## 配置
|
||||
|
||||
您可以使用命令列标志或在[config file](/docs/config).conf 中配置Web服务器。
|
||||
|
||||
### 港口
|
||||
|
||||
默认情况下,OpenCode 选择一个可用的端口。您可以指定一个端口:
|
||||
|
||||
```bash
|
||||
opencode web --port 4096
|
||||
```
|
||||
|
||||
### 主機名
|
||||
|
||||
情况默认下,服务器系结到`127.0.0.1`(仅限本地主机)。要使OpenCode在您的网路上可访问:
|
||||
|
||||
```bash
|
||||
opencode web --hostname 0.0.0.0
|
||||
```
|
||||
|
||||
使用`0.0.0.0`时,OpenCode将显示本地地址和网络地址:
|
||||
|
||||
```
|
||||
Local access: http://localhost:4096
|
||||
Network access: http://192.168.1.100:4096
|
||||
```
|
||||
|
||||
### mDNS 发现
|
||||
|
||||
启用 mDNS 使您的服务器在本地网上可以发现:
|
||||
|
||||
```bash
|
||||
opencode web --mdns
|
||||
```
|
||||
|
||||
This automatically sets the hostname to `0.0.0.0` and advertises the server as `opencode.local`.
|
||||
|
||||
您可以自定义 mDNS 域名以在同一网路上执行多个示例:
|
||||
|
||||
```bash
|
||||
opencode web --mdns --mdns-domain myproject.local
|
||||
```
|
||||
|
||||
### CORS
|
||||
|
||||
允许CORS使用其他域(对于自定义前缀有用):
|
||||
|
||||
```bash
|
||||
opencode web --cors https://example.com
|
||||
```
|
||||
|
||||
### 驗證
|
||||
|
||||
要保护访问,请使用 `OPENCODE_SERVER_PASSWORD` 环境变数设置密码:
|
||||
|
||||
```bash
|
||||
OPENCODE_SERVER_PASSWORD=secret opencode web
|
||||
```
|
||||
|
||||
The username defaults to `opencode` but can be changed with `OPENCODE_SERVER_USERNAME`.
|
||||
|
||||
---
|
||||
|
||||
## 使用網路介面
|
||||
|
||||
启动后,网路界面将提供对您的 OpenCode 会话的访问。
|
||||
|
||||
### 會議
|
||||
|
||||
從主頁檢視和管理您的會話。您可以檢視活動會話並開始新會話。
|
||||
|
||||

|
||||
|
||||
### 伺服器狀態
|
||||
|
||||
單擊“檢視伺服器”可檢視連線的伺服器及其狀態。
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
## 連線終端
|
||||
|
||||
您可以将终端 TUI 连线到正在执行的 Web 服务器:
|
||||
|
||||
```bash
|
||||
# Start the web server
|
||||
opencode web --port 4096
|
||||
|
||||
# In another terminal, attach the TUI
|
||||
opencode attach http://localhost:4096
|
||||
```
|
||||
|
||||
这允许您同时使用 Web 界面和终端,共享相同的会话和状态。
|
||||
|
||||
---
|
||||
|
||||
## 配置檔案
|
||||
|
||||
You can also configure server settings in your `opencode.json` config file:
|
||||
|
||||
```json
|
||||
{
|
||||
"server": {
|
||||
"port": 4096,
|
||||
"hostname": "0.0.0.0",
|
||||
"mdns": true,
|
||||
"cors": ["https://example.com"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
命令列標誌優先於配置檔案設定。
|
||||
Reference in New Issue
Block a user