fix(): 修复首页因权限设置时,不展示等问题
parent
1322a6cdfa
commit
a6e81a114e
|
|
@ -21,6 +21,29 @@ export const fileDownload = (url,params) => {
|
|||
// 模拟点击事件,开始下载
|
||||
downloadLink.click();
|
||||
}
|
||||
|
||||
export function getMenuUrl(menuItem){
|
||||
if (!menuItem) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const url = menuItem.path;
|
||||
if (url) {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (menuItem.children && menuItem.children.length) {
|
||||
for (const m of menuItem.children) {
|
||||
const url = getMenuUrl(m);
|
||||
|
||||
if (url) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 对象类型
|
||||
* @param {object} obj
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import HFivePlayer from '../../components/video1Plary';
|
|||
import moment from 'moment';
|
||||
import { loadMenu, loadRole } from '../../models/auth/_'
|
||||
import { gateMarkersConfig } from './gateMarkersConfig'
|
||||
|
||||
import { getMenuUrl } from '../../utils/tools';
|
||||
// 闸门标注组件
|
||||
const GateMarker = ({ gateInfo, position, onClick }) => {
|
||||
const getStatusColor = (status) => {
|
||||
|
|
@ -60,28 +60,7 @@ const MenuTitleCard = ({ key, title }) => {
|
|||
</div>
|
||||
)
|
||||
}
|
||||
function getMenuUrl(menuItem){
|
||||
if (!menuItem) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const url = menuItem.path;
|
||||
if (url) {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (menuItem.children && menuItem.children.length) {
|
||||
for (const m of menuItem.children) {
|
||||
const url = getMenuUrl(m);
|
||||
|
||||
if (url) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
export default function Home() {
|
||||
const menu = useSelector((state) => state.auth.menu);
|
||||
const [title, setTitle] = useState([])
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ import PicAuthCode from './PicAuthCode'
|
|||
import { httppost2 } from "../../utils/request";
|
||||
import apiurl from '../../service/apiurl';
|
||||
import { login, info, router } from './http'
|
||||
import { loadMenu, loadRole } from '../../models/auth/_'
|
||||
import { getMenuUrl } from '../../utils/tools';
|
||||
|
||||
// 引入md5加密
|
||||
// import md5 from 'js-md5';
|
||||
|
||||
|
|
@ -71,7 +74,7 @@ const LoginPage = () => {
|
|||
message.error((result?.description)?.replace('参数错误',''));
|
||||
}
|
||||
}
|
||||
const getInfo = (result1: any, value: any) => {
|
||||
const getInfo = async (result1: any, value: any) => {
|
||||
if (result1?.code === 200) {
|
||||
if(checked){
|
||||
localStorage.setItem('loginNamePwd',JSON.stringify(value))
|
||||
|
|
@ -82,8 +85,15 @@ const LoginPage = () => {
|
|||
}
|
||||
localStorage.setItem('userName', result1.user.nickName);
|
||||
localStorage.setItem('userId', result1.user.userId);
|
||||
|
||||
navigate('/home');
|
||||
let menuData = await loadMenu();
|
||||
if (menuData && menuData.length > 0) {
|
||||
const url = getMenuUrl(menuData[0]);
|
||||
if (url) {
|
||||
navigate(url);
|
||||
}
|
||||
} else {
|
||||
navigate('/home');
|
||||
}
|
||||
}else{
|
||||
message.error('获取用户信息失败');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue