Skip to content

Commit

Permalink
fix(用户登录): 权限设置
Browse files Browse the repository at this point in the history
权限为undefined时不缓存
  • Loading branch information
Lind-pro committed Sep 25, 2020
1 parent 0f8a7d6 commit 047296f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions config/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
export default {
dev: {
'/jetlinks': {
// target: 'http://127.0.0.1:8848/',
// ws: 'ws://127.0.0.1:8848/',
ws: 'ws://demo.jetlinks.cn/jetlinks',
target: 'http://demo.jetlinks.cn/jetlinks',
target: 'http://127.0.0.1:8848/',
ws: 'ws://127.0.0.1:8848/',
// ws: 'ws://demo.jetlinks.cn/jetlinks',
// target: 'http://demo.jetlinks.cn/jetlinks',
changeOrigin: true,
pathRewrite: { '^/jetlinks': '' },
},
Expand Down
6 changes: 1 addition & 5 deletions src/layouts/BasicLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] => {
// };
// return localItem?.version && version === 'community' ? [] : Authorized.check(item.authority, localItem, null) as MenuDataItem;
// });
// }
console.log(getAuthority(),'fff');
// }
return menuList.map(item => {
const localItem: any = {
...item,
Expand Down Expand Up @@ -139,9 +138,6 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => {
},
} = props;


const auth = localStorage.getItem('hsweb-autz');

useEffect(() => {
if (dispatch) {
dispatch({
Expand Down
4 changes: 3 additions & 1 deletion src/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const UserModel: UserModelType = {
*fetchCurrent(_, { call, put }) {
const response = yield call(queryCurrent);
if (response) {
localStorage.setItem('hsweb-autz', JSON.stringify(response.result));
if(response.result){
localStorage.setItem('hsweb-autz', JSON.stringify(response.result));
}
yield put({
type: 'saveCurrentUser',
payload: response.result.user,
Expand Down
4 changes: 3 additions & 1 deletion src/utils/authority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ export function clearAutz() {
export function setAutz(info: Authentication): Authentication {
window.top.hsweb_autz = new Authentication(info);
const autz = new Authentication(info);
localStorage.setItem('hsweb-autz', JSON.stringify(info));
if(JSON.stringify(info)!=='undefined'){
localStorage.setItem('hsweb-autz', JSON.stringify(info));
}
return autz;
}

0 comments on commit 047296f

Please sign in to comment.