Browse Source

fix: 主机文件的路径栏路径 Bug 解决 (#6428)

Refs #6310
pull/6431/head
2 months ago committed by GitHub
parent
commit
b6c873f22d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      backend/app/service/file.go
  2. 32
      frontend/src/views/host/file-management/index.vue

6
backend/app/service/file.go

@ -62,9 +62,13 @@ func NewIFileService() IFileService {
func (f *FileService) GetFileList(op request.FileOption) (response.FileInfo, error) {
var fileInfo response.FileInfo
if _, err := os.Stat(op.Path); err != nil && os.IsNotExist(err) {
data, err := os.Stat(op.Path)
if err != nil && os.IsNotExist(err) {
return fileInfo, nil
}
if !data.IsDir() {
op.FileOption.Path = filepath.Dir(op.FileOption.Path)
}
info, err := files.NewFileInfo(op.FileOption)
if err != nil {
return fileInfo, err

32
frontend/src/views/host/file-management/index.vue

@ -724,40 +724,22 @@ const top = () => {
};
const jump = async (url: string) => {
const fileName = url.substring(url.lastIndexOf('/') + 1);
let filePath = url.substring(0, url.lastIndexOf('/') + 1);
if (!url.includes('.')) {
filePath = url;
}
history.splice(pointer + 1);
history.push(url);
pointer = history.length - 1;
const oldUrl = req.path;
const oldPageSize = req.pageSize;
// reset search params before exec jump
Object.assign(req, initData());
req.path = filePath;
req.containSub = false;
req.search = '';
req.pageSize = oldPageSize;
const { path: oldUrl, pageSize: oldPageSize } = req;
Object.assign(req, initData(), { path: url, containSub: false, search: '', pageSize: oldPageSize });
let searchResult = await searchFile();
globalStore.setLastFilePath(req.path);
// check search result,the file is exists?
if (!searchResult.data.path) {
req.path = oldUrl;
globalStore.setLastFilePath(req.path);
MsgWarning(i18n.global.t('commons.res.notFound'));
return;
}
if (fileName && fileName.length > 1 && fileName.includes('.')) {
const fileData = searchResult.data.items.filter((item) => item.name === fileName);
if (fileData && fileData.length === 1) {
openView(fileData[0]);
} else {
MsgWarning(i18n.global.t('commons.res.notFound'));
}
}
req.path = searchResult.data.path;
globalStore.setLastFilePath(req.path);
handleSearchResult(searchResult);
getPaths(req.path);
nextTick(function () {
@ -896,6 +878,10 @@ const openView = (item: File.File) => {
};
const openPreview = (item: File.File, fileType: string) => {
if (item.mode.toString() == '-' && item.user == '-' && item.group == '-') {
MsgWarning(i18n.global.t('file.fileCanNotRead'));
return;
}
filePreview.path = item.isSymlink ? item.linkPath : item.path;
filePreview.name = item.name;
filePreview.extension = item.extension;

Loading…
Cancel
Save