mirror of
https://github.com/MCSManager/MCSManager.git
synced 2024-12-27 07:59:08 +08:00
Feat: terminal button group & clear terminal log
This commit is contained in:
parent
f6d940d507
commit
cb3761d077
@ -30,6 +30,34 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.position-relative {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.position-absolute {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.position-absolute-right {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.position-absolute-left {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.position-absolute-top {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.position-absolute-bottom {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.direction-column {
|
.direction-column {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,8 @@ import {
|
|||||||
DownOutlined,
|
DownOutlined,
|
||||||
PauseCircleOutlined,
|
PauseCircleOutlined,
|
||||||
PlayCircleOutlined,
|
PlayCircleOutlined,
|
||||||
RedoOutlined
|
RedoOutlined,
|
||||||
|
DeleteOutlined
|
||||||
} from "@ant-design/icons-vue";
|
} from "@ant-design/icons-vue";
|
||||||
import { CheckCircleOutlined, ExclamationCircleOutlined } from "@ant-design/icons-vue";
|
import { CheckCircleOutlined, ExclamationCircleOutlined } from "@ant-design/icons-vue";
|
||||||
import { arrayFilter } from "../../tools/array";
|
import { arrayFilter } from "../../tools/array";
|
||||||
@ -32,6 +33,8 @@ import { INSTANCE_STATUS_TEXT } from "../../hooks/useInstance";
|
|||||||
import { message } from "ant-design-vue";
|
import { message } from "ant-design-vue";
|
||||||
import connectErrorImage from "@/assets/daemon_connection_error.png";
|
import connectErrorImage from "@/assets/daemon_connection_error.png";
|
||||||
import { useLayoutContainerStore } from "@/stores/useLayoutContainerStore";
|
import { useLayoutContainerStore } from "@/stores/useLayoutContainerStore";
|
||||||
|
import { Terminal } from "xterm";
|
||||||
|
import { group } from "console";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
card: LayoutCard;
|
card: LayoutCard;
|
||||||
@ -156,7 +159,7 @@ const initTerminal = async () => {
|
|||||||
const dom = document.getElementById(terminalDomId.value);
|
const dom = document.getElementById(terminalDomId.value);
|
||||||
if (dom) {
|
if (dom) {
|
||||||
const term = initTerminalWindow(dom);
|
const term = initTerminalWindow(dom);
|
||||||
term.writeln(
|
term.write(
|
||||||
(await getInstanceOutputLog()
|
(await getInstanceOutputLog()
|
||||||
.execute({
|
.execute({
|
||||||
params: { uuid: instanceId || "", daemonId: daemonId || "" }
|
params: { uuid: instanceId || "", daemonId: daemonId || "" }
|
||||||
@ -188,6 +191,14 @@ events.on("error", (error: Error) => {
|
|||||||
socketError.value = error;
|
socketError.value = error;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let term: Terminal | null = null;
|
||||||
|
|
||||||
|
const clearTerminal = () => {
|
||||||
|
if (term) {
|
||||||
|
term.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
if (instanceId && daemonId) {
|
if (instanceId && daemonId) {
|
||||||
@ -196,7 +207,7 @@ onMounted(async () => {
|
|||||||
daemonId
|
daemonId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
initTerminal();
|
term = await initTerminal();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(t("TXT_CODE_9885543f"));
|
throw new Error(t("TXT_CODE_9885543f"));
|
||||||
}
|
}
|
||||||
@ -283,7 +294,19 @@ const innerTerminalType = viewType === "inner";
|
|||||||
</div>
|
</div>
|
||||||
<a-spin :spinning="!isConnect" :tip="t('TXT_CODE_686c9ca9')">
|
<a-spin :spinning="!isConnect" :tip="t('TXT_CODE_686c9ca9')">
|
||||||
<div v-if="!containerState.isDesignMode" class="console-wrapper">
|
<div v-if="!containerState.isDesignMode" class="console-wrapper">
|
||||||
<div class="terminal-wrapper global-card-container-shadow">
|
<div class="terminal-button-group position-absolute-right position-absolute-top">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a-tooltip placement="top" @click="clearTerminal()">
|
||||||
|
<template #title>
|
||||||
|
<span>{{ t("清空终端输出内容") }}</span>
|
||||||
|
</template>
|
||||||
|
<delete-outlined />
|
||||||
|
</a-tooltip>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="terminal-wrapper global-card-container-shadow position-relative">
|
||||||
<div class="terminal-container">
|
<div class="terminal-container">
|
||||||
<div :id="terminalDomId"></div>
|
<div :id="terminalDomId"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -391,6 +414,39 @@ const innerTerminalType = viewType === "inner";
|
|||||||
.console-wrapper {
|
.console-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
.terminal-button-group {
|
||||||
|
z-index: 11;
|
||||||
|
padding-bottom: 50px;
|
||||||
|
padding-left: 50px;
|
||||||
|
border-radius: 6px;
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
ul {
|
||||||
|
transition: all 1s;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
display: flex;
|
||||||
|
opacity: 0;
|
||||||
|
|
||||||
|
li {
|
||||||
|
cursor: pointer;
|
||||||
|
list-style: none;
|
||||||
|
padding: 5px;
|
||||||
|
margin-left: 5px;
|
||||||
|
border-radius: 6px;
|
||||||
|
// background-color: #111111;
|
||||||
|
font-size: 20px;
|
||||||
|
&:hover {
|
||||||
|
background-color: #3e3e3e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.terminal-wrapper {
|
.terminal-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
Loading…
Reference in New Issue
Block a user