Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed: Fixed an issue where terminal cannot type when tab is closed #1461

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions ui/src/components/Kubernetes/MainContent/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const paramsStore = useParamsStore();
const terminalStore = useTerminalStore();

const { setting } = storeToRefs(paramsStore);
const { connectInfo, treeNodes } = storeToRefs(treeStore);
const { connectInfo, treeNodes, root } = storeToRefs(treeStore);

const el = ref();

Expand Down Expand Up @@ -404,13 +404,14 @@ const handleClose = (name: string) => {

panels.value.splice(index, 1);

nextTick(() => {
const panelLength = panels.value.length;
// nextTick(() => {});

if (panelLength >= 1) {
nameRef.value = panels.value[panelLength - 1].name as string;
}
});
const panelLength = panels.value.length;

if (panelLength >= 1) {
nameRef.value = panels.value[panelLength - 1].name as string;
findNodeById(nameRef.value);
}
};

/**
Expand All @@ -419,6 +420,10 @@ const handleClose = (name: string) => {
* @param id
*/
const findNodeById = (id: string): void => {
if (id === root.value.id) {
return treeStore.setCurrentNode(root.value);
}

const searchNode = (nodes: customTreeOption[]) => {
for (const node of nodes) {
if (node.key === id) {
Expand Down
14 changes: 7 additions & 7 deletions ui/src/components/Kubernetes/Tree/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
"
>
<n-icon size="13" :component="option.icon" />
<n-icon size="15" :component="option.icon" />
</n-button>
</template>
{{ option.label }}
Expand Down Expand Up @@ -93,10 +93,10 @@ import { useTreeStore } from '@/store/modules/tree.ts';
import mittBus from '@/utils/mittBus.ts';

import { Folder, FolderOpen } from '@vicons/fa';
import { RefreshRound } from '@vicons/material';
import { ExpandCategories } from '@vicons/carbon';
import { Terminal2 } from '@vicons/tabler';
import { Terminal2, Search } from '@vicons/tabler';
import { NIcon, TreeOption, DropdownOption } from 'naive-ui';
import { RefreshRound, LocationSearchingOutlined } from '@vicons/material';

const { t } = useI18n();
const treeStore = useTreeStore();
Expand All @@ -122,26 +122,26 @@ const allOptions = [
label: '展开',
key: 'expand',
// disabled: true,
icon: () => h(NIcon, { size: 13 }, { default: () => h(ExpandCategories) })
icon: () => h(NIcon, { size: 15 }, { default: () => h(ExpandCategories) })
},
{
label: '连接',
key: 'connect',
// disabled: true,
icon: () => h(NIcon, { size: 13 }, { default: () => h(Terminal2) })
icon: () => h(NIcon, { size: 15 }, { default: () => h(Terminal2) })
}
];
const buttonGroups = [
{
label: t('link'),
label: t('connect'),
icon: Terminal2,
click: (e: Event) => {
handleRootLink(e);
}
},
{
label: t('search'),
icon: LocationSearchingOutlined,
icon: Search,
click: (e: Event) => {
e.stopPropagation();
showSearch.value = !showSearch.value;
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 @@ -192,10 +192,10 @@ export const handleTerminalOnData = (
data: data,
id: terminalId,
type: eventType,
pod: '',
pod: node.pod || '',
k8s_id: node.k8s_id,
namespace: '',
container: ''
namespace: node.namespace || '',
container: node.container || ''
};

// 如果有子节点并且是父节点的处理
Expand Down
11 changes: 6 additions & 5 deletions ui/src/hooks/useK8s.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NIcon } from 'naive-ui';
import { v4 as uuid } from 'uuid';
import { Folder, Docker } from '@vicons/fa';
import { Cube16Regular } from '@vicons/fluent';
import { Cube24Regular } from '@vicons/fluent';

import { ref, h } from 'vue';
import { storeToRefs } from 'pinia';
Expand Down Expand Up @@ -92,6 +92,7 @@ export const useK8s = () => {
label: info.asset.name,
k8s_id: uuid(),
isLeaf: false,
isParent: true,
prefix: () =>
h(NIcon, null, {
default: () => h(Folder)
Expand Down Expand Up @@ -130,7 +131,7 @@ export const useK8s = () => {
pod: podName,
container: container.name,
namespace,
prefix: () => h(NIcon, { size: 13 }, { default: () => h(Docker) })
prefix: () => h(NIcon, { size: 16 }, { default: () => h(Docker) })
});
setCommonAttributes(container, container.name, true, parentId);
});
Expand All @@ -150,7 +151,7 @@ export const useK8s = () => {
if (pod.containers && pod.containers?.length > 0) {
pod.namespace = namespace;
pod.children = pod.containers;
pod.prefix = () => h(NIcon, { size: 13 }, { default: () => h(Cube16Regular) });
pod.prefix = () => h(NIcon, { size: 16 }, { default: () => h(Cube24Regular) });
handleContainer(pod.children, pod.name, namespace, parentId);
delete pod.containers;
} else {
Expand All @@ -169,7 +170,7 @@ export const useK8s = () => {
Object.keys(data).map(nodeKey => {
const node = data[nodeKey];
setCommonAttributes(node, nodeKey, false, messageId);
node.prefix = () => h(NIcon, { size: 13 }, { default: () => h(Folder) });
node.prefix = () => h(NIcon, { size: 15 }, { default: () => h(Folder) });

if (node.pods && node.pods.length > 0) {
node.children = node.pods;
Expand Down Expand Up @@ -260,7 +261,7 @@ export const useK8s = () => {
NIcon,
{ size: 14 },
{
default: () => h(Cube16Regular)
default: () => h(Cube24Regular)
}
);
}
Expand Down
Loading