fix: 修复配置文档中的表格格式;添加路由配置示例
This commit is contained in:
@@ -127,8 +127,8 @@ export class AssistantApp extends Manager {
|
|||||||
}
|
}
|
||||||
async initRouterApp() {
|
async initRouterApp() {
|
||||||
const config = this.config.getConfig();
|
const config = this.config.getConfig();
|
||||||
const routerProxy = config.router.proxy || [];
|
const routerProxy = config?.router?.proxy || [];
|
||||||
const base = config.router.base ?? false;
|
const base = config.router?.base ?? false;
|
||||||
if (base) {
|
if (base) {
|
||||||
routerProxy.push({
|
routerProxy.push({
|
||||||
type: 'router',
|
type: 'router',
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { program } from 'commander';
|
|||||||
import { spawnSync } from 'node:child_process';
|
import { spawnSync } from 'node:child_process';
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import { AssistantApp } from './lib.ts';
|
import { AssistantApp, checkFileExists } from './lib.ts';
|
||||||
import { getBunPath } from './module/get-bun-path.ts';
|
import { getBunPath } from './module/get-bun-path.ts';
|
||||||
import { qwenAsr } from './services/asr/qwen-asr.ts';
|
import { qwenAsr } from './services/asr/qwen-asr.ts';
|
||||||
export const runServer = async (port: number = 51515, listenPath = '127.0.0.1') => {
|
export const runServer = async (port: number = 51515, listenPath = '127.0.0.1') => {
|
||||||
@@ -72,6 +72,7 @@ program
|
|||||||
.option('-p, --port <port>', '服务端口')
|
.option('-p, --port <port>', '服务端口')
|
||||||
.option('-s, --start', '是否启动服务')
|
.option('-s, --start', '是否启动服务')
|
||||||
.option('-r, --root <root>', '工作空间路径')
|
.option('-r, --root <root>', '工作空间路径')
|
||||||
|
.option('-i, --input <input>', '启动的输入文件,例如/workspace/src/main.ts')
|
||||||
.option('-e, --interpreter <interpreter>', '指定使用的解释器', 'bun')
|
.option('-e, --interpreter <interpreter>', '指定使用的解释器', 'bun')
|
||||||
.action(async (options) => {
|
.action(async (options) => {
|
||||||
// console.log('当前执行路径:', execPath, inte);
|
// console.log('当前执行路径:', execPath, inte);
|
||||||
@@ -105,6 +106,9 @@ program
|
|||||||
if (options.root) {
|
if (options.root) {
|
||||||
pm2Command += ` --root ${options.root}`;
|
pm2Command += ` --root ${options.root}`;
|
||||||
}
|
}
|
||||||
|
if (options.input) {
|
||||||
|
pm2Command += ` --input ${options.input}`;
|
||||||
|
}
|
||||||
console.log(chalk.gray('执行命令:'), pm2Command);
|
console.log(chalk.gray('执行命令:'), pm2Command);
|
||||||
console.log(chalk.gray('脚本路径:'), runPath);
|
console.log(chalk.gray('脚本路径:'), runPath);
|
||||||
|
|
||||||
@@ -151,6 +155,12 @@ program
|
|||||||
const listenPort = parseInt(options.port || config?.server?.port);
|
const listenPort = parseInt(options.port || config?.server?.port);
|
||||||
const listenPath = config?.server?.path || '::';
|
const listenPath = config?.server?.path || '::';
|
||||||
const server = await runServer(listenPort, listenPath);
|
const server = await runServer(listenPort, listenPath);
|
||||||
|
if (options.input) {
|
||||||
|
const _input = path.resolve(options.input);
|
||||||
|
if (checkFileExists(_input)) {
|
||||||
|
await import(_input);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('请使用 -s 参数启动服务');
|
console.log('请使用 -s 参数启动服务');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ---- | -------- | ------------------------------------------ |
|
||||||
| id | `string` | 应用唯一标识符,用于识别具体设备或应用实例 |
|
| id | `string` | 应用唯一标识符,用于识别具体设备或应用实例 |
|
||||||
| url | `string` | 应用访问地址 |
|
| url | `string` | 应用访问地址 |
|
||||||
|
|
||||||
## token - 访问令牌
|
## token - 访问令牌
|
||||||
|
|
||||||
@@ -37,8 +37,8 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ----- | -------- | -------- |
|
||||||
| token | `string` | 访问令牌 |
|
| token | `string` | 访问令牌 |
|
||||||
|
|
||||||
## registry - 注册中心
|
## registry - 注册中心
|
||||||
@@ -51,8 +51,8 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| -------- | -------- | ------------ |
|
||||||
| registry | `string` | 注册中心地址 |
|
| registry | `string` | 注册中心地址 |
|
||||||
|
|
||||||
## proxy - 前端代理配置
|
## proxy - 前端代理配置
|
||||||
@@ -71,12 +71,12 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ---------------- | ------------- | ---------------------- |
|
||||||
| proxy | `ProxyInfo[]` | 代理配置数组 |
|
| proxy | `ProxyInfo[]` | 代理配置数组 |
|
||||||
| proxy[].path | `string` | 匹配的路径前缀 |
|
| proxy[].path | `string` | 匹配的路径前缀 |
|
||||||
| proxy[].target | `string` | 目标服务器地址 |
|
| proxy[].target | `string` | 目标服务器地址 |
|
||||||
| proxy[].pathname | `string` | 转发到目标服务器的路径 |
|
| proxy[].pathname | `string` | 转发到目标服务器的路径 |
|
||||||
|
|
||||||
示例:访问 `/root/home` 会被转发到 `https://kevisual.cn/root/home`
|
示例:访问 `/root/home` 会被转发到 `https://kevisual.cn/root/home`
|
||||||
|
|
||||||
@@ -105,6 +105,31 @@ createdAt: '2025-12-18'
|
|||||||
|------|------|{------|
|
|------|------|{------|
|
||||||
| api.proxy | `ProxyInfo[]` | API代理配置数组 |
|
| api.proxy | `ProxyInfo[]` | API代理配置数组 |
|
||||||
|
|
||||||
|
## router - 路由配置
|
||||||
|
|
||||||
|
配置应用的路由代理功能。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"router": {
|
||||||
|
"proxy": [
|
||||||
|
{
|
||||||
|
"type": "router",
|
||||||
|
"router": {
|
||||||
|
"url": "https://kevisual.cn/api/router"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"base": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
| ------------ | ------------- | ----------------------------------------------------------------- |
|
||||||
|
| router.proxy | `ProxyInfo[]` | 代理配置数组 |
|
||||||
|
| router.base | `boolean` | 是否注册基础路由,监听https://kevisual.cn/api/router,默认 `false` |
|
||||||
|
|
||||||
## description - 应用描述
|
## description - 应用描述
|
||||||
|
|
||||||
应用的描述信息。
|
应用的描述信息。
|
||||||
@@ -115,8 +140,8 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ----------- | -------- | ------------ |
|
||||||
| description | `string` | 应用描述信息 |
|
| description | `string` | 应用描述信息 |
|
||||||
|
|
||||||
## server - 服务器配置
|
## server - 服务器配置
|
||||||
@@ -132,10 +157,10 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ----------- | --------- | -------------------------------- |
|
||||||
| server.path | `string`` | 服务器监听地址,默认 `127.0.0.1` |
|
| server.path | `string`` | 服务器监听地址,默认 `127.0.0.1` |
|
||||||
| server.port | `number` | 服务器监听端口号 |
|
| server.port | `number` | 服务器监听端口号 |
|
||||||
|
|
||||||
## share - 远程访问配置
|
## share - 远程访问配置
|
||||||
|
|
||||||
@@ -150,9 +175,9 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ------------- | --------- | -------------------- |
|
||||||
| share.url | `string` | 远程应用代理地址 |
|
| share.url | `string` | 远程应用代理地址 |
|
||||||
| share.enabled | `boolean` | 是否启用远程访问功能 |
|
| share.enabled | `boolean` | 是否启用远程访问功能 |
|
||||||
|
|
||||||
## watch - 文件监听配置
|
## watch - 文件监听配置
|
||||||
@@ -167,8 +192,8 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ------------- | --------- | ---------------- |
|
||||||
| watch.enabled | `boolean` | 是否启用文件监听 |
|
| watch.enabled | `boolean` | 是否启用文件监听 |
|
||||||
|
|
||||||
## home - 首页路径
|
## home - 首页路径
|
||||||
@@ -181,8 +206,8 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ---- | -------- | -------- |
|
||||||
| home | `string` | 首页路径 |
|
| home | `string` | 首页路径 |
|
||||||
|
|
||||||
## ai - AI功能配置
|
## ai - AI功能配置
|
||||||
@@ -200,12 +225,12 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ----------- | --------- | ---------------------------- | ---------- |
|
||||||
| ai.enabled | `boolean` | 是否启用 AI 功能 |
|
| ai.enabled | `boolean` | 是否启用 AI 功能 |
|
||||||
| ai.provider | `string` | AI 提供商,可选 `'DeepSeek'` | `'Custom'` |
|
| ai.provider | `string` | AI 提供商,可选 `'DeepSeek'` | `'Custom'` |
|
||||||
| ai.apiKey | `string` | API 密钥 |
|
| ai.apiKey | `string` | API 密钥 |
|
||||||
| ai.model | `string` | 使用的模型名称 |
|
| ai.model | `string` | 使用的模型名称 |
|
||||||
|
|
||||||
## asr - 语音识别配置
|
## asr - 语音识别配置
|
||||||
|
|
||||||
@@ -220,10 +245,10 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ----------- | --------- | -------------------- |
|
||||||
| asr.enabled | `boolean` | 是否启用语音识别功能 |
|
| asr.enabled | `boolean` | 是否启用语音识别功能 |
|
||||||
| asr.token | `string` | 阿里云 ASR 服务令牌 |
|
| asr.token | `string` | 阿里云 ASR 服务令牌 |
|
||||||
|
|
||||||
使用模型:`qwen3-asr-flash-realtime`
|
使用模型:`qwen3-asr-flash-realtime`
|
||||||
|
|
||||||
@@ -239,11 +264,12 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ---------- | -------- | ------------------------------------------------- |
|
||||||
| auth.share | `string` | 共享访问模式,影响 pages 目录下页面的对外共享权限 |
|
| auth.share | `string` | 共享访问模式,影响 pages 目录下页面的对外共享权限 |
|
||||||
|
|
||||||
**share 可选值:**
|
**share 可选值:**
|
||||||
|
|
||||||
- `"protected"` - 需要认证才能访问(默认)
|
- `"protected"` - 需要认证才能访问(默认)
|
||||||
- `"public"` - 公开访问,无需认证
|
- `"public"` - 公开访问,无需认证
|
||||||
- `"private"` - 私有访问,完全禁止外部访问
|
- `"private"` - 私有访问,完全禁止外部访问
|
||||||
@@ -293,16 +319,16 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
|------|------|------|
|
| ------------------------- | ---------------------------- | ------------------------------------------------------- |
|
||||||
| storage[].id | `string` | 存储标识符,唯一标识一个存储配置 |
|
| storage[].id | `string` | 存储标识符,唯一标识一个存储配置 |
|
||||||
| storage[].type | `'local' \| 's3' \| 'minio'` | 存储类型 |
|
| storage[].type | `'local' \| 's3' \| 'minio'` | 存储类型 |
|
||||||
| storage[].path | `string` | 本地存储路径(仅 type 为 `local` 时有效) |
|
| storage[].path | `string` | 本地存储路径(仅 type 为 `local` 时有效) |
|
||||||
| storage[].bucket | `string` | 存储桶名称(仅 type 为 `s3` 或 `minio` 时有效) |
|
| storage[].bucket | `string` | 存储桶名称(仅 type 为 `s3` 或 `minio` 时有效) |
|
||||||
| storage[].region | `string` | 存储区域(仅 type 为 `s3` 或 `minio` 时有效) |
|
| storage[].region | `string` | 存储区域(仅 type 为 `s3` 或 `minio` 时有效) |
|
||||||
| storage[].accessKeyId | `string` | 访问密钥 ID(仅 type 为 `s3` 或 `minio` 时有效) |
|
| storage[].accessKeyId | `string` | 访问密钥 ID(仅 type 为 `s3` 或 `minio` 时有效) |
|
||||||
| storage[].secretAccessKey | `string` | 访问密钥(仅 type 为 `s3` 或 `minio` 时有效) |
|
| storage[].secretAccessKey | `string` | 访问密钥(仅 type 为 `s3` 或 `minio` 时有效) |
|
||||||
| storage[].endpoint | `string` | 服务端点地址(仅 type 为 `s3` 或 `minio` 时有效,可选) |
|
| storage[].endpoint | `string` | 服务端点地址(仅 type 为 `s3` 或 `minio` 时有效,可选) |
|
||||||
|
|
||||||
## 完整配置示例
|
## 完整配置示例
|
||||||
|
|
||||||
@@ -329,6 +355,17 @@ createdAt: '2025-12-18'
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"router": {
|
||||||
|
"proxy": [
|
||||||
|
{
|
||||||
|
"type": "router",
|
||||||
|
"router": {
|
||||||
|
"url": "https://kevisual.cn/api/router"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"base": true
|
||||||
|
},
|
||||||
"description": "生产环境助手应用",
|
"description": "生产环境助手应用",
|
||||||
"server": {
|
"server": {
|
||||||
"path": "0.0.0.0",
|
"path": "0.0.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/cli",
|
"name": "@kevisual/cli",
|
||||||
"version": "0.0.91",
|
"version": "0.0.92",
|
||||||
"description": "envision 命令行工具",
|
"description": "envision 命令行工具",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"basename": "/root/cli",
|
"basename": "/root/cli",
|
||||||
|
|||||||
Reference in New Issue
Block a user