298298 </div >
299299 </template >
300300 <template #default >
301+ <div v-show =" isFull" class =" full-terminal-button-wrapper" >
302+ <div class =" full-terminal-button" @click =" openInstance" >开启</div >
303+ <div class =" full-terminal-button" @click =" stopInstance" >关闭</div >
304+ <div class =" full-terminal-button" @click =" restartInstance" >重启</div >
305+ <div class =" full-terminal-button" @click =" killInstance" >终止</div >
306+ <div class =" full-terminal-button" @click =" backTerminal" >退出</div >
307+ </div >
301308 <div :class =" { 'terminal-wrapper': true, 'full-terminal-wrapper': isFull }" >
302309 <div id =" terminal-container" style =" height : 560px ; width : 100% " ></div >
303310 <div id =" terminal-input-wrapper" >
311318 >
312319 </el-input >
313320 </div >
314- <div v-show =" isFull" id =" full-terminal-option" >A</div >
315321 </div >
316322 </template >
317323 </Panel >
@@ -689,6 +695,7 @@ export default {
689695 terminalContainer .removeAttribute (" style" );
690696 terminalContainer .setAttribute (" style" , ` height: ${ height} px; width:100%` );
691697 }
698+ if (this .term && this .term .fitAddon ) this .$nextTick (() => this .term .fitAddon .fit ());
692699 },
693700 // 开启实例(Ajax)
694701 async openInstance () {
@@ -966,6 +973,25 @@ export default {
966973 if (type === 2 ) {
967974 window .open (` #/terminal/${ this .serviceUuid } /${ this .instanceUuid } /?full=1` );
968975 }
976+ },
977+
978+ backTerminal () {
979+ this .isFull = false ;
980+ this .onChangeTerminalContainerHeight ();
981+ router .push ({
982+ path: ` /terminal/${ this .serviceUuid } /${ this .instanceUuid } /` ,
983+ query: {}
984+ });
985+ },
986+
987+ fireResizeEvent () {
988+ if (document .createEventObject ) {
989+ window .fireEvent (" onresize" );
990+ } else if (document .createEvent ) {
991+ let event = document .createEvent (" HTMLEvents" );
992+ event .initEvent (" resize" , true , true );
993+ window .dispatchEvent (event );
994+ }
969995 }
970996 },
971997 // 装载事件
@@ -982,9 +1008,10 @@ export default {
9821008 this .sendResize (size .cols , size .rows );
9831009 });
9841010 this .term .fitAddon .fit ();
985- window .onresize = () => {
986- this .term .fitAddon .fit ();
987- };
1011+
1012+ // window.onresize = () => {
1013+ // this.term.fitAddon.fit();
1014+ // };
9881015
9891016 // 与守护进程建立 Websocket 连接
9901017 await this .setUpWebsocket ();
@@ -1044,6 +1071,7 @@ export default {
10441071 right: 0px ;
10451072 bottom: 0px ;
10461073 top: 0px ;
1074+ z- index: 99 ;
10471075}
10481076
10491077.terminal - right- botton {
@@ -1058,4 +1086,28 @@ export default {
10581086.terminal - right- botton: hover {
10591087 background- color: rgb (219 , 219 , 219 );
10601088}
1089+
1090+ .full - terminal- button- wrapper {
1091+ position: fixed;
1092+ right: 30px ;
1093+ top: 12px ;
1094+ z- index: 100 ;
1095+ }
1096+
1097+ .full - terminal- button {
1098+ display: inline- block;
1099+ margin: 6px ;
1100+ padding: 8px 14px ;
1101+ color: white;
1102+ background- color: rgb (54 , 54 , 54 );
1103+ border- radius: 4px ;
1104+ box- shadow: 0px 0px 12px rgba (25 , 25 , 25 , 0.626 );
1105+ border: 1px solid rgb (73 , 73 , 73 );
1106+ transition: all 1s ;
1107+ cursor: pointer;
1108+ }
1109+
1110+ .full - terminal- button: hover {
1111+ background- color: rgb (101 , 101 , 101 );
1112+ }
10611113< / style>
0 commit comments