Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the bug of changing the state during the render process and other small bugs #335

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"react-intl-universal": "^2.4.2",
"react-json-view": "^1.21.3",
"react-resizable": "^1.11.0",
"react-router-dom": "^6.15.0",
"redux-logger": "^3.0.6",
"setprototypeof": "^1.1.0",
"url-polyfill": "^1.0.10"
Expand Down
36 changes: 21 additions & 15 deletions src/layouts/BasicLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ class BasicLayout extends React.PureComponent {
localeName: window.sessionStorage.getItem("locale")
? window.sessionStorage.getItem("locale")
: "en-US",
pluginsLoaded: false
pluginsLoaded: false,
processedMenus: []
};
}

Expand All @@ -135,6 +136,7 @@ class BasicLayout extends React.PureComponent {
});
return;
}
this.processMenus()
const { dispatch } = this.props;
dispatch({
type: "global/fetchPlatform"
Expand Down Expand Up @@ -216,19 +218,9 @@ class BasicLayout extends React.PureComponent {
});
};

render() {
const {
collapsed,
routerData,
match,
location,
plugins,
menuTree,
permissions,
dispatch
} = this.props;
const { localeName, pluginsLoaded } = this.state;
const bashRedirect = this.getBaseRedirect();
processMenus() {
const { plugins, menuTree, permissions, dispatch } = this.props
const { pluginsLoaded } = this.state
let menus = getMenuData();
if (menuTree.length > 0) {
menus = menus.slice(0, 1);
Expand Down Expand Up @@ -308,13 +300,27 @@ class BasicLayout extends React.PureComponent {
}
});

this.setState({processedMenus: menus})
}

render() {
const {
collapsed,
routerData,
match,
location,
dispatch
} = this.props;
const { localeName, processedMenus } = this.state;
const bashRedirect = this.getBaseRedirect();

const layout = (
<Layout>
<SiderMenu
logo={logo}
TitleLogo={TitleLogo}
dispatch={dispatch}
menuData={menus}
menuData={processedMenus}
collapsed={collapsed}
location={location}
onCollapse={this.handleMenuCollapse}
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/UserLayout.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
flex-direction: column;
height: 100vh;
overflow: auto;
background-image: url();
// background-image: url();
background: #ffffff;
}

Expand Down Expand Up @@ -78,4 +78,4 @@
color: #ffffff;
margin-top: 12px;
margin-bottom: 40px;
}
}
2 changes: 1 addition & 1 deletion src/routes/System/Plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export default class Plugin extends Component {
width: 120,
render: (text, record) => {
return record.url
? <Link to={record.url}><div style={{color: "#1890ff", "fontWeight": "bold", "text-decoration-line": "underline"}}>{text || "----"}</div></Link>
? <Link to={record.url}><div style={{color: "#1890ff", "fontWeight": "bold", "textDecorationLine": "underline"}}>{text || "----"}</div></Link>
: <div style={{color: "#260033", "fontWeight": "bold"}}>{text || "----"}</div>;
}
},
Expand Down
Loading