fix: 优化connect ws的模块
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/assistant-cli",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.8",
|
||||
"description": "",
|
||||
"main": "dist/assistant.mjs",
|
||||
"keywords": [
|
||||
|
||||
@@ -100,7 +100,9 @@ export class AssistantApp extends Manager {
|
||||
if (isConnect) {
|
||||
remoteApp.listenProxy();
|
||||
this.remoteIsConnected = true;
|
||||
remoteApp.emitter.once('close', () => {
|
||||
// 清理已有的 close 事件监听器,防止多重绑定
|
||||
remoteApp.emitter.removeAllListeners('close');
|
||||
remoteApp.emitter.on('close', () => {
|
||||
setTimeout(() => {
|
||||
if (remoteApp.isError) {
|
||||
console.error('远程应用发生错误,不重连');
|
||||
@@ -201,8 +203,8 @@ export class AssistantApp extends Manager {
|
||||
remoteApp.listenProxy();
|
||||
this.attemptedConnectTimes = 0;
|
||||
console.log('重新连接到了远程应用服务器');
|
||||
this.reconnectRemoteApp();
|
||||
} else {
|
||||
this.reconnectRemoteApp();
|
||||
setTimeout(() => {
|
||||
this.initRouterApp()
|
||||
}, 30 * 1000 + this.attemptedConnectTimes * 10 * 1000); // 30秒后重连 + 每次增加10秒
|
||||
|
||||
@@ -138,11 +138,18 @@ export const initLightCode = async (opts: opts) => {
|
||||
continue;
|
||||
}
|
||||
// console.log(`注册 light-code 路由: [${routerItem.path}] ${routerItem.id} 来自文件: ${file.filepath}`);
|
||||
const metadata = routerItem.metadata || {};
|
||||
if (metadata.tags && Array.isArray(metadata.tags)) {
|
||||
metadata.tags.push('light-code');
|
||||
} else {
|
||||
metadata.tags = ['light-code'];
|
||||
}
|
||||
app.route({
|
||||
id: routerItem.id,
|
||||
path: routerItem.id!,
|
||||
path: `${routerItem.id}__${routerItem.path}`,
|
||||
key: routerItem.key,
|
||||
description: routerItem.description || '',
|
||||
metadata: routerItem.metadata || {},
|
||||
metadata,
|
||||
middleware: ['auth'],
|
||||
}).define(async (ctx) => {
|
||||
const tokenUser = ctx.state?.tokenUser || {};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/cli",
|
||||
"version": "0.0.93",
|
||||
"version": "0.0.94",
|
||||
"description": "envision 命令行工具",
|
||||
"type": "module",
|
||||
"basename": "/root/cli",
|
||||
|
||||
Reference in New Issue
Block a user