fix:修复文件路径bug (#6313)

* fix:修复文件路径bug

* fix:修改文件路径逻辑
This commit is contained in:
trom 2024-09-02 10:35:32 +08:00 committed by GitHub
parent 5b00286e65
commit cf8aa86a67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -550,6 +550,11 @@ const top = () => {
}; };
const jump = async (url: string) => { 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.splice(pointer + 1);
history.push(url); history.push(url);
pointer = history.length - 1; pointer = history.length - 1;
@ -558,7 +563,7 @@ const jump = async (url: string) => {
const oldPageSize = req.pageSize; const oldPageSize = req.pageSize;
// reset search params before exec jump // reset search params before exec jump
Object.assign(req, initData()); Object.assign(req, initData());
req.path = url; req.path = filePath;
req.containSub = false; req.containSub = false;
req.search = ''; req.search = '';
req.pageSize = oldPageSize; req.pageSize = oldPageSize;
@ -571,6 +576,14 @@ const jump = async (url: string) => {
MsgWarning(i18n.global.t('commons.res.notFound')); MsgWarning(i18n.global.t('commons.res.notFound'));
return; 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'));
}
}
handleSearchResult(searchResult); handleSearchResult(searchResult);
getPaths(req.path); getPaths(req.path);
nextTick(function () { nextTick(function () {