feat: 更新 RemoteApp 类以支持 ListenProcessParams 和改进消息处理逻辑
fix: 更新 package.json 版本号至 0.1.2 feat: 在部署函数中添加 detect 标志以增强功能
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import type { App } from '@kevisual/router';
|
import type { App, ListenProcessParams } from '@kevisual/router';
|
||||||
import { EventEmitter } from 'eventemitter3';
|
import { EventEmitter } from 'eventemitter3';
|
||||||
type RemoteAppOptions = {
|
type RemoteAppOptions = {
|
||||||
app?: App;
|
app?: App;
|
||||||
@@ -7,6 +7,9 @@ type RemoteAppOptions = {
|
|||||||
emitter?: EventEmitter;
|
emitter?: EventEmitter;
|
||||||
id?: string;
|
id?: string;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 远程共享地址类似:https://kevisual.cn/ws/proxy
|
||||||
|
*/
|
||||||
export class RemoteApp {
|
export class RemoteApp {
|
||||||
mainApp: App;
|
mainApp: App;
|
||||||
url: string;
|
url: string;
|
||||||
@@ -108,8 +111,6 @@ export class RemoteApp {
|
|||||||
this.emitter.off(event, listener);
|
this.emitter.off(event, listener);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sendData(data: any) { }
|
|
||||||
json(data: any) {
|
json(data: any) {
|
||||||
this.ws.send(JSON.stringify(data));
|
this.ws.send(JSON.stringify(data));
|
||||||
}
|
}
|
||||||
@@ -119,8 +120,10 @@ export class RemoteApp {
|
|||||||
const listenFn = async (event: any) => {
|
const listenFn = async (event: any) => {
|
||||||
try {
|
try {
|
||||||
const data = event.toString();
|
const data = event.toString();
|
||||||
const body = JSON.parse(data);
|
const body = JSON.parse(data)
|
||||||
const message = body.data || {};
|
const bodyData = body?.data as ListenProcessParams;
|
||||||
|
const message = bodyData?.message || {};
|
||||||
|
const context = bodyData?.context || {};
|
||||||
if (body?.code === 401) {
|
if (body?.code === 401) {
|
||||||
console.error('远程应用认证失败,请检查 token 是否正确');
|
console.error('远程应用认证失败,请检查 token 是否正确');
|
||||||
this.isError = true;
|
this.isError = true;
|
||||||
@@ -138,12 +141,12 @@ export class RemoteApp {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
const res = await app.call(message);
|
const res = await app.run(message, context);
|
||||||
remoteApp.json({
|
remoteApp.json({
|
||||||
id: body.id,
|
id: body.id,
|
||||||
data: {
|
data: {
|
||||||
code: res.code,
|
code: res.code,
|
||||||
data: res.body,
|
data: res.data,
|
||||||
message: res.message,
|
message: res.message,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/cli",
|
"name": "@kevisual/cli",
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"description": "envision 命令行工具",
|
"description": "envision 命令行工具",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"basename": "/root/cli",
|
"basename": "/root/cli",
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ const deployLoadFn = async (id: string, org?: string) => {
|
|||||||
data: {
|
data: {
|
||||||
id: id,
|
id: id,
|
||||||
username: org,
|
username: org,
|
||||||
|
detect: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
|
|||||||
Reference in New Issue
Block a user