Skip to content

Commit

Permalink
fixed: Problems with repairing the clone window
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoJiSen committed Nov 5, 2024
1 parent ca5f231 commit f12a399
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
2 changes: 0 additions & 2 deletions ui/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ declare module 'vue' {
export interface GlobalComponents {
ContentHeader: typeof import('./src/components/Kubernetes/ContentHeader/index.vue')['default']
CustomTerminal: typeof import('./src/components/CustomTerminal/index.vue')['default']
Index1: typeof import('./src/components/Kubernetes/MainContent/index.vue')['default']
K8sTerminal: typeof import('./src/components/k8sTerminal/index.vue')['default']
Logo: typeof import('./src/components/Kubernetes/Sidebar/components/Logo/index.vue')['default']
Main: typeof import('./src/components/Kubernetes/MainContent/main.vue')['default']
MainContent: typeof import('./src/components/Kubernetes/MainContent/index.vue')['default']
Expand Down
25 changes: 11 additions & 14 deletions ui/src/components/Kubernetes/MainContent/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import Share from '@/components/Share/index.vue';
import Settings from '@/components/Settings/index.vue';
import ThemeConfig from '@/components/ThemeConfig/index.vue';
import { computed, h, markRaw, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
import { computed, h, markRaw, nextTick, onBeforeUnmount, onMounted, ref, unref } from 'vue';
import { findNodeById, renderIcon, swapElements } from '@/components/Kubernetes/helper';
import { updateIcon } from '@/components/CustomTerminal/helper';
import { useTerminalStore } from '@/store/modules/terminal.ts';
Expand Down Expand Up @@ -379,9 +379,7 @@ const handleChangeTab = (value: string) => {
findNodeById(value);
nextTick(() => {
terminalStore.setTerminalConfig('currentTab', value);
});
terminalStore.setTerminalConfig('currentTab', value);
};
/**
Expand Down Expand Up @@ -434,16 +432,15 @@ const handleReconnect = (type: string) => {
panels.value.splice(index, 1);
treeStore.removeK8sIdMap(operatedNode.k8s_id);
operatedNode.k8s_id = uuid();
operatedNode.position = index;
const newId = uuid();
const structuredClone = JSON.parse(JSON.stringify(operatedNode));
operatedNode.key = newId;
operatedNode.k8s_id = newId;
operatedNode.position = index;
mittBus.emit('connect-terminal', { ...structuredClone });
mittBus.emit('connect-terminal', { ...operatedNode });
} else if (type === 'cloneConnect') {
operatedNode.k8s_id = uuid();
const structuredClone = JSON.parse(JSON.stringify(operatedNode));
mittBus.emit('connect-terminal', { ...structuredClone });
mittBus.emit('connect-terminal', { ...operatedNode });
}
showContextMenu.value = false;
Expand Down Expand Up @@ -538,8 +535,6 @@ const initializeDraggable = () => {
findNodeById(newActiveTab);
terminalStore.setTerminalConfig('currentTab', newActiveTab);
}
await nextTick(() => {});
}
});
}
Expand Down Expand Up @@ -667,7 +662,9 @@ onMounted(() => {
// 如果在 panels 中有相同的 k8s_id,则认为是对一个节点重复连接
panels.value.forEach(panel => {
if (panel.name === node.k8s_id) {
node.k8s_id = uuid();
const newId = uuid();
node.key = newId;
node.k8s_id = newId;
}
});
Expand Down
10 changes: 5 additions & 5 deletions ui/src/components/Kubernetes/helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Component } from 'vue';
import type { TreeOption } from 'naive-ui';
import type { customTreeOption } from '@/hooks/interface';
import { useTreeStore } from '@/store/modules/tree.ts';
import { useTerminalStore } from '@/store/modules/terminal.ts';
// import { useTerminalStore } from '@/store/modules/terminal.ts';

/**
* @description 用于每个 Tree Item 的 Tooltip
Expand Down Expand Up @@ -57,14 +57,14 @@ export const swapElements = (arr: any[], index1: number, index2: number) => {
*/
export const findNodeById = (nameRef: string) => {
const treeStore = useTreeStore();
const terminalStore = useTerminalStore();
// const terminalStore = useTerminalStore();

for (const [_key, value] of treeStore.terminalMap.entries()) {
if (value.k8s_id === nameRef) {
treeStore.setCurrentNode(value);
const ctrlCAsCtrl: string = value.ctrlCAsCtrlZMap.get(value.k8s_id);

terminalStore.setTerminalConfig('ctrlCAsCtrlZ', ctrlCAsCtrl);
// const ctrlCAsCtrl: string = value.ctrlCAsCtrlZMap.get(value.k8s_id);
//
// terminalStore.setTerminalConfig('ctrlCAsCtrlZ', ctrlCAsCtrl);
}
}
};
2 changes: 0 additions & 2 deletions ui/src/hooks/useKubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,6 @@ export const initElEvent = (
if (terminalStore.termSelectionText !== '') text = terminalStore.termSelectionText;
}

console.log(text);

e.preventDefault();

socket.send(
Expand Down

0 comments on commit f12a399

Please sign in to comment.