mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-09 07:00:48 +08:00
feat: 查看文件详情解除二进制文件限制 (#5696)
This commit is contained in:
parent
2e8403347a
commit
0d3e834b37
5 changed files with 14 additions and 6 deletions
|
@ -10,7 +10,8 @@ type FileOption struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileContentReq struct {
|
type FileContentReq struct {
|
||||||
Path string `json:"path" validate:"required"`
|
Path string `json:"path" validate:"required"`
|
||||||
|
IsDetail bool `json:"isDetail"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchUploadWithPage struct {
|
type SearchUploadWithPage struct {
|
||||||
|
|
|
@ -288,8 +288,9 @@ func (f *FileService) DeCompress(c request.FileDeCompress) error {
|
||||||
|
|
||||||
func (f *FileService) GetContent(op request.FileContentReq) (response.FileInfo, error) {
|
func (f *FileService) GetContent(op request.FileContentReq) (response.FileInfo, error) {
|
||||||
info, err := files.NewFileInfo(files.FileOption{
|
info, err := files.NewFileInfo(files.FileOption{
|
||||||
Path: op.Path,
|
Path: op.Path,
|
||||||
Expand: true,
|
Expand: true,
|
||||||
|
IsDetail: op.IsDetail,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return response.FileInfo{}, err
|
return response.FileInfo{}, err
|
||||||
|
|
|
@ -44,6 +44,7 @@ type FileInfo struct {
|
||||||
Items []*FileInfo `json:"items"`
|
Items []*FileInfo `json:"items"`
|
||||||
ItemTotal int `json:"itemTotal"`
|
ItemTotal int `json:"itemTotal"`
|
||||||
FavoriteID uint `json:"favoriteID"`
|
FavoriteID uint `json:"favoriteID"`
|
||||||
|
IsDetail bool `json:"isDetail"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileOption struct {
|
type FileOption struct {
|
||||||
|
@ -57,6 +58,7 @@ type FileOption struct {
|
||||||
PageSize int `json:"pageSize"`
|
PageSize int `json:"pageSize"`
|
||||||
SortBy string `json:"sortBy"`
|
SortBy string `json:"sortBy"`
|
||||||
SortOrder string `json:"sortOrder"`
|
SortOrder string `json:"sortOrder"`
|
||||||
|
IsDetail bool `json:"isDetail"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileSearchInfo struct {
|
type FileSearchInfo struct {
|
||||||
|
@ -89,6 +91,7 @@ func NewFileInfo(op FileOption) (*FileInfo, error) {
|
||||||
Gid: strconv.FormatUint(uint64(info.Sys().(*syscall.Stat_t).Gid), 10),
|
Gid: strconv.FormatUint(uint64(info.Sys().(*syscall.Stat_t).Gid), 10),
|
||||||
Group: GetGroup(info.Sys().(*syscall.Stat_t).Gid),
|
Group: GetGroup(info.Sys().(*syscall.Stat_t).Gid),
|
||||||
MimeType: GetMimeType(op.Path),
|
MimeType: GetMimeType(op.Path),
|
||||||
|
IsDetail: op.IsDetail,
|
||||||
}
|
}
|
||||||
favoriteRepo := repo.NewIFavoriteRepo()
|
favoriteRepo := repo.NewIFavoriteRepo()
|
||||||
favorite, _ := favoriteRepo.GetFirst(favoriteRepo.WithByPath(op.Path))
|
favorite, _ := favoriteRepo.GetFirst(favoriteRepo.WithByPath(op.Path))
|
||||||
|
@ -322,8 +325,10 @@ func (f *FileInfo) getContent() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(cByte) > 0 && DetectBinary(cByte) {
|
if !f.IsDetail {
|
||||||
return buserr.New(constant.ErrFileCanNotRead)
|
if len(cByte) > 0 && DetectBinary(cByte) {
|
||||||
|
return buserr.New(constant.ErrFileCanNotRead)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
f.Content = string(cByte)
|
f.Content = string(cByte)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -33,6 +33,7 @@ export namespace File {
|
||||||
containSub?: boolean;
|
containSub?: boolean;
|
||||||
sortBy?: string;
|
sortBy?: string;
|
||||||
sortOrder?: string;
|
sortOrder?: string;
|
||||||
|
isDetail?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SearchUploadInfo extends ReqPage {
|
export interface SearchUploadInfo extends ReqPage {
|
||||||
|
|
|
@ -56,7 +56,7 @@ const handleClose = () => {
|
||||||
|
|
||||||
const acceptParams = async (params: InfoProps): Promise<void> => {
|
const acceptParams = async (params: InfoProps): Promise<void> => {
|
||||||
props.value = params;
|
props.value = params;
|
||||||
GetFileContent({ path: params.path, expand: false, page: 1, pageSize: 1 }).then((res) => {
|
GetFileContent({ path: params.path, expand: false, page: 1, pageSize: 1, isDetail: true }).then((res) => {
|
||||||
data.value = res.data;
|
data.value = res.data;
|
||||||
open.value = true;
|
open.value = true;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue