refactor: 机器操作界面调整

This commit is contained in:
meilin.huang
2024-02-07 21:14:29 +08:00
parent 20eb06fb28
commit 9dbf104ef1
8 changed files with 131 additions and 81 deletions

View File

@@ -17,7 +17,7 @@
"countup.js": "^2.7.0", "countup.js": "^2.7.0",
"cropperjs": "^1.5.11", "cropperjs": "^1.5.11",
"echarts": "^5.4.3", "echarts": "^5.4.3",
"element-plus": "^2.5.3", "element-plus": "^2.5.5",
"js-base64": "^3.7.5", "js-base64": "^3.7.5",
"jsencrypt": "^3.3.2", "jsencrypt": "^3.3.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",

View File

@@ -119,8 +119,8 @@ const open = (optionProps: MonacoEditorDialogProps) => {
} }
setTimeout(() => { setTimeout(() => {
editorRef.value?.format();
editorRef.value?.focus(); editorRef.value?.focus();
editorRef.value?.format();
}, 300); }, 300);
state.dialogVisible = true; state.dialogVisible = true;

View File

@@ -163,7 +163,7 @@ const fitTerminal = () => {
}; };
const focus = () => { const focus = () => {
setTimeout(() => term.focus(), 400); setTimeout(() => term.focus(), 100);
}; };
const clear = () => { const clear = () => {

View File

@@ -17,7 +17,7 @@
@node-contextmenu="nodeContextmenu" @node-contextmenu="nodeContextmenu"
> >
<template #default="{ node, data }"> <template #default="{ node, data }">
<span> <span @dblclick="treeNodeDblclick(data)">
<span v-if="data.type.value == TagTreeNode.TagPath"> <span v-if="data.type.value == TagTreeNode.TagPath">
<tag-info :tag-path="data.label" /> <tag-info :tag-path="data.label" />
</span> </span>
@@ -25,7 +25,13 @@
<slot v-else :node="node" :data="data" name="prefix"></slot> <slot v-else :node="node" :data="data" name="prefix"></slot>
<span class="ml3" :title="data.labelRemark"> <span class="ml3" :title="data.labelRemark">
<slot name="label" :data="data"> {{ data.label }}</slot> <slot name="label" :data="data" v-if="!data.disabled"> {{ data.label }}</slot>
<!-- 禁用状态 -->
<slot name="disabledLabel" :data="data" v-else>
<el-link type="danger" disabled :underline="false">
{{ `${data.label}` }}
</el-link>
</slot>
</span> </span>
<slot :node="node" :data="data" name="suffix"></slot> <slot :node="node" :data="data" name="suffix"></slot>
@@ -135,15 +141,29 @@ const loadNode = async (node: any, resolve: any) => {
const treeNodeClick = (data: any) => { const treeNodeClick = (data: any) => {
emit('nodeClick', data); emit('nodeClick', data);
if (data.type.nodeClickFunc) { if (!data.disabled && !data.type.nodeDblclickFunc && data.type.nodeClickFunc) {
data.type.nodeClickFunc(data); data.type.nodeClickFunc(data);
} }
// 关闭可能存在的右击菜单 // 关闭可能存在的右击菜单
contextmenuRef.value.closeContextmenu(); contextmenuRef.value.closeContextmenu();
}; };
// 树节点双击事件
const treeNodeDblclick = (data: any) => {
// emit('nodeDblick', data);
if (!data.disabled && data.type.nodeDblclickFunc) {
data.type.nodeDblclickFunc(data);
}
// 关闭可能存在的右击菜单
contextmenuRef.value.closeContextmenu();
};
// 树节点右击事件 // 树节点右击事件
const nodeContextmenu = (event: any, data: any) => { const nodeContextmenu = (event: any, data: any) => {
if (data.disabled) {
return;
}
// 加载当前节点是否需要显示右击菜单 // 加载当前节点是否需要显示右击菜单
let items = data.type.contextMenuItems; let items = data.type.contextMenuItems;
if (!items || items.length == 0) { if (!items || items.length == 0) {

View File

@@ -28,6 +28,11 @@ export class TagTreeNode {
*/ */
isLeaf: boolean = false; isLeaf: boolean = false;
/**
* 是否禁用状态
*/
disabled: boolean = false;
/** /**
* 额外需要传递的参数 * 额外需要传递的参数
*/ */
@@ -53,6 +58,11 @@ export class TagTreeNode {
return this; return this;
} }
withDisabled(disabled: boolean) {
this.disabled = disabled;
return this;
}
withParams(params: any) { withParams(params: any) {
this.params = params; this.params = params;
return this; return this;
@@ -91,8 +101,14 @@ export class NodeType {
loadNodesFunc: (parentNode: TagTreeNode) => Promise<TagTreeNode[]>; loadNodesFunc: (parentNode: TagTreeNode) => Promise<TagTreeNode[]>;
/**
* 节点点击事件
*/
nodeClickFunc: (node: TagTreeNode) => void; nodeClickFunc: (node: TagTreeNode) => void;
// 节点双击事件
nodeDblclickFunc: (node: TagTreeNode) => void;
constructor(value: number) { constructor(value: number) {
this.value = value; this.value = value;
} }
@@ -117,6 +133,16 @@ export class NodeType {
return this; return this;
} }
/**
* 赋值节点双击事件回调函数
* @param func 节点双击事件回调函数
* @returns this
*/
withNodeDblclickFunc(func: (node: TagTreeNode) => void) {
this.nodeDblclickFunc = func;
return this;
}
/** /**
* 赋值右击菜单按钮选项 * 赋值右击菜单按钮选项
* @param contextMenuItems 右击菜单按钮选项 * @param contextMenuItems 右击菜单按钮选项

View File

@@ -1,5 +1,5 @@
<template> <template>
<div> <div class="machine-list">
<page-table <page-table
ref="pageTableRef" ref="pageTableRef"
:page-api="machineApi.list" :page-api="machineApi.list"
@@ -25,7 +25,7 @@
<span v-if="!data.stat">-</span> <span v-if="!data.stat">-</span>
<div v-else> <div v-else>
<el-row> <el-row>
<el-text size="small" style="font-size: 10px"> <el-text size="small" class="font11">
内存(可用/): 内存(可用/):
<span :class="getStatsFontClass(data.stat.memAvailable, data.stat.memTotal)" <span :class="getStatsFontClass(data.stat.memAvailable, data.stat.memTotal)"
>{{ formatByteSize(data.stat.memAvailable, 1) }}/{{ formatByteSize(data.stat.memTotal, 1) }} >{{ formatByteSize(data.stat.memAvailable, 1) }}/{{ formatByteSize(data.stat.memTotal, 1) }}
@@ -33,7 +33,7 @@
</el-text> </el-text>
</el-row> </el-row>
<el-row> <el-row>
<el-text style="font-size: 10px" size="small"> <el-text class="font11" size="small">
CPU(空闲): <span :class="getStatsFontClass(data.stat.cpuIdle, 100)">{{ data.stat.cpuIdle.toFixed(0) }}%</span> CPU(空闲): <span :class="getStatsFontClass(data.stat.cpuIdle, 100)">{{ data.stat.cpuIdle.toFixed(0) }}%</span>
</el-text> </el-text>
</el-row> </el-row>
@@ -44,7 +44,7 @@
<span v-if="!data.stat?.fsInfos">-</span> <span v-if="!data.stat?.fsInfos">-</span>
<div v-else> <div v-else>
<el-row v-for="(i, idx) in data.stat.fsInfos.slice(0, 2)" :key="i.mountPoint"> <el-row v-for="(i, idx) in data.stat.fsInfos.slice(0, 2)" :key="i.mountPoint">
<el-text style="font-size: 10px" size="small" :class="getStatsFontClass(i.free, i.used + i.free)"> <el-text class="font11" size="small" :class="getStatsFontClass(i.free, i.used + i.free)">
{{ i.mountPoint }} => {{ formatByteSize(i.free, 0) }}/{{ formatByteSize(i.used + i.free, 0) }} {{ i.mountPoint }} => {{ formatByteSize(i.free, 0) }}/{{ formatByteSize(i.used + i.free, 0) }}
</el-text> </el-text>
@@ -55,7 +55,7 @@
</template> </template>
<el-row v-for="i in data.stat.fsInfos.slice(2)" :key="i.mountPoint"> <el-row v-for="i in data.stat.fsInfos.slice(2)" :key="i.mountPoint">
<el-text style="font-size: 10px" size="small" :class="getStatsFontClass(i.free, i.used + i.free)"> <el-text class="font11" size="small" :class="getStatsFontClass(i.free, i.used + i.free)">
{{ i.mountPoint }} => {{ formatByteSize(i.free, 0) }}/{{ formatByteSize(i.used + i.free, 0) }} {{ i.mountPoint }} => {{ formatByteSize(i.free, 0) }}/{{ formatByteSize(i.used + i.free, 0) }}
</el-text> </el-text>
</el-row> </el-row>
@@ -464,7 +464,7 @@ const showRec = (row: any) => {
</script> </script>
<style> <style>
.el-dialog__body { .machine-list .el-dialog {
padding: 2px 2px; padding: 2px 2px;
} }

View File

@@ -8,11 +8,22 @@
ref="tagTreeRef" ref="tagTreeRef"
:resource-type="TagResourceTypeEnum.Machine.value" :resource-type="TagResourceTypeEnum.Machine.value"
:tag-path-node-type="NodeTypeTagPath" :tag-path-node-type="NodeTypeTagPath"
/> >
<template #prefix="{ data }">
<SvgIcon v-if="data.icon && data.params.status == 1" :name="data.icon.name" :color="data.icon.color" />
<SvgIcon v-if="data.icon && data.params.status == -1" :name="data.icon.name" color="var(--el-color-danger)" />
</template>
<template #suffix="{ data }">
<span style="color: #c4c9c4; font-size: 9px" v-if="data.type.value == MachineNodeType.Machine">{{
` ${data.params.username}@${data.params.ip}:${data.params.port}`
}}</span>
</template>
</tag-tree>
</Pane> </Pane>
<Pane> <Pane>
<div class="card pd5"> <div class="machine-terminal-tabs card pd5">
<el-tabs <el-tabs
v-if="state.tabs.size > 0" v-if="state.tabs.size > 0"
type="card" type="card"
@@ -20,18 +31,18 @@
@tab-change="onTabChange" @tab-change="onTabChange"
style="width: 100%" style="width: 100%"
v-model="state.activeTermName" v-model="state.activeTermName"
class="h100 machine-terminal-tabs" class="h100"
> >
<el-tab-pane class="h100" closable v-for="dt in state.tabs.values()" :label="dt.label" :name="dt.key" :key="dt.key"> <el-tab-pane class="h100" closable v-for="dt in state.tabs.values()" :label="dt.label" :name="dt.key" :key="dt.key">
<template #label> <template #label>
<el-popconfirm @confirm="handleReconnect(dt.key)" title="确认重新连接?"> <el-popconfirm @confirm="handleReconnect(dt.key)" title="确认重新连接?">
<template #reference> <template #reference>
<el-icon class="mr2" :color="dt.status == 1 ? '#67c23a' : '#f56c6c'" :title="dt.status == 1 ? '' : '点击重连'" <el-icon class="mr5" :color="dt.status == 1 ? '#67c23a' : '#f56c6c'" :title="dt.status == 1 ? '' : '点击重连'"
><Connection /> ><Connection />
</el-icon> </el-icon>
</template> </template>
</el-popconfirm> </el-popconfirm>
<el-popover placement="bottom-start" trigger="hover" :width="250"> <el-popover :show-after="1000" placement="bottom-start" trigger="hover" :width="250">
<template #reference> <template #reference>
<div> <div>
<span class="machine-terminal-tab-label">{{ dt.label }}</span> <span class="machine-terminal-tab-label">{{ dt.label }}</span>
@@ -41,6 +52,8 @@
<el-descriptions :column="1" size="small"> <el-descriptions :column="1" size="small">
<el-descriptions-item label="机器名"> {{ dt.params?.name }} </el-descriptions-item> <el-descriptions-item label="机器名"> {{ dt.params?.name }} </el-descriptions-item>
<el-descriptions-item label="host"> {{ dt.params?.ip }} : {{ dt.params?.port }} </el-descriptions-item> <el-descriptions-item label="host"> {{ dt.params?.ip }} : {{ dt.params?.port }} </el-descriptions-item>
<el-descriptions-item label="username"> {{ dt.params?.username }} </el-descriptions-item>
<el-descriptions-item label="remark"> {{ dt.params?.remark }} </el-descriptions-item>
</el-descriptions> </el-descriptions>
</template> </template>
</el-popover> </el-popover>
@@ -50,7 +63,7 @@
<TerminalBody <TerminalBody
@status-change="terminalStatusChange(dt.key, $event)" @status-change="terminalStatusChange(dt.key, $event)"
:ref="(el) => setTerminalRef(el, dt.key)" :ref="(el) => setTerminalRef(el, dt.key)"
:socket-url="dt.terminalInfo.socketUrl" :socket-url="dt.socketUrl"
/> />
</div> </div>
</el-tab-pane> </el-tab-pane>
@@ -84,16 +97,6 @@
</el-descriptions> </el-descriptions>
</el-dialog> </el-dialog>
<terminal-dialog ref="terminalDialogRef" :visibleMinimize="true">
<template #headerTitle="{ terminalInfo }">
{{ `${(terminalInfo.terminalId + '').slice(-2)}` }}
<el-divider direction="vertical" />
{{ `${terminalInfo.meta.username}@${terminalInfo.meta.ip}:${terminalInfo.meta.port}` }}
<el-divider direction="vertical" />
{{ terminalInfo.meta.name }}
</template>
</terminal-dialog>
<process-list v-model:visible="processDialog.visible" v-model:machineId="processDialog.machineId" /> <process-list v-model:visible="processDialog.visible" v-model:machineId="processDialog.machineId" />
<script-manage :title="serviceDialog.title" v-model:visible="serviceDialog.visible" v-model:machineId="serviceDialog.machineId" /> <script-manage :title="serviceDialog.title" v-model:visible="serviceDialog.visible" v-model:machineId="serviceDialog.machineId" />
@@ -121,7 +124,6 @@ import TagTree from '../component/TagTree.vue';
import { Splitpanes, Pane } from 'splitpanes'; import { Splitpanes, Pane } from 'splitpanes';
import { ContextmenuItem } from '@/components/contextmenu/index'; import { ContextmenuItem } from '@/components/contextmenu/index';
// 组件 // 组件
const TerminalDialog = defineAsyncComponent(() => import('@/components/terminal/TerminalDialog.vue'));
const ScriptManage = defineAsyncComponent(() => import('./ScriptManage.vue')); const ScriptManage = defineAsyncComponent(() => import('./ScriptManage.vue'));
const FileConfList = defineAsyncComponent(() => import('./file/FileConfList.vue')); const FileConfList = defineAsyncComponent(() => import('./file/FileConfList.vue'));
const MachineStats = defineAsyncComponent(() => import('./MachineStats.vue')); const MachineStats = defineAsyncComponent(() => import('./MachineStats.vue'));
@@ -131,7 +133,6 @@ import TerminalBody from '@/components/terminal/TerminalBody.vue';
import { TerminalStatus } from '@/components/terminal/common'; import { TerminalStatus } from '@/components/terminal/common';
const router = useRouter(); const router = useRouter();
const terminalDialogRef: any = ref(null);
const perms = { const perms = {
addMachine: 'machine:add', addMachine: 'machine:add',
@@ -156,13 +157,10 @@ const state = reactive({
name: null, name: null,
tagPath: '', tagPath: '',
}, },
pageData: [] as any[],
infoDialog: { infoDialog: {
visible: false, visible: false,
data: null as any, data: null as any,
}, },
// 当前选中数据
selectionData: [],
serviceDialog: { serviceDialog: {
visible: false, visible: false,
machineId: 0, machineId: 0,
@@ -189,7 +187,7 @@ const state = reactive({
title: '', title: '',
}, },
activeTermName: '', activeTermName: '',
tabs: new Map(), tabs: new Map<string, any>(),
}); });
const { infoDialog, serviceDialog, processDialog, fileDialog, machineStatsDialog, machineRecDialog } = toRefs(state); const { infoDialog, serviceDialog, processDialog, fileDialog, machineStatsDialog, machineRecDialog } = toRefs(state);
@@ -204,17 +202,24 @@ const NodeTypeTagPath = new NodeType(TagTreeNode.TagPath).withLoadNodesFunc(asyn
const res = await search(); const res = await search();
// 把list 根据name字段排序 // 把list 根据name字段排序
res.list = res.list.sort((a: any, b: any) => a.name.localeCompare(b.name)); res.list = res.list.sort((a: any, b: any) => a.name.localeCompare(b.name));
state.pageData = res.list; return res.list.map((x: any) =>
return res.list.map((x: any) => new TagTreeNode(x.id, x.name, NodeTypeMachine(x)).withParams(x).withIsLeaf(true)); new TagTreeNode(x.id, x.name, NodeTypeMachine(x))
.withParams(x)
.withDisabled(x.status == -1)
.withIcon({
name: 'Monitor',
color: '#409eff',
})
.withIsLeaf(true)
);
}); });
let termIndex = 0;
let openIds = {}; let openIds = {};
const NodeTypeMachine = (machine: any) => { const NodeTypeMachine = (machine: any) => {
let contextMenuItems = []; let contextMenuItems = [];
contextMenuItems.push(new ContextmenuItem('term', '打开终端').withIcon('Monitor').withOnClick(() => showTerminal(machine))); contextMenuItems.push(new ContextmenuItem('term', '打开终端').withIcon('Monitor').withOnClick(() => openTerminal(machine)));
contextMenuItems.push(new ContextmenuItem('term-ex', '打开终端(新窗口)').withIcon('Monitor').withOnClick(() => showTerminal(machine, true))); contextMenuItems.push(new ContextmenuItem('term-ex', '打开终端(新窗口)').withIcon('Monitor').withOnClick(() => openTerminal(machine, true)));
contextMenuItems.push(new ContextmenuItem('detail', '详情').withIcon('More').withOnClick(() => showInfo(machine))); contextMenuItems.push(new ContextmenuItem('detail', '详情').withIcon('More').withOnClick(() => showInfo(machine)));
contextMenuItems.push(new ContextmenuItem('status', '状态').withIcon('Compass').withOnClick(() => showMachineStats(machine))); contextMenuItems.push(new ContextmenuItem('status', '状态').withIcon('Compass').withOnClick(() => showMachineStats(machine)));
contextMenuItems.push(new ContextmenuItem('process', '进程').withIcon('DataLine').withOnClick(() => showProcess(machine))); contextMenuItems.push(new ContextmenuItem('process', '进程').withIcon('DataLine').withOnClick(() => showProcess(machine)));
@@ -225,15 +230,22 @@ const NodeTypeMachine = (machine: any) => {
contextMenuItems.push(new ContextmenuItem('files', '文件管理').withIcon('FolderOpened').withOnClick(() => showFileManage(machine))); contextMenuItems.push(new ContextmenuItem('files', '文件管理').withIcon('FolderOpened').withOnClick(() => showFileManage(machine)));
contextMenuItems.push(new ContextmenuItem('scripts', '脚本管理').withIcon('Files').withOnClick(() => serviceManager(machine))); contextMenuItems.push(new ContextmenuItem('scripts', '脚本管理').withIcon('Files').withOnClick(() => serviceManager(machine)));
return new NodeType(MachineNodeType.Machine).withContextMenuItems(contextMenuItems).withNodeClickFunc(() => { return new NodeType(MachineNodeType.Machine).withContextMenuItems(contextMenuItems).withNodeDblclickFunc(() => {
state.pageData = [machine]; // for (let k of state.tabs.keys()) {
// // 存在该机器相关的终端tab则直接激活该tab
// if (k.startsWith(`${machine.id}_${machine.username}_`)) {
// state.activeTermName = k;
// onTabChange();
// return;
// }
// }
showTerminal(machine); openTerminal(machine);
}); });
}; };
const showTerminal = (machine: any, ex?: boolean) => { const openTerminal = (machine: any, ex?: boolean) => {
// 按住ctrl点击则新建标签页打开, metaKey对应mac command键 // 新窗口打开
if (ex) { if (ex) {
const { href } = router.resolve({ const { href } = router.resolve({
path: `/machine/terminal`, path: `/machine/terminal`,
@@ -246,29 +258,21 @@ const showTerminal = (machine: any, ex?: boolean) => {
return; return;
} }
let { name, id, username, ip, port } = machine; let { name, id, username } = machine;
// 同一个机器的终端打开多次key后添加下划线和数字区分 // 同一个机器的终端打开多次key后添加下划线和数字区分
openIds[id] = openIds[id] ? ++openIds[id] : 1; openIds[id] = openIds[id] ? ++openIds[id] : 1;
let sameIndex = openIds[id]; let sameIndex = openIds[id];
const terminalId = Date.now(); let key = `${id}_${username}_${sameIndex}`;
let key = name + '_' + id + '_' + sameIndex + '_' + terminalId;
// 只保留name的10个字超出部分只保留前后4个字符中间用省略号代替 // 只保留name的10个字超出部分只保留前后4个字符中间用省略号代替
let label = name.length > 10 ? name.slice(0, 4) + '...' + name.slice(-4) : name; let label = name.length > 10 ? name.slice(0, 4) + '...' + name.slice(-4) : name;
state.tabs.set(key, { state.tabs.set(key, {
key, key,
label: `${++termIndex}.${label}${sameIndex === 1 ? '' : ':' + sameIndex}`, // label组成为:总打开term次数+name+同一个机器打开的次数 label: `${label}${sameIndex === 1 ? '' : ':' + sameIndex}`, // label组成为:总打开term次数+name+同一个机器打开的次数
params: machine, params: machine,
terminalInfo: { socketUrl: getMachineTerminalSocketUrl(id),
terminalId: terminalId,
status: TerminalStatus.NoConnected,
socketUrl: getMachineTerminalSocketUrl(id),
minTitle: `${name} [${(terminalId + '').slice(-2)}]`, // 截取terminalId最后两位区分多个terminal
minDesc: `${username}@${ip}:${port} (${name})`,
meta: machine,
},
}); });
state.activeTermName = key; state.activeTermName = key;
fitTerminal(); fitTerminal();
@@ -291,7 +295,6 @@ const showMachineStats = async (machine: any) => {
const search = async () => { const search = async () => {
const res = await machineApi.list.request(state.params); const res = await machineApi.list.request(state.params);
state.pageData = res.list;
return res; return res;
}; };
@@ -301,18 +304,6 @@ const showFileManage = (selectionData: any) => {
state.fileDialog.title = `${selectionData.name} => ${selectionData.ip}`; state.fileDialog.title = `${selectionData.name} => ${selectionData.ip}`;
}; };
const getStatsFontClass = (available: number, total: number) => {
const p = available / total;
if (p < 0.1) {
return 'color-danger';
}
if (p < 0.2) {
return 'color-warning';
}
return 'color-success';
};
const showInfo = (info: any) => { const showInfo = (info: any) => {
state.infoDialog.data = info; state.infoDialog.data = info;
state.infoDialog.visible = true; state.infoDialog.visible = true;
@@ -343,8 +334,11 @@ const onRemoveTab = (targetName: string) => {
} else { } else {
activeTermName = ''; activeTermName = '';
} }
// 关闭连接
machineApi.closeCli.request({ id: state.tabs.get(targetName).params.id }); let info = state.tabs.get(targetName);
if (info) {
terminalRefs[info.key]?.close();
}
state.tabs.delete(targetName); state.tabs.delete(targetName);
state.activeTermName = activeTermName; state.activeTermName = activeTermName;
@@ -355,6 +349,7 @@ const onRemoveTab = (targetName: string) => {
const terminalStatusChange = (key: string, status: TerminalStatus) => { const terminalStatusChange = (key: string, status: TerminalStatus) => {
state.tabs.get(key).status = status; state.tabs.get(key).status = status;
}; };
const terminalRefs: any = {}; const terminalRefs: any = {};
const setTerminalRef = (el: any, key: any) => { const setTerminalRef = (el: any, key: any) => {
if (key) { if (key) {
@@ -362,7 +357,7 @@ const setTerminalRef = (el: any, key: any) => {
} }
}; };
const onResizeTagTree = (a) => { const onResizeTagTree = () => {
fitTerminal(); fitTerminal();
}; };
@@ -375,8 +370,9 @@ const fitTerminal = () => {
let info = state.tabs.get(state.activeTermName); let info = state.tabs.get(state.activeTermName);
if (info) { if (info) {
terminalRefs[info.key]?.resize(); terminalRefs[info.key]?.resize();
terminalRefs[info.key]?.focus();
} }
}, 500); }, 100);
}; };
const handleReconnect = (key: string) => { const handleReconnect = (key: string) => {
@@ -386,7 +382,13 @@ const handleReconnect = (key: string) => {
<style lang="scss"> <style lang="scss">
.machine-terminal-tabs { .machine-terminal-tabs {
height: calc(100vh - 108px);
--el-tabs-header-height: 30px; --el-tabs-header-height: 30px;
.el-tabs {
--el-tabs-header-height: 30px;
}
.machine-terminal-tab-label { .machine-terminal-tab-label {
font-size: 12px; font-size: 12px;
} }
@@ -394,13 +396,7 @@ const handleReconnect = (key: string) => {
margin-bottom: 5px; margin-bottom: 5px;
} }
.el-tabs__item { .el-tabs__item {
padding: 0 5px !important; padding: 0 8px !important;
}
}
.machine-terminal-tree {
.el-tree-node__content {
font-size: 12px;
} }
} }
</style> </style>

View File

@@ -104,8 +104,16 @@ func (c *Cli) Close() {
c.sftpClient.Close() c.sftpClient.Close()
c.sftpClient = nil c.sftpClient = nil
} }
var sshTunnelMachineId uint64
if c.Info.SshTunnelMachine != nil { if c.Info.SshTunnelMachine != nil {
logx.Infof("关闭机器的隧道信息: machineId=%d, sshTunnelMachineId=%d", c.Info.Id, c.Info.SshTunnelMachine.Id) sshTunnelMachineId = c.Info.SshTunnelMachine.Id
}
if c.Info.TempSshMachineId != 0 {
sshTunnelMachineId = c.Info.TempSshMachineId
}
if sshTunnelMachineId != 0 {
logx.Infof("关闭机器的隧道信息: machineId=%d, sshTunnelMachineId=%d", c.Info.Id, sshTunnelMachineId)
CloseSshTunnelMachine(int(c.Info.SshTunnelMachine.Id), c.Info.GetTunnelId()) CloseSshTunnelMachine(int(c.Info.SshTunnelMachine.Id), c.Info.GetTunnelId())
} }
} }