Browse Source

(*)顶部菜单初始加载修改

master
zmh 2 years ago
parent
commit
1036bd2cc2
  1. 10
      web/client/src/layout/components/header/contant.js
  2. 13
      web/client/src/layout/components/header/index.jsx

10
web/client/src/layout/components/header/contant.js

@ -1,6 +1,9 @@
import { isAuthorized } from '$utils' import { isAuthorized } from '$utils'
let hrUser = JSON.parse(sessionStorage.getItem('hrUser')) const userData = JSON.parse(sessionStorage.getItem('hrUser'));
export const headerItemsFun = () => {
let hrUser = userData || JSON.parse(sessionStorage.getItem('hrUser'));
if (hrUser) {
let admin = false let admin = false
hrUser && hrUser.adminHr.forEach(e => { hrUser && hrUser.adminHr.forEach(e => {
if (e.id == hrUser.id) { if (e.id == hrUser.id) {
@ -142,7 +145,6 @@ headerItems = headerItems.filter(element => {
return true; return true;
} }
}) })
return headerItems;
export { }
headerItems
} }

13
web/client/src/layout/components/header/index.jsx

@ -1,14 +1,19 @@
"use strict"; "use strict";
import React from "react"; import React, { useState, useEffect } from 'react';
import { connect } from "react-redux"; import { connect } from "react-redux";
import { SplitButtonGroup, Dropdown, Button, Nav, Avatar } from '@douyinfe/semi-ui'; import { SplitButtonGroup, Dropdown, Button, Nav, Avatar } from '@douyinfe/semi-ui';
import { IconTreeTriangleDown } from '@douyinfe/semi-icons'; import { IconTreeTriangleDown } from '@douyinfe/semi-icons';
import { headerItems } from './contant'; import { headerItemsFun } from './contant';
import "./index.less"; import "./index.less";
const Header = (props) => { const Header = (props) => {
const { dispatch, history, user, actions, socket, tochange } = props; const { dispatch, history, user, actions, socket, tochange } = props;
const [allItems, setAllItems] = useState([])
useEffect(() => {
const headerItems = headerItemsFun();
if (headerItems)
setAllItems(headerItems);
}, [user && user.authorized])
return ( return (
<> <>
<div id="top-slider"> <div id="top-slider">
@ -59,7 +64,7 @@ const Header = (props) => {
}} }}
footer={ footer={
<> <>
{headerItems.map((item, index) => { {allItems.map((item, index) => {
if (item.hasOwnProperty('items')) { if (item.hasOwnProperty('items')) {
return ( return (
<Nav.Sub <Nav.Sub

Loading…
Cancel
Save