NEZ-342 feat:ternimal页面保存用户选择过的字体大小

This commit is contained in:
zhangyu
2020-07-01 14:11:49 +08:00
parent cd42ce455d
commit adb4720bce
2 changed files with 16 additions and 14 deletions

View File

@@ -25,6 +25,7 @@ export default {
type: Boolean,
default: false,
},
fontSize:{}
},
data () {
return {
@@ -35,7 +36,6 @@ export default {
topMenuHeight:30,
dragHeigh:8,
minRow:1,
fontSize:15,
fontSpaceHeight:2,//一行高度=fontSize+fontSpaceHeight
obj:{
id:2
@@ -314,7 +314,6 @@ export default {
},
setFontSize(fontSize){
this.term.setOption('fontSize',fontSize);
this.fontSize=fontSize;
const consoleBox = document.getElementById('ternimalContainer'+this.idIndex);
let width = document.body.clientWidth;//可视宽度
let height = parseInt(consoleBox.style.height);
@@ -325,20 +324,21 @@ export default {
cols:this.term.cols,//cols和rows在resizeConsole方法已经设置
rows:this.term.rows,
};
// alert(JSON.stringify(winStyle));
this.$post('terminal/resize',winStyle).then(response => {
if (response.code === 200) {
this.term.fit();
//this.term.scrollToBottom();
} else {
this.$message.error(response.msg);
}
});
//调整终端可视区域高度
document.getElementsByClassName('xterm-screen')[this.idIndex].style.height=height+'px'
this.$nextTick(()=>{
this.term.resize(this.term.cols,this.term.rows);
})
// alert(JSON.stringify(winStyle));
// this.$post('terminal/resize',winStyle).then(response => {
// if (response.code === 200) {
// this.term.fit();
// //this.term.scrollToBottom();
// } else {
// this.$message.error(response.msg);
// }
// });
// console.log(winStyle)
}
},

View File

@@ -6,7 +6,7 @@
<div id="shell-service-resize-mask"></div>
<div id="shell-split" class="shell-split shell-iconfont" @mousedown="dragEagle" v-show="!isFullScreen"></div>
<div style='position: relative;'>
<el-menu mode="horizontal" @select="handleSelect" style='position: absolute;left:0px;top:0px;border-top: 1px solid #DCDFE6;' default-active="1-2">
<el-menu mode="horizontal" @select="handleSelect" style='position: absolute;left:0px;top:0px;border-top: 1px solid #DCDFE6;'>
<el-submenu index="1" style="width:40px;" popper-class="fontSizeBox">
<template slot="title" ><i class="nz-icon nz-icon-728bianjiqi_zitidaxiao" style="position: absolute;left: 10px;top: 4px;"></i></template>
<!--<el-submenu index="1-1">-->
@@ -51,7 +51,7 @@
style="margin-top: 0px;"></div>{{item.title}}
</span>
<my-console :terminal="item.terminal" @refreshConsoleTitle="refreshTabTitle" :ref="'console'+index" @closeConsole="removeTab" :idIndex="index" :isFullScreen="isFullScreen"></my-console>
<my-console :terminal="item.terminal" @refreshConsoleTitle="refreshTabTitle" :ref="'console'+index" @closeConsole="removeTab" :idIndex="index" :isFullScreen="isFullScreen" :fontSize="fontSize"></my-console>
</el-tab-pane>
<el-tab-pane key="add" name="add">
@@ -175,6 +175,7 @@
},
data() {
let termFontSize=parseInt(localStorage.getItem("termFontSize"));
return {
consoleShow:false,
isFullScreen:false,
@@ -200,7 +201,7 @@
downloadFileList:[],
downloadResult:null,
// 字体大小
fontSize:15,
fontSize:termFontSize?termFontSize:15,
}
},
methods: {
@@ -576,6 +577,7 @@
changeFontSize(fontSize){
// this.$refs['console'+this.index].setFontSize(fontSize);
this.fontSize=fontSize;
localStorage.setItem("termFontSize", fontSize);
this.editableTabs.forEach((tab, index) => {
this.$refs['console'+index][0].setFontSize(fontSize);
});