From ea7fed720241038d53d0911c0fa0bafb9c705888 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Fri, 9 Dec 2022 21:56:35 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-2446=20feat=EF=BC=9A=20web=20terminal=20?= =?UTF-8?q?=E6=96=B0=E9=A1=B5=E9=9D=A2=E5=BC=80=E5=8F=91=EF=BC=88=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E6=B5=8F=E8=A7=88=E5=99=A8=E6=96=B0=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E9=A1=B5=E6=96=B9=E5=BC=8F=E6=89=93=E5=BC=80=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../css/components/cli/fileDirectory.scss | 45 +++++++++++++++++++ .../src/components/chart/chartDataFormat.js | 1 - nezha-fronted/src/components/cli/console.vue | 1 - .../src/components/cli/consoleNew.vue | 9 ++-- .../src/components/cli/fileDirectory.vue | 45 ++++++++++++++++--- .../src/components/cli/fileListState.vue | 1 - nezha-fronted/src/components/cli/terminal.vue | 6 ++- .../src/components/cli/webSSHNew.vue | 8 +++- nezha-fronted/src/components/layout/home.vue | 1 - .../page/dashboard/overview/chartConfig.vue | 1 - nezha-fronted/src/store/terminalFile.js | 4 -- 11 files changed, 101 insertions(+), 21 deletions(-) diff --git a/nezha-fronted/src/assets/css/components/cli/fileDirectory.scss b/nezha-fronted/src/assets/css/components/cli/fileDirectory.scss index 3536fd916..e7f2d84ae 100644 --- a/nezha-fronted/src/assets/css/components/cli/fileDirectory.scss +++ b/nezha-fronted/src/assets/css/components/cli/fileDirectory.scss @@ -104,10 +104,12 @@ .file-size{ width: 15%; display: inline-block; + position: relative; } .file-date{ width: 25%; display: inline-block; + position: relative; } .file-opt{ width: 14%; @@ -116,6 +118,27 @@ margin-right: 20px; } } + .file-arrow-header{ + display: inline-flex;align-items: center;width: 100% +} + .nz-arrow-box{ + display: flex;flex-direction: column;align-items: center;margin-left: 7px + } + .nz-arrow-up{ + margin-bottom: 5px; + } + .nz-arrow-up.is-select{ + border-bottom:5px solid $--color-primary; /* 定义底部颜色 */ + } + .nz-arrow-down.is-select{ + border-top:5px solid $--color-primary; /* 定义底部颜色 */ + } + .nz-icon-caret-up { + position: absolute; + } + .nz-icon-caret-down { + position: absolute; + } .file-item{ font-family: Roboto-Regular; font-size: 14px; @@ -153,3 +176,25 @@ } } } +div.nz-arrow-up { + width:0px; + height:0px; + border-left:5px solid transparent; /* 右透明 */ + border-right:5px solid transparent; /*右透明 */ + border-bottom:5px solid $--color-text-disabled; /* 定义底部颜色 */ + font-size:0px; + line-height:0px; + cursor: pointer; +} +/* css3三角形(向下 ▼) */ +div.nz-arrow-down { + width:0px; + height:0px; + border-left:5px solid transparent; + border-right:5px solid transparent; + border-top:5px solid $--color-text-disabled; + font-size:0px; + line-height:0px; + cursor: pointer; +} + diff --git a/nezha-fronted/src/components/chart/chartDataFormat.js b/nezha-fronted/src/components/chart/chartDataFormat.js index e798bf03c..095668fb6 100644 --- a/nezha-fronted/src/components/chart/chartDataFormat.js +++ b/nezha-fronted/src/components/chart/chartDataFormat.js @@ -700,7 +700,6 @@ const unitOptions = [ ] const units = [] window.addEventListener('load', function () { - console.log(13213) if (units.length < 1) { unitOptions.forEach((item, index) => { item.children.forEach((n, i) => { diff --git a/nezha-fronted/src/components/cli/console.vue b/nezha-fronted/src/components/cli/console.vue index 5d0bc97cd..5ec6a1260 100644 --- a/nezha-fronted/src/components/cli/console.vue +++ b/nezha-fronted/src/components/cli/console.vue @@ -300,7 +300,6 @@ export default { // 错误 this.terminalSocket.onerror = (e) => { this.isLogin = false - console.log(this.isLogin, 'close') } // 选中 复制 this.term.on('selection', function () {}) diff --git a/nezha-fronted/src/components/cli/consoleNew.vue b/nezha-fronted/src/components/cli/consoleNew.vue index c8215e297..27d8e5699 100644 --- a/nezha-fronted/src/components/cli/consoleNew.vue +++ b/nezha-fronted/src/components/cli/consoleNew.vue @@ -126,7 +126,6 @@ export default { authPinTip: this.$loadsh.get(this.terminal, 'custom.authPinTip', '') } this.$post('/terminal/login', params).then(res => { - console.log(res) if (res.code == 200) { this.terminal.uuid = res.data.uuid this.$forceUpdate() @@ -234,7 +233,6 @@ export default { // 错误 this.terminalSocket.onerror = (e) => { this.terminal.isLogin = false - console.log(this.terminal.isLogin, 'close') } // 选中 复制 this.term.on('selection', function () {}) @@ -262,7 +260,6 @@ export default { this.term && this.term.setOption('fontSize', fontSize) const consoleBox = document.getElementById('ternimalContainer' + this.idIndex) const width = document.body.clientWidth// 可视宽度 - console.log(consoleBox.offsetHeight) let height = parseInt(consoleBox.offsetHeight) if (height == null || !height) { height = this.termimalHeight } const winStyle = { @@ -306,6 +303,12 @@ export default { this.animateCSS(this.$refs.fileDirectory.$el, animationClass).then((message) => { this.fileDirectoryShow = show }) + }, + enterStr (message) { + this.terminalSocket.send(message) + setTimeout(()=>{ + this.terminalSocket.send('\n') + }, 100) } }, mounted () { diff --git a/nezha-fronted/src/components/cli/fileDirectory.vue b/nezha-fronted/src/components/cli/fileDirectory.vue index 8eefbb23e..708d681be 100644 --- a/nezha-fronted/src/components/cli/fileDirectory.vue +++ b/nezha-fronted/src/components/cli/fileDirectory.vue @@ -32,10 +32,34 @@ {{$t('overall.name')}}
- {{$t('backup.size')}} +
+
+ {{$t('backup.size')}} +
+
+
+
+
+
- {{$t('issue.createTime')}} +
+
+ {{$t('issue.createTime')}} +
+
+
+
+
+
{{$t('overall.option')}} @@ -217,8 +241,11 @@ export default { data () { return { fileDirectory: '/', + sizeOrderType: 0, + dateOrderType: 0, breadcrumb: [], fileList: [], + oldFileList: [], newFolderBoxShow: false, folder: '', fileDirectoryLoading: false, @@ -287,8 +314,7 @@ export default { this.editPath = '' this.editPathShow = false }, - goEditPath () { - console.log('123123123') + goEditPath () { this.getSftpPath(this.editPath) setTimeout(() => { this.editPath = '' @@ -302,7 +328,6 @@ export default { } }, showFileInfo (item) { - console.log(item) this.fileInfo = item this.fileInfoShow = true }, @@ -344,6 +369,7 @@ export default { this.fileDirectoryLoading = false this.fileDirectory = res.data.path this.fileList = res.data.list + this.oldFileList = res.data.list this.editPath = '' this.breadcrumb = res.data.path.split('/').filter(item => item) } else { @@ -475,6 +501,15 @@ export default { } return '-' }, + orderBy (key, orderType, order) { + if (this[key] == orderType) { + this[key] = 0 + this.fileList = this.oldFileList + } else { + this[key] = orderType + this.fileList = this.$loadsh.orderBy(this.oldFileList, order, orderType) + } + }, tableOperation ([command, row, param]) { switch (command) { case 'rename': diff --git a/nezha-fronted/src/components/cli/fileListState.vue b/nezha-fronted/src/components/cli/fileListState.vue index 1492c63eb..a9210a1af 100644 --- a/nezha-fronted/src/components/cli/fileListState.vue +++ b/nezha-fronted/src/components/cli/fileListState.vue @@ -110,7 +110,6 @@ export default { methods: { bytes: chartDataFormat.getUnit(7).compute, customColorMethod (percentage, item) { - console.log(item) if (percentage < 100) { return '#3B92F1' } else { diff --git a/nezha-fronted/src/components/cli/terminal.vue b/nezha-fronted/src/components/cli/terminal.vue index 9ba69b9c4..202f530f2 100644 --- a/nezha-fronted/src/components/cli/terminal.vue +++ b/nezha-fronted/src/components/cli/terminal.vue @@ -11,7 +11,7 @@
- + @@ -59,7 +59,6 @@ export default { ) } window.addEventListener('message', function (e) { - console.log(e) if (e.data) { try { const data = JSON.parse(e.data) @@ -81,6 +80,9 @@ export default { }, hideFileState () { this.$refs.fileListState.fileStateShow(false, this.fileListStateType) + }, + sendMessage () { + this.$refs.websshNew.sendMessage(this.message) } }, beforeDestroy () { diff --git a/nezha-fronted/src/components/cli/webSSHNew.vue b/nezha-fronted/src/components/cli/webSSHNew.vue index 01d7b1e6c..cb7cee0d0 100644 --- a/nezha-fronted/src/components/cli/webSSHNew.vue +++ b/nezha-fronted/src/components/cli/webSSHNew.vue @@ -610,12 +610,12 @@ export default { }) } else { console.terminal.username = '' + console.terminal.terminalType = this.customConnect.authProtocol this.editableTabsValue = newTabName this.editableTabs.push(console) } }, duplicate (item, index) { - console.log(item, index) if (item.terminal.assetId) { const newTabName = ++this.tabIndex + '' this.editableTabsValue = newTabName @@ -652,7 +652,6 @@ export default { } }, reconnect (item, index) { - console.log(item, index) this.$refs['console' + index][0].reconnect() }, showFileDir (item, index) { @@ -660,6 +659,11 @@ export default { }, closeShell (item, index) { this.removeTab(item.name) + }, + sendMessage (message) { + this.editableTabs.forEach((item, index) => { + this.$refs['console' + index][0].enterStr(message) + }) } }, watch: { diff --git a/nezha-fronted/src/components/layout/home.vue b/nezha-fronted/src/components/layout/home.vue index 8b0cd48cd..ae7114737 100644 --- a/nezha-fronted/src/components/layout/home.vue +++ b/nezha-fronted/src/components/layout/home.vue @@ -60,7 +60,6 @@ export default { } }, mounted () { - console.log(this.$router, this.$route) }, destroyed () { localStorage.removeItem('moduleProjectId') diff --git a/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue b/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue index 85109944f..c43d04b60 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue @@ -4,7 +4,6 @@ import vm from '../../../../entrance/app/main' import exportHtml from '../../../../entrance/exportHtml/exportHtml' // const vm = window.dataJson ? exportHtml : app window.addEventListener('load', function () { - console.log(123213) if (!window.dataJson) { commonOption.toolbox.feature.dataZoom.title.zoom = vm.$i18n.t('overall.toolBox.zoom') commonOption.toolbox.feature.dataZoom.title.back = vm.$i18n.t('overall.toolBox.back') diff --git a/nezha-fronted/src/store/terminalFile.js b/nezha-fronted/src/store/terminalFile.js index 7c853daa5..e650b3173 100644 --- a/nezha-fronted/src/store/terminalFile.js +++ b/nezha-fronted/src/store/terminalFile.js @@ -26,7 +26,6 @@ const terminalFile = { if (!state.messageFunction) { state.messageFunction = true window.addEventListener('message', function (e) { - console.log(e) const data = JSON.parse(e.data) // e.data 里面有自己所传的所有参数 可以根据参数做自己的判断 if (data.close) { state.externalTerminal = false @@ -39,11 +38,8 @@ const terminalFile = { state.externalTerminalWindow = '' } if (item && state.externalTerminal) { - console.log('onloda', state.externalTerminalWindow) state.externalTerminalWindow.addEventListener('load', () => { - console.log(123123123123123) setTimeout(() => { - console.log('time') state.externalTerminalWindow.postMessage( JSON.stringify(item) )