提交 9ed4b601 authored 作者: 钟是志's avatar 钟是志

33470 请销假管理系统-权限配置-辅导员/班主任列表,开放修改功能暂无对应修改辅导员信息功能

上级 3d9655ec
import React, { useMemo } from 'react';
import { isJSON } from '@/webPublic/one_stop_public/copy';
export default function Authorized(props) {
const {
authority,
children
} = props;
const check = useMemo(() => {
let parentIframeRouteInfo = localStorage.getItem('parentRouteInfo'); // 获取父节点路由信息
parentIframeRouteInfo = isJSON(parentIframeRouteInfo) ? JSON.parse(parentIframeRouteInfo) : null;
let allAuth = localStorage.getItem('antd-pro-authority');
allAuth = isJSON(allAuth) ? JSON.parse(allAuth) : null;
if(!parentIframeRouteInfo || !allAuth){
return false;
}
const { path } = parentIframeRouteInfo;
const checkPath = path + authority;
console.log('检查权限:', checkPath);
let findX = allAuth.find((g) => g === checkPath);
return !!findX;
}, [authority]);
if (!check) {
return null;
}
return children;
}
...@@ -11,7 +11,7 @@ window.addEventListener('message', (event) => { ...@@ -11,7 +11,7 @@ window.addEventListener('message', (event) => {
if (event.data && event.data.indexOf) { if (event.data && event.data.indexOf) {
if (event.data.indexOf('iframeGetScrollHeight') > -1) { if (event.data.indexOf('iframeGetScrollHeight') > -1) {
const height = event.data.split('-')[1]; const height = event.data.split('-')[1];
console.log('父页面向子iframe页面发送滚动高度: ', event.data); // console.log('父页面向子iframe页面发送滚动高度: ', event.data);
let dom = document.getElementsByClassName('ant-modal-wrap'); let dom = document.getElementsByClassName('ant-modal-wrap');
if (dom && dom.length) { if (dom && dom.length) {
dom[0].style.top = height + 'px'; dom[0].style.top = height + 'px';
...@@ -19,16 +19,16 @@ window.addEventListener('message', (event) => { ...@@ -19,16 +19,16 @@ window.addEventListener('message', (event) => {
} }
if (event.data.indexOf('parentRouteInfo') > -1) { if (event.data.indexOf('parentRouteInfo') > -1) {
const info = event.data.split('-')[1]; const info = event.data.split('-')[1];
console.log('父页面告知子页面路由信息: ', info); // console.log('父页面告知子页面路由信息: ', info);
if (info && isJSON(info)) { if (info && isJSON(info)) {
localStorage.setItem('parentRouteInfo', info); localStorage.setItem('parentRouteInfo', info);
} }
} }
if (event.data.indexOf('setLocalStorage') > -1) { if (event.data.indexOf('setAuthorityLocalStorage') > -1) {
const info = event.data.split('-'); const info = event.data.split('-');
console.log('父页面告知子页面localStorage信息: ', info); // console.log('父页面告知子页面localStorage信息: antd-pro-authority');
if (info && info.length > 2) { if (info && info.length > 1) {
localStorage.setItem(info[1], info[2]); localStorage.setItem('antd-pro-authority', info[1]);
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论