mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 18:30:53 +00:00
style: optimize code
This commit is contained in:
@@ -39,17 +39,21 @@ class Wiki extends Component {
|
||||
assets_url: '',
|
||||
};
|
||||
}
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
if (!Utils.isDesktop()) {
|
||||
this.setState({ closeSideBar: true });
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.getWikiConfig();
|
||||
}
|
||||
|
||||
handlePath = () => {
|
||||
return isWiki2 ? 'wikis/' : 'published/';
|
||||
};
|
||||
|
||||
getWikiConfig = () => {
|
||||
wikiAPI.getWiki2Config(wikiId).then(res => {
|
||||
const { wiki_config, repo_id } = res.data.wiki;
|
||||
@@ -85,6 +89,7 @@ class Wiki extends Component {
|
||||
onError && onError();
|
||||
});
|
||||
};
|
||||
|
||||
getFirstPageId = (config) => {
|
||||
if (!config || !Array.isArray(config.navigation)) return '';
|
||||
for (let i = 0; i < config.navigation.length; i++) {
|
||||
@@ -97,6 +102,7 @@ class Wiki extends Component {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getSdocFileContent = (docUuid, accessToken) => {
|
||||
const config = {
|
||||
docUuid,
|
||||
@@ -114,9 +120,11 @@ class Wiki extends Component {
|
||||
toaster.danger(errorMsg);
|
||||
});
|
||||
};
|
||||
|
||||
onCloseSide = () => {
|
||||
this.setState({ closeSideBar: !this.state.closeSideBar });
|
||||
};
|
||||
|
||||
showPage = (pageId, filePath) => {
|
||||
this.setState({
|
||||
isDataLoading: true,
|
||||
@@ -142,6 +150,7 @@ class Wiki extends Component {
|
||||
const fileUrl = `${siteRoot}${this.handlePath()}${wikiId}/?${params.toString()}`;
|
||||
window.history.pushState({ url: fileUrl, path: filePath }, filePath, fileUrl);
|
||||
};
|
||||
|
||||
setCurrentPage = (pageId, callback) => {
|
||||
const { currentPageId, config } = this.state;
|
||||
if (pageId === currentPageId) {
|
||||
@@ -162,6 +171,7 @@ class Wiki extends Component {
|
||||
callback && callback();
|
||||
});
|
||||
};
|
||||
|
||||
onUpdatePage = (pageId, newPage) => {
|
||||
if (newPage.name === '') {
|
||||
toaster.danger(gettext('Page name cannot be empty'));
|
||||
|
@@ -36,7 +36,6 @@ function getPaths(navigation, currentPageId, pages) {
|
||||
}
|
||||
|
||||
function WikiTopNav({ config, currentPageId }) {
|
||||
console.log('config in wiki top nav',config)
|
||||
const { navigation, pages } = config;
|
||||
const paths = getPaths(navigation, currentPageId, pages);
|
||||
return (
|
||||
|
@@ -47,4 +47,4 @@ const getCurrentPageConfig = (pages,pageId) => {
|
||||
return pages.filter(page => page.id === pageId)[0]
|
||||
}
|
||||
|
||||
export { generatorBase64Code, generateUniqueId, isObjectNotEmpty, getIconURL,getCurrentPageConfig };
|
||||
export { generatorBase64Code, generateUniqueId, isObjectNotEmpty, getIconURL, getCurrentPageConfig };
|
||||
|
Reference in New Issue
Block a user