From d19d22c69de69b52947252c16c3334c630ec655d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=9B=BD=E7=92=87?= <37972689+YangGuoXuan-0503@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:00:12 +0800 Subject: [PATCH] fix: open in new tab (#7200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: open in new tab * feat: optimize code --------- Co-authored-by: 杨国璇 --- frontend/src/metadata/utils/file.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/frontend/src/metadata/utils/file.js b/frontend/src/metadata/utils/file.js index 23548432e5..d9098be10a 100644 --- a/frontend/src/metadata/utils/file.js +++ b/frontend/src/metadata/utils/file.js @@ -103,13 +103,9 @@ export const openFile = (repoID, record, _openImage = () => {}) => { export const openInNewTab = (repoID, record) => { if (!record) return; const isDir = checkIsDir(record); - const parentDir = getParentDirFromRecord(record); const fileName = getFileNameFromRecord(record); - const url = isDir - ? window.location.origin + window.location.pathname + Utils.encodePath(Utils.joinPath(parentDir, fileName)) - : `${siteRoot}lib/${repoID}/file${Utils.encodePath(Utils.joinPath(parentDir, fileName))}`; - - window.open(url, '_blank'); + const parentDir = _getParentDir(record); + _openByNewWindow(repoID, fileName, parentDir, isDir ? FILE_TYPE.FOLDER : ''); }; export const openParentFolder = (record) => {