Skip to content

Commit

Permalink
fixed:Fixed an issue where the request tree would go white when the S…
Browse files Browse the repository at this point in the history
…ocket was closed
  • Loading branch information
ZhaoJiSen committed Aug 27, 2024
1 parent b5f25e6 commit 1afaff1
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"serve": "vite",
"build": "vue-tsc -b && vite build",
"preview": "vite preview",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Kubernetes/MainContent/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ const onSocketData = (msgType: string, msg: any, terminal: Terminal) => {
}
case 'CLOSE': {
sessionId.value = '';
message.error(t('TerminalClosed'));
message.error(t('WebSocketClosed'));
break;
}
default:
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Kubernetes/Tree/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<n-descriptions label-placement="top" class="tree-wrapper">
<template #header>
<n-flex align="center" justify="space-between">
{{ t('List of Assets') }}
{{ t('KubernetesManagement') }}
<n-icon size="16px" :component="EllipsisHorizontal" class="mr-2.5 cursor-pointer" />
</n-flex>
</template>
Expand Down
6 changes: 3 additions & 3 deletions ui/src/hooks/helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export const generateWsURL = () => {
break;
}
case 'kubernetes': {
connectURL = `${BASE_WS_URL}/koko/ws/terminal/?token=${route.query.token}`;
connectURL = `${BASE_WS_URL}/koko/ws/terminal/?token=${route.query.token}&type=k8s`;
break;
}
case 'Share': {
Expand Down Expand Up @@ -322,11 +322,11 @@ export const generateWsURL = () => {
export const onWebsocketWrong = (event: Event, type: string, terminal?: Terminal) => {
switch (type) {
case 'error': {
terminal ? terminal.write('Connection Websocket Error') : message.error('Error');
terminal ? terminal.write('Connection Websocket Error') : '';
break;
}
case 'disconnected': {
terminal ? terminal.write('Connection Websocket Closed') : message.error('Disconnected');
terminal ? terminal.write('Connection Websocket Closed') : '';
break;
}
}
Expand Down
2 changes: 0 additions & 2 deletions ui/src/hooks/useK8s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ export const useK8s = () => {
}
case 'CLOSE':
case 'ERROR': {
message.error('Receive Connection Closed');

socket.close();
break;
}
Expand Down
15 changes: 13 additions & 2 deletions ui/src/hooks/useTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const useTerminal = async (el: HTMLElement, option: ICallbackOptions): Pr
break;
}
case 'CLOSE': {
terminal?.writeln('Receive Connection closed');
terminal?.writeln('Receive Connection Closed');
socket.close();
sendEventToLuna('CLOSE', '');
break;
Expand Down Expand Up @@ -273,7 +273,7 @@ export const useTerminal = async (el: HTMLElement, option: ICallbackOptions): Pr
break;
}
case 'TERMINAL_ERROR': {
message.error(`Socket Error ${socketData.err}`);
// message.error(`Socket Error ${socketData.err}`);
terminal?.write(socketData.err);
break;
}
Expand Down Expand Up @@ -526,6 +526,17 @@ export const useTerminal = async (el: HTMLElement, option: ICallbackOptions): Pr
});

mittBus.on('sync-theme', ({ type, data }) => {
if (option.type === 'k8s') {
return socket.send(
JSON.stringify({
k8s_id: k8s_id.value,
id: terminalId.value,
type,
data: JSON.stringify(data)
})
);
}

sendWsMessage(type, data);
});
};
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/Connection/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const onSocketData = (msgType: string, msg: any, terminal: Terminal) => {
}
case 'ClOSE': {
sessionId.value = '';
message.error(t('TerminalClosed'));
message.error(t('WebSocketClosed'));
break;
}
default:
Expand Down

0 comments on commit 1afaff1

Please sign in to comment.