Commit f3178a81 authored by afc163's avatar afc163

Fix JSON parse error in authority

close #2243
close #2276
close #2185
close #2226
close #2218
close #2241
ref #2170
parent f344342b
...@@ -98,7 +98,6 @@ export default class SiderMenu extends PureComponent { ...@@ -98,7 +98,6 @@ export default class SiderMenu extends PureComponent {
return ( return (
<Sider <Sider
trigger={null}
collapsible collapsible
collapsed={collapsed} collapsed={collapsed}
breakpoint="lg" breakpoint="lg"
......
// use localStorage to store the authority info, which might be sent from server in actual project. // use localStorage to store the authority info, which might be sent from server in actual project.
export function getAuthority() { export function getAuthority() {
// return localStorage.getItem('antd-pro-authority') || ['admin', 'user']; // return localStorage.getItem('antd-pro-authority') || ['admin', 'user'];
let authority = localStorage.getItem('antd-pro-authority'); const authorityString = localStorage.getItem('antd-pro-authority');
if (authority) { let authority;
if (authority.includes('[')) { try {
authority = JSON.parse(authority); authority = JSON.parse(authorityString);
} else { } catch (e) {
authority = [JSON.parse(authority)]; authority = [authorityString];
} }
} else { return authority || ['admin'];
authority = ['admin'];
}
return authority;
} }
export function setAuthority(authority) { export function setAuthority(authority) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment