feat: 更新 RemoteApp 类以支持 ListenProcessParams 和改进消息处理逻辑

fix: 更新 package.json 版本号至 0.1.2
feat: 在部署函数中添加 detect 标志以增强功能
This commit is contained in:
2026-02-05 03:00:51 +08:00
parent 037146bf51
commit a46510949b
3 changed files with 12 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import type { App } from '@kevisual/router';
import type { App, ListenProcessParams } from '@kevisual/router';
import { EventEmitter } from 'eventemitter3';
type RemoteAppOptions = {
app?: App;
@@ -7,6 +7,9 @@ type RemoteAppOptions = {
emitter?: EventEmitter;
id?: string;
};
/**
* 远程共享地址类似https://kevisual.cn/ws/proxy
*/
export class RemoteApp {
mainApp: App;
url: string;
@@ -108,8 +111,6 @@ export class RemoteApp {
this.emitter.off(event, listener);
};
}
sendData(data: any) { }
json(data: any) {
this.ws.send(JSON.stringify(data));
}
@@ -119,8 +120,10 @@ export class RemoteApp {
const listenFn = async (event: any) => {
try {
const data = event.toString();
const body = JSON.parse(data);
const message = body.data || {};
const body = JSON.parse(data)
const bodyData = body?.data as ListenProcessParams;
const message = bodyData?.message || {};
const context = bodyData?.context || {};
if (body?.code === 401) {
console.error('远程应用认证失败,请检查 token 是否正确');
this.isError = true;
@@ -138,12 +141,12 @@ export class RemoteApp {
return;
}
const res = await app.call(message);
const res = await app.run(message, context);
remoteApp.json({
id: body.id,
data: {
code: res.code,
data: res.body,
data: res.data,
message: res.message,
},
});

View File

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

View File

@@ -236,6 +236,7 @@ const deployLoadFn = async (id: string, org?: string) => {
data: {
id: id,
username: org,
detect: true,
},
});
if (res.code === 200) {