Skip to content

Commit

Permalink
fixed:Fixed connection timeout shareable issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoJiSen committed Aug 28, 2024
1 parent 4e21538 commit 9264408
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
1 change: 0 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"serve": "vite",
"build": "vue-tsc -b && vite build",
"preview": "vite preview",
Expand Down
11 changes: 8 additions & 3 deletions ui/src/components/Kubernetes/MainContent/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import CustomTerminal from '@/components/CustomTerminal/index.vue';
// import TabSuffix from '@/components/Kubernetes/MainContent/components/TabSuffix/index.vue';
// 引入 type
import { NMessageProvider, TabPaneProps, useDialog } from 'naive-ui';
import { NMessageProvider, TabPaneProps, useDialog, useNotification } from 'naive-ui';
import type { Ref } from 'vue';
import type { ISettingProp, shareUser } from '@/views/interface';
Expand All @@ -90,6 +90,8 @@ const treeStore = useTreeStore();
const { t } = useI18n();
const dialog = useDialog();
const notification = useNotification();
const paramsStore = useParamsStore();
const terminalStore = useTerminalStore();
Expand Down Expand Up @@ -268,8 +270,11 @@ const onSocketData = (msgType: string, msg: any, terminal: Terminal) => {
break;
}
case 'CLOSE': {
sessionId.value = '';
message.error(t('WebSocketClosed'));
enableShare.value = false;
notification.error({
content: t('WebSocketClosed'),
duration: 50000
});
break;
}
default:
Expand Down
4 changes: 0 additions & 4 deletions ui/src/hooks/useTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export const useTerminal = async (el: HTMLElement, option: ICallbackOptions): Pr
break;
}
case 'CLOSE': {
terminal?.writeln('Receive Connection Closed');
socket.close();
sendEventToLuna('CLOSE', '');
break;
Expand Down Expand Up @@ -150,8 +149,6 @@ export const useTerminal = async (el: HTMLElement, option: ICallbackOptions): Pr
}
case 'TERMINAL_ERROR':
case 'ERROR': {
message.error(msg.err);
terminal?.writeln(msg.err);
break;
}
case 'MESSAGE_NOTIFY': {
Expand Down Expand Up @@ -273,7 +270,6 @@ export const useTerminal = async (el: HTMLElement, option: ICallbackOptions): Pr
break;
}
case 'TERMINAL_ERROR': {
// message.error(`Socket Error ${socketData.err}`);
terminal?.write(socketData.err);
break;
}
Expand Down
10 changes: 7 additions & 3 deletions ui/src/views/Connection/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { useLogger } from '@/hooks/useLogger.ts';
import { useDialog, useMessage } from 'naive-ui';
import { useDialog, useMessage, useNotification } from 'naive-ui';
import { useParamsStore } from '@/store/modules/params.ts';
import { useTerminalStore } from '@/store/modules/terminal.ts';
Expand Down Expand Up @@ -50,6 +50,7 @@ const { setting } = storeToRefs(paramsStore);
const dialog = useDialog();
const message = useMessage();
const notification = useNotification();
const terminalType = ref<string>('common');
const sessionId = ref<string>('');
Expand Down Expand Up @@ -238,8 +239,11 @@ const onSocketData = (msgType: string, msg: any, terminal: Terminal) => {
break;
}
case 'ClOSE': {
sessionId.value = '';
message.error(t('WebSocketClosed'));
enableShare.value = false;
notification.error({
content: t('WebSocketClosed'),
duration: 50000
});
break;
}
default:
Expand Down

0 comments on commit 9264408

Please sign in to comment.