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

Refs https://github.com/1Panel-dev/1Panel/issues/2670
This commit is contained in:
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 // @Summary Load file content
// @Description 获取文件内容 // @Description 获取文件内容
// @Accept json // @Accept json
// @Param request body request.FileOption true "request" // @Param request body request.FileContentReq true "request"
// @Success 200 {object} response.FileInfo // @Success 200 {object} response.FileInfo
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /files/content [post] // @Router /files/content [post]
// @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"获取文件内容 [path]","formatEN":"Load file content [path]"} // @x-panel-log {"bodyKeys":["path"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"获取文件内容 [path]","formatEN":"Load file content [path]"}
func (b *BaseApi) GetContent(c *gin.Context) { func (b *BaseApi) GetContent(c *gin.Context) {
var req request.FileOption var req request.FileContentReq
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }

View file

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

View file

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

View file

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