|
@ -5,14 +5,18 @@ import '../styles/app.scss' |
|
|
import { useRouter } from "../hooks/useRouter"; |
|
|
import { useRouter } from "../hooks/useRouter"; |
|
|
import Slider from "../components/layout/Slider"; |
|
|
import Slider from "../components/layout/Slider"; |
|
|
import Header from "../components/layout/Header"; |
|
|
import Header from "../components/layout/Header"; |
|
|
import { useEffect, useRef } from "react"; |
|
|
|
|
|
|
|
|
import { useEffect, useRef, useState } from "react"; |
|
|
import { unLoginPath } from "./routes"; |
|
|
import { unLoginPath } from "./routes"; |
|
|
|
|
|
import { Divider, Modal } from "antd"; |
|
|
|
|
|
import { NotifyStatus_Type } from "../types"; |
|
|
|
|
|
import { http_notify } from "../http/api"; |
|
|
|
|
|
|
|
|
const LayoutRouter = () => { |
|
|
const LayoutRouter = () => { |
|
|
|
|
|
|
|
|
const { push, location } = useRouter() |
|
|
const { push, location } = useRouter() |
|
|
|
|
|
|
|
|
|
|
|
const [visible, setVisible] = useState(false) |
|
|
const { token, screenWidth } = store.state |
|
|
const { token, screenWidth } = store.state |
|
|
|
|
|
const [notifys, setNotifys] = useState([] as any) |
|
|
//
|
|
|
//
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
@ -36,45 +40,78 @@ const LayoutRouter = () => { |
|
|
} |
|
|
} |
|
|
}, [location.pathname, token]) |
|
|
}, [location.pathname, token]) |
|
|
|
|
|
|
|
|
|
|
|
const isShowNotifyModal = async () => { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const res: any = await http_notify() |
|
|
|
|
|
if (res.code === 0) { |
|
|
|
|
|
console.log(res); |
|
|
|
|
|
|
|
|
|
|
|
setNotifys(res.data) |
|
|
|
|
|
const type = window.localStorage.getItem('NotifyStatus') || NotifyStatus_Type.show |
|
|
|
|
|
if (type === NotifyStatus_Type.show && res.data && res.data.length > 0) { |
|
|
|
|
|
setVisible(true) |
|
|
|
|
|
window.localStorage.setItem('NotifyStatus', NotifyStatus_Type.hidden) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
token && store.getUserInfo() |
|
|
token && store.getUserInfo() |
|
|
token && store.getReceiveAccount() |
|
|
token && store.getReceiveAccount() |
|
|
!token && store.resetUserInfo() |
|
|
!token && store.resetUserInfo() |
|
|
!token && store.resetReceiveAccount() |
|
|
!token && store.resetReceiveAccount() |
|
|
}, [token]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
window.addEventListener('message', (res) => { |
|
|
|
|
|
if (res.origin === process.env.REACT_APP_ORIGIN) { |
|
|
|
|
|
if (res && res.data && res.data.token) { |
|
|
|
|
|
store.setToken(res.data.token) |
|
|
|
|
|
if (!window.sessionStorage.getItem('first_render')) { |
|
|
|
|
|
window.location.reload() |
|
|
|
|
|
} |
|
|
|
|
|
window.sessionStorage.setItem('first_render', 'true') |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
if (token) { |
|
|
|
|
|
isShowNotifyModal() |
|
|
|
|
|
} |
|
|
|
|
|
}, [token]) |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
!token ? ( |
|
|
|
|
|
<RenderRouter /> |
|
|
|
|
|
) : ( |
|
|
|
|
|
<div className="layout"> |
|
|
|
|
|
<div className="container-header"></div> |
|
|
|
|
|
<div className="container-aplication"> |
|
|
|
|
|
|
|
|
<> |
|
|
|
|
|
{ |
|
|
|
|
|
!token ? ( |
|
|
|
|
|
<RenderRouter /> |
|
|
|
|
|
) : ( |
|
|
|
|
|
<div className="layout"> |
|
|
|
|
|
<div className="container-header"></div> |
|
|
|
|
|
<div className="container-aplication"> |
|
|
|
|
|
{ |
|
|
|
|
|
screenWidth > 1000 && <Slider /> |
|
|
|
|
|
} |
|
|
|
|
|
<div style={{ paddingLeft: screenWidth > 1000 ? 40 : 0, flex: 1 }}> |
|
|
|
|
|
<Header /> |
|
|
|
|
|
<div className="divider"></div> |
|
|
|
|
|
<RenderRouter /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
<Modal |
|
|
|
|
|
open={visible} |
|
|
|
|
|
onCancel={() => setVisible(false)} |
|
|
|
|
|
footer={() => null} |
|
|
|
|
|
width={screenWidth > 1000 ? '60%' : '90%'} |
|
|
|
|
|
title="平台公告" |
|
|
|
|
|
> |
|
|
|
|
|
<div style={{ minHeight: 300 }}> |
|
|
{ |
|
|
{ |
|
|
screenWidth > 1000 && <Slider /> |
|
|
|
|
|
|
|
|
notifys.map((item: any) => ( |
|
|
|
|
|
<div key={item.id} className="mt-2"> |
|
|
|
|
|
<div className="fz-wb-550">{item.title}</div> |
|
|
|
|
|
<div dangerouslySetInnerHTML={{ __html: item.content }} className="mt-1"></div> |
|
|
|
|
|
<Divider /> |
|
|
|
|
|
</div> |
|
|
|
|
|
)) |
|
|
} |
|
|
} |
|
|
<div style={{ paddingLeft: screenWidth > 1000 ? 40 : 0, flex: 1 }}> |
|
|
|
|
|
<Header /> |
|
|
|
|
|
<div className="divider"></div> |
|
|
|
|
|
<RenderRouter /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
</Modal> |
|
|
|
|
|
</> |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|