diff --git a/assets/scripts/dec.js b/assets/scripts/dec.js index f33b0d6..cd2412e 100644 --- a/assets/scripts/dec.js +++ b/assets/scripts/dec.js @@ -16,6 +16,8 @@ window.DecCst = { EditStatusEvent: { OPEN: 'getConnectionStatus', SHUTDOWN: 'shutdownConnectionStatus', + CONNECTION_EDITED: 'connectionEdited', + CONNECTION_RELEASED: 'connectionReleased', } }, Hyperlink: { diff --git a/src/modules/constants/env.ts b/src/modules/constants/env.ts index 8ff0057..e3ce683 100644 --- a/src/modules/constants/env.ts +++ b/src/modules/constants/env.ts @@ -12,6 +12,8 @@ export const connectionType: { export const editStatusEvent: { OPEN: string; SHUTDOWN: string; + CONNECTION_EDITED: string, + CONNECTION_RELEASED: string, } = DecCst.Connect.EditStatusEvent; export const errorCode: { diff --git a/src/modules/crud/api.ts b/src/modules/crud/api.ts index 12d4f0c..fa0f2d4 100644 --- a/src/modules/crud/api.ts +++ b/src/modules/crud/api.ts @@ -63,6 +63,12 @@ export interface Api { */ getConnectionStatus(name: string): Promise; + /** + * 设置编辑状态 + * @param name + */ + setEditedConnectionStatus(name: string): void; + /** * 关闭连接 * @param name diff --git a/src/modules/crud/decision.api.ts b/src/modules/crud/decision.api.ts index 1963071..942941c 100644 --- a/src/modules/crud/decision.api.ts +++ b/src/modules/crud/decision.api.ts @@ -86,8 +86,12 @@ export class DecisionApi implements Api { }); } + setEditedConnectionStatus(name: string): Promise { + return this.sendEditStatusEvent(name, editStatusEvent.CONNECTION_EDITED); + } + shutdownConnectionStatus(name: string): Promise { - return this.sendEditStatusEvent(name, editStatusEvent.SHUTDOWN); + return this.sendEditStatusEvent(name, editStatusEvent.CONNECTION_RELEASED); } getSocketStatus(): boolean { @@ -119,7 +123,7 @@ export class DecisionApi implements Api { private sendEditStatusEvent(name: string, type: string): Promise { return new Promise(resolve => { if (Dec?.socket?.connected) { - Dec.socketEmit(type, BI.encode(name), (re: any) => { + Dec.socket.emit(type, BI.encode(name), (re: any) => { resolve(re); }); } else { diff --git a/src/modules/pages/maintain/maintain.ts b/src/modules/pages/maintain/maintain.ts index 98ff521..137ccfe 100644 --- a/src/modules/pages/maintain/maintain.ts +++ b/src/modules/pages/maintain/maintain.ts @@ -81,6 +81,8 @@ export class Maintain extends BI.Widget { }); this.socketTip.setVisible(true); } + + api.setEditedConnectionStatus(this.model.connectionSelectedOne.connectionName); } private renderItems() { diff --git a/types/globals.d.ts b/types/globals.d.ts index 09a8987..7e81c07 100644 --- a/types/globals.d.ts +++ b/types/globals.d.ts @@ -9,6 +9,7 @@ declare const Dec: { fineServletURL: string; socket: { connected: boolean; + emit: Function; }; system: {