| 29 | ); |
| 30 | |
| 31 | const BasicLayout = props => { |
| 32 | const { |
| 33 | children, |
| 34 | settings, |
| 35 | location = { |
| 36 | pathname: '/', |
| 37 | }, |
| 38 | } = props; |
| 39 | const userRole = localStorage.getItem('userRole')||'user'; |
| 40 | const changeBackground = () => { |
| 41 | // 根据鼠标移动改变图片 |
| 42 | let startingPoint = null |
| 43 | const snowContainer = document.getElementById('snow-container') |
| 44 | const header = document.getElementById('index-header') |
| 45 | const headerEnterListener = new WeakMap() // WeakMap类型 不计入垃圾回收机制 |
| 46 | headerEnterListener.set(header, (e) => { |
| 47 | startingPoint = e.clientX |
| 48 | header.classList.add('moving') |
| 49 | }) |
| 50 | header.addEventListener('mouseenter', headerEnterListener.get(header), false) |
| 51 | |
| 52 | const headerOutListener = new WeakMap() // WeakMap类型 不计入垃圾回收机制 |
| 53 | headerOutListener.set(header, (e) => { |
| 54 | header.classList.remove('moving') |
| 55 | header.style.setProperty('--percentage', 1) |
| 56 | snowContainer.style.visibility = 'inherit' |
| 57 | }) |
| 58 | header.addEventListener('mouseout', headerOutListener.get(header), false) |
| 59 | |
| 60 | const headerMoveListener = new WeakMap() // WeakMap类型 不计入垃圾回收机制 |
| 61 | headerMoveListener.set(header, (e) => { |
| 62 | const percentage = (e.clientX - startingPoint) / window.outerWidth + 1 |
| 63 | if (percentage < 0.5) { |
| 64 | snowContainer.style.visibility = 'hidden' |
| 65 | } else { |
| 66 | snowContainer.style.visibility = 'inherit' |
| 67 | } |
| 68 | header.style.setProperty('--percentage', percentage) |
| 69 | }) |
| 70 | header.addEventListener('mousemove', headerMoveListener.get(header), false) |
| 71 | |
| 72 | } |
| 73 | useEffect(() => { |
| 74 | changeBackground() |
| 75 | }, []) |
| 76 | |
| 77 | const authorized = getAuthorityFromRouter(props.route.routes, location.pathname || '/') || { |
| 78 | authority: undefined, |
| 79 | }; |
| 80 | return ( |
| 81 | <React.Fragment> |
| 82 | <div className="index-header" id="index-header"> |
| 83 | <div className="snow-container" id="snow-container"> |
| 84 | <div className="snow middleground" /> |
| 85 | <div className="snow middleground layered" /> |
| 86 | <div className="snow background" /> |
| 87 | <div className="snow background layered" /> |
| 88 | </div> |
nothing calls this directly
no test coverage detected