From c2da62e86b594f22d142ea36bfadeb566a0c3b58 Mon Sep 17 00:00:00 2001 From: shanshuirenjia <978987373@qq.com> Date: Thu, 13 Dec 2018 11:05:47 +0800 Subject: [PATCH] repair bug --- frontend/src/components/dir-view/dir-view.js | 9 ++++----- .../src/components/dirent-list-view/dirent-list-item.js | 2 +- .../shared-repo-list-view/shared-repo-list-item.js | 2 +- frontend/src/pages/my-libs/item.js | 6 +++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/dir-view/dir-view.js b/frontend/src/components/dir-view/dir-view.js index 5d17ba4f95..2693c2a201 100644 --- a/frontend/src/components/dir-view/dir-view.js +++ b/frontend/src/components/dir-view/dir-view.js @@ -44,7 +44,7 @@ class DirView extends React.Component { } componentDidMount() { - //eg: http://127.0.0.1:8000/library/repo_id/repo_name/**/**/ + //eg: http://127.0.0.1:8000/library/repo_id/repo_name/**/**/\ let location = decodeURIComponent(window.location.href); let repoID = this.props.repoID; seafileAPI.getRepoInfo(repoID).then(res => { @@ -66,8 +66,7 @@ class DirView extends React.Component { updateDirentList = (filePath) => { let repoID = this.state.repoID; this.setState({isDirentListLoading: true}); - - const path = encodeURIComponent(filePath); + const path = Utils.encodePath(filePath); seafileAPI.listDir(repoID, path).then(res => { let direntList = res.data.map(item => { return new Dirent(item); @@ -88,7 +87,7 @@ class DirView extends React.Component { this.updateDirentList(direntPath); this.setState({path: direntPath}); - let fileUrl = siteRoot + 'library/' + this.state.repoID + '/' + this.state.repoName + direntPath; + let fileUrl = siteRoot + 'library/' + this.state.repoID + '/' + this.state.repoName + Utils.encodePath(direntPath); window.history.pushState({url: fileUrl, path: direntPath}, direntPath, fileUrl); } else { const w=window.open('about:blank'); @@ -308,7 +307,7 @@ class DirView extends React.Component { this.updateDirentList(path); this.setState({path: path}); - let fileUrl = siteRoot + 'library/' + this.state.repoID + '/' + this.state.repoName + path; + let fileUrl = siteRoot + 'library/' + this.state.repoID + '/' + this.state.repoName + Utils.encodePath(path); window.history.pushState({url: fileUrl, path: path}, path, fileUrl); } diff --git a/frontend/src/components/dirent-list-view/dirent-list-item.js b/frontend/src/components/dirent-list-view/dirent-list-item.js index 9f0c260532..70324cee90 100644 --- a/frontend/src/components/dirent-list-view/dirent-list-item.js +++ b/frontend/src/components/dirent-list-view/dirent-list-item.js @@ -376,7 +376,7 @@ class DirentListItem extends React.Component { render() { let { path, dirent } = this.props; let direntPath = Utils.joinPath(path, dirent.name); - let href = siteRoot + 'wiki/lib/' + this.props.repoID + direntPath; + let href = siteRoot + 'wiki/lib/' + this.props.repoID + Utils.encodePath(direntPath); return ( diff --git a/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js b/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js index c78b153167..b575759df1 100644 --- a/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js +++ b/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js @@ -91,7 +91,7 @@ class SharedRepoListItem extends React.Component { }); //todo change to library; div-view is not compatibility - let libPath = `${siteRoot}library/${this.props.repo.repo_id}/${this.props.repo.repo_name}/`; + let libPath = `${siteRoot}library/${repo.repo_id}/${Utils.encodePath(repo.repo_name)}/`; return { iconUrl, iconTitle, libPath }; } diff --git a/frontend/src/pages/my-libs/item.js b/frontend/src/pages/my-libs/item.js index cb4aa993b0..0d9e2b9a76 100644 --- a/frontend/src/pages/my-libs/item.js +++ b/frontend/src/pages/my-libs/item.js @@ -168,7 +168,7 @@ class Item extends Component { 'is_admin': data.is_admin, 'permission': permission }); - data.url = `${siteRoot}library/${data.repo_id}/`; + data.url = `${siteRoot}library/${data.repo_id}/${Utils.encodePath(data.repo_name)}`; let iconVisibility = this.state.showOpIcon ? '' : ' invisible'; let shareIconClassName = 'sf2-icon-share sf2-x op-icon' + iconVisibility; @@ -243,7 +243,7 @@ class Item extends Component { /> )} {!this.state.showChangeLibName && data.repo_name && ( - {data.repo_name} + {data.repo_name} )} {!this.state.showChangeLibName && !data.repo_name && (gettext('Broken (please contact your administrator to fix this library)')) @@ -261,7 +261,7 @@ class Item extends Component { {data.icon_title} {data.repo_name ? - {data.repo_name} : + {data.repo_name} : gettext('Broken (please contact your administrator to fix this library)')}
{Utils.formatSize({bytes: data.size})}