From 2c442f0932e5bf7076fe0f0b98b60f16a09dc8c2 Mon Sep 17 00:00:00 2001 From: Michael An <2331806369@qq.com> Date: Thu, 6 Jun 2024 16:57:20 +0800 Subject: [PATCH] Fix searched file is markdown (#6172) * fix searched file is markdown * delete uesless codes --- frontend/src/pages/file-history/main-panel.js | 5 --- .../lib-content-view/lib-content-view.js | 33 ++++++++++--------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/frontend/src/pages/file-history/main-panel.js b/frontend/src/pages/file-history/main-panel.js index ba10695593..972a32d03c 100644 --- a/frontend/src/pages/file-history/main-panel.js +++ b/frontend/src/pages/file-history/main-panel.js @@ -12,11 +12,6 @@ const propTypes = { }; class MainPanel extends React.Component { - - onSearchedClick = () => { - //todos; - }; - render() { const { renderingContent, newMarkdownContent } = this.props; return ( diff --git a/frontend/src/pages/lib-content-view/lib-content-view.js b/frontend/src/pages/lib-content-view/lib-content-view.js index d19aa438ce..b7f9e2ae57 100644 --- a/frontend/src/pages/lib-content-view/lib-content-view.js +++ b/frontend/src/pages/lib-content-view/lib-content-view.js @@ -932,6 +932,9 @@ class LibContentView extends React.Component { }; onSearchedClick = (item) => { + if (item.repo_id !== this.props.repoID) { + this.openSearchedNewTab(item); + } let path = item.is_dir ? item.path.slice(0, item.path.length - 1) : item.path; if (this.state.currentPath === path) { return; @@ -962,32 +965,30 @@ class LibContentView extends React.Component { if (Utils.isMarkdownFile(path)) { this.showFile(path); } else { - let url = siteRoot + 'lib/' + item.repo_id + '/file' + Utils.encodePath(path); - let isWeChat = Utils.isWeChat(); - if (!isWeChat) { - let newWindow = window.open('about:blank'); - newWindow.location.href = url; - } else { - location.href = url; - } + this.openSearchedNewTab(item); } } } else { if (item.is_dir) { this.showDir(path); } else { - let url = siteRoot + 'lib/' + item.repo_id + '/file' + Utils.encodePath(path); - let isWeChat = Utils.isWeChat(); - if (!isWeChat) { - let newWindow = window.open('about:blank'); - newWindow.location.href = url; - } else { - location.href = url; - } + this.openSearchedNewTab(item); } } }; + openSearchedNewTab = (item) => { + let path = item.is_dir ? item.path.slice(0, item.path.length - 1) : item.path; + let url = siteRoot + 'lib/' + item.repo_id + '/file' + Utils.encodePath(path); + let isWeChat = Utils.isWeChat(); + if (!isWeChat) { + let newWindow = window.open('about:blank'); + newWindow.location.href = url; + } else { + location.href = url; + } + }; + onMainNavBarClick = (nodePath) => { //just for dir this.resetSelected();