fix: 修复配置文档中的表格格式;添加路由配置示例

This commit is contained in:
2026-01-22 01:53:51 +08:00
parent 18a6fd4cfe
commit ddfdb63598
4 changed files with 98 additions and 51 deletions

View File

@@ -127,8 +127,8 @@ export class AssistantApp extends Manager {
}
async initRouterApp() {
const config = this.config.getConfig();
const routerProxy = config.router.proxy || [];
const base = config.router.base ?? false;
const routerProxy = config?.router?.proxy || [];
const base = config.router?.base ?? false;
if (base) {
routerProxy.push({
type: 'router',

View File

@@ -9,7 +9,7 @@ import { program } from 'commander';
import { spawnSync } from 'node:child_process';
import path from 'node:path'
import chalk from 'chalk';
import { AssistantApp } from './lib.ts';
import { AssistantApp, checkFileExists } from './lib.ts';
import { getBunPath } from './module/get-bun-path.ts';
import { qwenAsr } from './services/asr/qwen-asr.ts';
export const runServer = async (port: number = 51515, listenPath = '127.0.0.1') => {
@@ -72,6 +72,7 @@ program
.option('-p, --port <port>', '服务端口')
.option('-s, --start', '是否启动服务')
.option('-r, --root <root>', '工作空间路径')
.option('-i, --input <input>', '启动的输入文件,例如/workspace/src/main.ts')
.option('-e, --interpreter <interpreter>', '指定使用的解释器', 'bun')
.action(async (options) => {
// console.log('当前执行路径:', execPath, inte);
@@ -105,6 +106,9 @@ program
if (options.root) {
pm2Command += ` --root ${options.root}`;
}
if (options.input) {
pm2Command += ` --input ${options.input}`;
}
console.log(chalk.gray('执行命令:'), pm2Command);
console.log(chalk.gray('脚本路径:'), runPath);
@@ -151,6 +155,12 @@ program
const listenPort = parseInt(options.port || config?.server?.port);
const listenPath = config?.server?.path || '::';
const server = await runServer(listenPort, listenPath);
if (options.input) {
const _input = path.resolve(options.input);
if (checkFileExists(_input)) {
await import(_input);
}
}
} else {
console.log('请使用 -s 参数启动服务');
}

View File

@@ -23,7 +23,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ---- | -------- | ------------------------------------------ |
| id | `string` | 应用唯一标识符,用于识别具体设备或应用实例 |
| url | `string` | 应用访问地址 |
@@ -38,7 +38,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ----- | -------- | -------- |
| token | `string` | 访问令牌 |
## registry - 注册中心
@@ -52,7 +52,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| -------- | -------- | ------------ |
| registry | `string` | 注册中心地址 |
## proxy - 前端代理配置
@@ -72,7 +72,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ---------------- | ------------- | ---------------------- |
| proxy | `ProxyInfo[]` | 代理配置数组 |
| proxy[].path | `string` | 匹配的路径前缀 |
| proxy[].target | `string` | 目标服务器地址 |
@@ -105,6 +105,31 @@ createdAt: '2025-12-18'
|------|------|{------|
| 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 - 应用描述
应用的描述信息。
@@ -116,7 +141,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ----------- | -------- | ------------ |
| description | `string` | 应用描述信息 |
## server - 服务器配置
@@ -133,7 +158,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ----------- | --------- | -------------------------------- |
| server.path | `string`` | 服务器监听地址,默认 `127.0.0.1` |
| server.port | `number` | 服务器监听端口号 |
@@ -151,7 +176,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ------------- | --------- | -------------------- |
| share.url | `string` | 远程应用代理地址 |
| share.enabled | `boolean` | 是否启用远程访问功能 |
@@ -168,7 +193,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ------------- | --------- | ---------------- |
| watch.enabled | `boolean` | 是否启用文件监听 |
## home - 首页路径
@@ -182,7 +207,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ---- | -------- | -------- |
| home | `string` | 首页路径 |
## ai - AI功能配置
@@ -201,7 +226,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ----------- | --------- | ---------------------------- | ---------- |
| ai.enabled | `boolean` | 是否启用 AI 功能 |
| ai.provider | `string` | AI 提供商,可选 `'DeepSeek'` | `'Custom'` |
| ai.apiKey | `string` | API 密钥 |
@@ -221,7 +246,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ----------- | --------- | -------------------- |
| asr.enabled | `boolean` | 是否启用语音识别功能 |
| asr.token | `string` | 阿里云 ASR 服务令牌 |
@@ -240,10 +265,11 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ---------- | -------- | ------------------------------------------------- |
| auth.share | `string` | 共享访问模式,影响 pages 目录下页面的对外共享权限 |
**share 可选值:**
- `"protected"` - 需要认证才能访问(默认)
- `"public"` - 公开访问,无需认证
- `"private"` - 私有访问,完全禁止外部访问
@@ -294,7 +320,7 @@ createdAt: '2025-12-18'
```
| 字段 | 类型 | 说明 |
|------|------|------|
| ------------------------- | ---------------------------- | ------------------------------------------------------- |
| storage[].id | `string` | 存储标识符,唯一标识一个存储配置 |
| storage[].type | `'local' \| 's3' \| 'minio'` | 存储类型 |
| storage[].path | `string` | 本地存储路径(仅 type 为 `local` 时有效) |
@@ -329,6 +355,17 @@ createdAt: '2025-12-18'
}
]
},
"router": {
"proxy": [
{
"type": "router",
"router": {
"url": "https://kevisual.cn/api/router"
}
}
],
"base": true
},
"description": "生产环境助手应用",
"server": {
"path": "0.0.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@kevisual/cli",
"version": "0.0.91",
"version": "0.0.92",
"description": "envision 命令行工具",
"type": "module",
"basename": "/root/cli",