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 参数启动服务');
}