Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 937791e

Browse files
committed
新增 前往全屏按钮
1 parent f869aaf commit 937791e

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

src/app/views/Terminal.vue

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@
286286
<div>实例操作终端</div>
287287
<div>
288288
<el-tooltip class="item" effect="dark" content="新开全屏" placement="top">
289-
<span class="terminal-right-botton">
289+
<span class="terminal-right-botton" @click="toFullTerminal(2)">
290290
<i class="el-icon-monitor"></i>
291291
</span>
292292
</el-tooltip>
293293
<el-tooltip class="item" effect="dark" content="立刻全屏" placement="top">
294-
<span class="terminal-right-botton">
294+
<span class="terminal-right-botton" @click="toFullTerminal(1)">
295295
<i class="el-icon-full-screen"></i>
296296
</span>
297297
</el-tooltip>
@@ -311,6 +311,7 @@
311311
>
312312
</el-input>
313313
</div>
314+
<div v-show="isFull" id="full-terminal-option">A</div>
314315
</div>
315316
</template>
316317
</Panel>
@@ -675,9 +676,20 @@ export default {
675676
// 初始化 Terminal 窗口
676677
initTerm() {
677678
// 创建窗口与输入事件传递
678-
this.term = initTerminalWindow(document.getElementById("terminal-container"));
679+
const terminalContainer = document.getElementById("terminal-container");
680+
this.onChangeTerminalContainerHeight();
681+
this.term = initTerminalWindow(terminalContainer);
679682
this.term.onData(this.sendInput);
680683
},
684+
// 浏览器改变大小或重置高度事件
685+
onChangeTerminalContainerHeight() {
686+
if (this.isFull) {
687+
const terminalContainer = document.getElementById("terminal-container");
688+
const height = document.body.clientHeight - 50;
689+
terminalContainer.removeAttribute("style");
690+
terminalContainer.setAttribute("style", `height: ${height}px; width:100%`);
691+
}
692+
},
681693
// 开启实例(Ajax)
682694
async openInstance() {
683695
// this.busy = true;
@@ -938,6 +950,22 @@ export default {
938950
showTimeStr(time, now) {
939951
const date = new Date(now - time);
940952
return `${date.getHours()}:${(Array(2).join(0) + date.getMinutes()).slice(-2)}`;
953+
},
954+
955+
toFullTerminal(type = 1) {
956+
if (type === 1) {
957+
this.isFull = true;
958+
this.onChangeTerminalContainerHeight();
959+
router.push({
960+
path: `/terminal/${this.serviceUuid}/${this.instanceUuid}/`,
961+
query: {
962+
full: 1
963+
}
964+
});
965+
}
966+
if (type === 2) {
967+
window.open(`#/terminal/${this.serviceUuid}/${this.instanceUuid}/?full=1`);
968+
}
941969
}
942970
},
943971
// 装载事件
@@ -967,9 +995,15 @@ export default {
967995
console.error(error);
968996
// 忽略
969997
}
998+
999+
// 监听窗口变化事件
1000+
window.addEventListener("resize", this.onChangeTerminalContainerHeight);
9701001
},
9711002
// 卸载事件
9721003
beforeUnmount() {
1004+
// 卸载监听浏览器窗口改变时间
1005+
window.removeEventListener("resize", this.onChangeTerminalContainerHeight);
1006+
9731007
try {
9741008
// 停止定时器
9751009
this.stopInterval();

0 commit comments

Comments
 (0)