mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-28 21:39:06 +08:00
fix: 修改 ssh 登录日志排序规则 (#1264)
This commit is contained in:
parent
056c771d2e
commit
4fdb81642a
@ -6,6 +6,7 @@ import (
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -222,6 +223,7 @@ func (u *SSHService) LoadLog(req dto.SearchSSHLog) (*dto.SSHLog, error) {
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fileList = sortFileList(fileList)
|
||||
|
||||
command := ""
|
||||
if len(req.Info) != 0 {
|
||||
@ -284,6 +286,26 @@ func (u *SSHService) LoadLog(req dto.SearchSSHLog) (*dto.SSHLog, error) {
|
||||
return &data, nil
|
||||
}
|
||||
|
||||
func sortFileList(fileNames []string) []string {
|
||||
if len(fileNames) < 2 {
|
||||
return fileNames
|
||||
}
|
||||
var itemFile []string
|
||||
if strings.Contains(fileNames[0], "secure") {
|
||||
sort.Slice(fileNames, func(i, j int) bool {
|
||||
return fileNames[i] < fileNames[j]
|
||||
})
|
||||
itemFile = append(itemFile, fileNames[1:]...)
|
||||
itemFile = append(itemFile, fileNames[0])
|
||||
return itemFile
|
||||
}
|
||||
|
||||
sort.Slice(fileNames, func(i, j int) bool {
|
||||
return fileNames[i] > fileNames[j]
|
||||
})
|
||||
return fileNames
|
||||
}
|
||||
|
||||
func updateSSHConf(oldFiles []string, param string, value interface{}) []string {
|
||||
hasKey := false
|
||||
var newFiles []string
|
||||
|
@ -228,6 +228,7 @@ const message = {
|
||||
container: 'Container',
|
||||
cronjob: 'Cronjob',
|
||||
host: 'Host',
|
||||
ssh: 'SSH Setting',
|
||||
security: 'Security',
|
||||
files: 'File',
|
||||
monitor: 'Monitor',
|
||||
@ -869,6 +870,8 @@ const message = {
|
||||
fileUploadStart: 'Uploading [{0}]....',
|
||||
},
|
||||
ssh: {
|
||||
sshAlert:
|
||||
'The list data is sorted based on login time, but please note that changing time zones or other operations may cause deviations in the time of login logs.',
|
||||
sshOperate: 'Operation [{0}] on the SSH service is performed. Do you want to continue?',
|
||||
sshChange: 'SSH Setting',
|
||||
sshChangeHelper: 'This action changed {0} to [{1}]. Do you want to continue?',
|
||||
|
@ -863,6 +863,7 @@ const message = {
|
||||
fileUploadStart: '正在上传[{0}]....',
|
||||
},
|
||||
ssh: {
|
||||
sshAlert: '列表数据根据登录时间排序,但请注意,切换时区或其他操作可能导致登录日志的时间出现偏差。',
|
||||
sshOperate: '对 SSH 服务进行 [{0}] 操作,是否继续?',
|
||||
sshChange: 'SSH 配置修改',
|
||||
sshChangeHelper: '此操作将 {0} 修改为 [{1}] ,是否继续?',
|
||||
|
@ -1,6 +1,15 @@
|
||||
<template>
|
||||
<div>
|
||||
<LayoutContent v-loading="loading" :title="$t('ssh.loginLogs')">
|
||||
<template #prompt>
|
||||
<el-alert type="info" :closable="false">
|
||||
<template #default>
|
||||
<span>
|
||||
{{ $t('ssh.sshAlert') }}
|
||||
</span>
|
||||
</template>
|
||||
</el-alert>
|
||||
</template>
|
||||
<template #toolbar>
|
||||
<el-row>
|
||||
<el-col :xs="24" :sm="16" :md="16" :lg="16" :xl="16">
|
||||
|
Loading…
Reference in New Issue
Block a user