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