Merge branch 'dev-3.6' of git.mesalab.cn:nezha/nezha-fronted into dev-3.6

This commit is contained in:
zyh
2022-11-28 16:35:12 +08:00
6 changed files with 41 additions and 18 deletions

View File

@@ -13,9 +13,9 @@
<div class="active-icon" :class="isLogin ? 'green-bg': 'red-bg'"></div>
{{userName}}
</span>
<span style="color: #fff" v-show="isLogin">
<i class="nz-icon nz-icon-reconnect" style="margin-right: 22px" @click="reconnect"></i>
<i class="nz-icon nz-icon-SFTP" v-if="userName && terminalType == '1'" style="margin-right: 22px" @click="showFileDir(true)"></i>
<span style="color: #fff">
<i class="nz-icon nz-icon-reconnect" v-show="isInit" style="margin-right: 22px" @click="reconnect"></i>
<i class="nz-icon nz-icon-SFTP" v-show="isLogin" v-if="userName && terminalType == '1'" style="margin-right: 22px" @click="showFileDir(true)"></i>
</span>
</div>
<div :id="'terminal'+idIndex" ></div>
@@ -57,6 +57,7 @@ export default {
id: 2
},
isLogin: false,
isInit:false,
successBackContent: 'Connecting to',
failBackContent: 'Sorry',
connectFailContent: 'Connection failed',
@@ -231,9 +232,10 @@ export default {
})
}
this.terminalSocket = new WebSocket(url)
// 连接成功
// 连接成功onclose
this.terminalSocket.onopen = () => {
this.isLogin = true
this.isInit = true
}
// 登录后,你输入的内容从后台服务返回
this.term.on('data', function (data) {
@@ -247,9 +249,6 @@ export default {
// 返回
this.terminalSocket.onmessage = function (evt) {
let backContent = evt.data
if (backContent.indexOf('Connection closed') !== -1 && backContent.indexOf('logout') !== -1) {
that.isLogin = false
}
const welComIndex = backContent.indexOf(that.welcomeBackContent)
if (welComIndex > -1) { // 无服务器信息只与nezha进行了连接
const connectResult = {
@@ -293,7 +292,6 @@ export default {
// 关闭
this.terminalSocket.onclose = () => {
this.isLogin = false
console.log(this.isLogin, 'close')
// 报错sorry的还没来得及看信息就关闭
// this.$emit("closeConsole",this.terminal.name);//
this.term && this.term.setOption('disableStdin', true)

View File

@@ -1,5 +1,5 @@
<template>
<div class="fileDirectory" style="width: 100% !important;transform: scale(1) !important;">
<div class="fileDirectory" style="width: 100% !important;">
<div class="file-directory-header">
<span style="color: #fff">
{{$t('terminal.sftp')}}
@@ -39,7 +39,6 @@
:title='$t("overall.newFolder")'
destroy-on-close
:modal-append-to-body="false"
:close-on-click-modal="false"
:visible.sync="newFolderBoxShow"
@close="newFolder(false)"
>
@@ -143,9 +142,7 @@ export default {
this.getSftpPath(path || '/')
},
gotoPath (item, index) {
console.log(item, index, this.breadcrumb.slice(0, index + 1))
const path = '/' + this.breadcrumb.slice(0, index + 1).join('/')
console.log(path)
this.getSftpPath(path || '/')
},
getSftpPath (path) {
@@ -206,9 +203,10 @@ export default {
}, 300)
},
delFile (item) {
const path = this.fileDirectory == '/' ? '' : this.fileDirectory
const params = {
uuid: this.uuid,
path: this.fileDirectory + '/' + item.name
path: path + '/' + item.name
}
this.$post('/terminal/sftp/rm', params).then(res => {
if (res.code == 200) {

View File

@@ -134,6 +134,7 @@ export default {
item.fileLength = progressEvent.loaded
item.speed = item.fileLength / ((new Date().getTime() - item.startTime) / 1000)
item.speed = self.bytes(item.speed, 0, 0) + '/s'
item.done = (item.fileLength / item.total) * 100
// this.$set(this.fileList, 0,item)
}
}).then(res => {

View File

@@ -657,7 +657,6 @@ export default {
if (params.assetId) {
this.assetShowChange()
} else {
console.log()
this.customConnect = {
authType: Number(params.authType),
...params
@@ -1059,7 +1058,7 @@ export default {
const targetDiv = document.getElementById('shell-service')
targetDiv.style.height = this.webSSHHeight
if (!this.webSSHHeight) {
this.initConsoleHeight = this.initConsoleHeight > window.innerHeight * 0.4 ? this.initConsoleHeight : window.innerHeight
this.initConsoleHeight = this.initConsoleHeight > (window.innerHeight * 0.4) ? this.initConsoleHeight : (window.innerHeight * 0.4)
targetDiv.style.height = this.initConsoleHeight + 'px'
}
}
@@ -1070,6 +1069,7 @@ export default {
created () {
// window.addEventListener('resize',this.windowChange);
window.addEventListener('resize', this.debounce(this.windowChange, 1000), false)
this.initConsoleHeight = this.initConsoleHeight > (window.innerHeight * 0.4) ? this.initConsoleHeight : (window.innerHeight * 0.4)
},
mounted () {

View File

@@ -18,7 +18,7 @@
:fixed="item.fixed"
:label="item.label"
:min-width="`${item.minWidth}`"
:width="`${item.Width}`"
:width="`${item.width}`"
:prop="item.prop"
:resizable="true"
:sort-orders="['ascending', 'descending']"
@@ -88,7 +88,8 @@ export default {
}, {
label: this.$t('overall.type'),
prop: 'type',
width: 80,
width: 150,
minWidth: 30,
show: true,
sortable: 'custom'
},
@@ -96,7 +97,8 @@ export default {
label: this.$t('overall.time'),
prop: 'ts',
show: true,
width: 80,
width: 180,
minWidth: 40,
sortable: 'custom'
}
]

View File

@@ -65,6 +65,16 @@
<span>{{getDuration(scope.row)}}</span>
</el-tooltip>
</template>
<template v-else-if="item.prop === 'cmdNum'">
<div style="cursor: pointer" @click="showBottomBox('cmdTab', scope.row)">
{{scope.row[item.prop] ? scope.row[item.prop] : '-'}}
</div>
</template>
<template v-else-if="item.prop === 'sftpNum'">
<div style="cursor: pointer" @click="showBottomBox('sftpTab', scope.row)">
{{scope.row[item.prop] ? scope.row[item.prop] : '-'}}
</div>
</template>
<template v-else-if="item.prop === 'authType'">
<span v-if="scope.row.authType == 1">{{$t('login.pin')}}</span>
<span v-else-if="scope.row.authType == 2">{{$t('config.terminallog.key')}}</span>
@@ -183,6 +193,20 @@ export default {
minWidth: 100,
show: false
},
{
label: this.$t('config.terminallog.cmd.cmd'),
prop: 'cmdNum',
show: false,
width: 120,
sortable: 'custom'
},
{
label: this.$t('terminal.sftp'),
prop: 'sftpNum',
show: false,
width: 100,
sortable: 'custom'
},
{
label: this.$t('overall.state'), // killusername鼠标悬停形式
prop: 'state',