fix: 解决网站日志审计切换网站日志显示错误的问题 (#2708)

Refs https://github.com/1Panel-dev/1Panel/issues/2670
pull/2710/head
zhengkunwang 2023-10-27 15:27:25 +08:00 committed by GitHub
parent 1ca199ac6b
commit e952b77334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 5 deletions

View File

@ -248,13 +248,13 @@ func (b *BaseApi) DeCompressFile(c *gin.Context) {
// @Summary Load file content
// @Description 获取文件内容
// @Accept json
// @Param request body request.FileOption true "request"
// @Param request body request.FileContentReq true "request"
// @Success 200 {object} response.FileInfo
// @Security ApiKeyAuth
// @Router /files/content [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"获取文件内容 [path]","formatEN":"Load file content [path]"}
func (b *BaseApi) GetContent(c *gin.Context) {
var req request.FileOption
var req request.FileContentReq
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}

View File

@ -9,6 +9,10 @@ type FileOption struct {
files.FileOption
}
type FileContentReq struct {
Path string `json:"path" validate:"required"`
}
type SearchUploadWithPage struct {
dto.PageInfo
Path string `json:"path" validate:"required"`

View File

@ -32,7 +32,7 @@ type IFileService interface {
ChangeMode(op request.FileCreate) error
Compress(c request.FileCompress) error
DeCompress(c request.FileDeCompress) error
GetContent(op request.FileOption) (response.FileInfo, error)
GetContent(op request.FileContentReq) (response.FileInfo, error)
SaveContent(edit request.FileEdit) error
FileDownload(d request.FileDownload) (string, error)
DirSize(req request.DirSizeReq) (response.DirSizeRes, error)
@ -191,8 +191,10 @@ func (f *FileService) DeCompress(c request.FileDeCompress) error {
return fo.Decompress(c.Path, c.Dst, files.CompressType(c.Type))
}
func (f *FileService) GetContent(op request.FileOption) (response.FileInfo, error) {
info, err := files.NewFileInfo(op.FileOption)
func (f *FileService) GetContent(op request.FileContentReq) (response.FileInfo, error) {
info, err := files.NewFileInfo(files.FileOption{
Path: op.Path,
})
if err != nil {
return response.FileInfo{}, err
}

View File

@ -169,6 +169,8 @@ const search = () => {
content.value = content.value + '\n' + res.data.content;
}
}
} else {
content.value = '';
}
end.value = res.data.end;
nextTick(() => {