From 8a1aff4c5023cc1dd99a2b595aa3eec4869c5704 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Sun, 25 Jan 2026 21:19:28 +0800 Subject: [PATCH] update --- src/route.ts | 3 ++- src/utils/listen-process.ts | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/route.ts b/src/route.ts index df9bdcd..bb7a9cd 100644 --- a/src/route.ts +++ b/src/route.ts @@ -614,7 +614,8 @@ export class QueryRouter { } /** * 等待程序运行, 获取到message的数据,就执行 - * + * params 是预设参数,默认path为main + * * emitter = process * -- .exit * -- .on diff --git a/src/utils/listen-process.ts b/src/utils/listen-process.ts index b08d568..9963852 100644 --- a/src/utils/listen-process.ts +++ b/src/utils/listen-process.ts @@ -2,7 +2,7 @@ export type ListenProcessOptions = { app?: any; // 传入的应用实例 emitter?: any; // 可选的事件发射器 params?: any; // 可选的参数 - timeout?: number; // 可选的超时时间 (单位: 毫秒) + timeout?: number; // 可选的超时时间 (单位: 毫秒) 默认 10 分钟 }; export const listenProcess = async ({ app, emitter, params, timeout = 10 * 60 * 60 * 1000 }: ListenProcessOptions) => { const process = emitter || globalThis.process; @@ -27,9 +27,10 @@ export const listenProcess = async ({ app, emitter, params, timeout = 10 * 60 * } try { - const { path = 'main', ...rest } = await getParams() + const { path = 'main', payload = {}, ...rest + } = await getParams() // 执行主要逻辑 - const result = await app.queryRoute({ path, ...rest, ...params }) + const result = await app.queryRoute({ path, ...params, ...rest, payload: { ...params.payload, ...payload } }) // 发送结果回主进程 const response = { success: true,