forked from Gitlink/forgeplus-react
上传路由修改示例代码
This commit is contained in:
parent
4b4ac537c0
commit
018244c368
|
@ -377,7 +377,7 @@ class App extends Component {
|
|||
{/*专家评审*/}
|
||||
<Route path="/expert" component={Expert} />
|
||||
{/*启智2022*/}
|
||||
<Route path="/competition" component={Competition} />
|
||||
<Route path="/competition/:competitionId" component={Competition} />
|
||||
|
||||
<Route exact path="/explore/all"
|
||||
render={
|
||||
|
|
|
@ -13,10 +13,10 @@ export function getImageUrl(path) {
|
|||
// const local = 'http://localhost:3000'
|
||||
// const local = 'http://39.105.176.215:49999';
|
||||
const local = 'http://111.8.36.180:8000';
|
||||
if (isDev) {
|
||||
return `${local}/${path}`
|
||||
}
|
||||
path && !path.startsWith('/') && (path = '/'.concat(path));
|
||||
if (isDev) {
|
||||
return `${local}${path}`
|
||||
}
|
||||
return `${path}`;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ const Management = Loadable({
|
|||
})
|
||||
|
||||
const Qz2022 = (props) => {
|
||||
const { history, current_user } = props;
|
||||
const { history, current_user,match } = props;
|
||||
const { location } = history;
|
||||
const { pathname } = location;
|
||||
const [active, setActive] = useState();
|
||||
|
@ -77,6 +77,8 @@ const Qz2022 = (props) => {
|
|||
|
||||
const [fixedTop, setFixedTop] = useState('');
|
||||
|
||||
const {competitionId}=match.params;
|
||||
|
||||
const menu = (
|
||||
<Menu>
|
||||
<Menu.Item>
|
||||
|
@ -123,8 +125,8 @@ const Qz2022 = (props) => {
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
// 获取启智2022详情
|
||||
getQz2022().then(response => {
|
||||
// 获取竞赛详情
|
||||
getQz2022(competitionId).then(response => {
|
||||
if (response && response.status === 200) {
|
||||
setQzDetail(response.data.data);
|
||||
}
|
||||
|
@ -133,7 +135,7 @@ const Qz2022 = (props) => {
|
|||
|
||||
useEffect(() => {
|
||||
// 获取用户参与竞赛状态
|
||||
userCompetitionStatus('qz2022').then(response => {
|
||||
userCompetitionStatus(competitionId).then(response => {
|
||||
if (response && response.status === 200) {
|
||||
setEnrollStatus(response.data.data);
|
||||
}
|
||||
|
@ -176,35 +178,35 @@ const Qz2022 = (props) => {
|
|||
<a href="/"><img src={logo} alt="" style={{ width: 120 }} /></a>
|
||||
</li>
|
||||
<li className={active === 'qz2022' || active === "introduce" ? "active" : ""}>
|
||||
<Link to={{ pathname: `/competition/qz2022/introduce` }}>首页</Link>
|
||||
<Link to={{ pathname: `/competition/${competitionId}/introduce` }}>首页</Link>
|
||||
</li>
|
||||
<li className={active === "fingerpost" ? "active" : ""}>
|
||||
<Link to={{ pathname: `/competition/qz2022/fingerpost` }}>赛事指南</Link>
|
||||
<Link to={{ pathname: `/competition/${competitionId}/fingerpost` }}>赛事指南</Link>
|
||||
</li>
|
||||
<li className={active === "notice" ? "active" : ""}>
|
||||
<Link to={{ pathname: `/competition/qz2022/notice` }}>通知公告</Link>
|
||||
<Link to={{ pathname: `/competition/${competitionId}/notice` }}>通知公告</Link>
|
||||
</li>
|
||||
{/* 处于报名阶段正常跳转到报名页面,不处于右侧弹消息 */}
|
||||
<li className={active === "apply" ? "active" : ""}>
|
||||
<Link to={{ pathname: applyStatus && current_user && current_user.login ? '/competition/qz2022/apply' : '' }} onClick={() => { current_user && current_user.login ? !applyStatus && props.showNotification("报名时间已截止") : props.showLoginDialog() }}>参赛报名</Link>
|
||||
<Link to={{ pathname: applyStatus && current_user && current_user.login ? `/competition/${competitionId}/apply` : '' }} onClick={() => { current_user && current_user.login ? !applyStatus && props.showNotification("报名时间已截止") : props.showLoginDialog() }}>参赛报名</Link>
|
||||
</li>
|
||||
<li className={active === "refer" ? "active" : ""}>
|
||||
<Link to={{ pathname: referStatus && !referEnd && current_user && current_user.login && enrollStatus && enrollStatus.enroll_status ? `/competition/qz2022/refer` : '' }} onClick={goToRefer}>提案提交</Link>
|
||||
<Link to={{ pathname: referStatus && !referEnd && current_user && current_user.login && enrollStatus && enrollStatus.enroll_status ? `/competition/${competitionId}/refer` : '' }} onClick={goToRefer}>提案提交</Link>
|
||||
</li>
|
||||
{/* <li className={active === "apply" ? "active" : ""}>
|
||||
<Link to={{ pathname: '/competition/qz2022/apply'}}>参赛报名</Link>
|
||||
<Link to={{ pathname: `/competition/${competitionId}/apply`}}>参赛报名</Link>
|
||||
</li> */}
|
||||
{/* <li className={active === "refer" ? "active" : ""}>
|
||||
<Link to={{ pathname: `/competition/qz2022/refer`}}>提案提交</Link>
|
||||
<Link to={{ pathname: `/competition/${competitionId}/refer`}}>提案提交</Link>
|
||||
</li> */}
|
||||
<li className={active === "statistics" ? "active" : ""}>
|
||||
<Link to={{ pathname: `/competition/qz2022/statistics` }}>数据统计</Link>
|
||||
<Link to={{ pathname: `/competition/${competitionId}/statistics` }}>数据统计</Link>
|
||||
</li>
|
||||
<li className={active === "chat" ? "active" : ""}>
|
||||
<Link to={{ pathname: `/competition/qz2022/chat` }}>交流互动</Link>
|
||||
<Link to={{ pathname: `/competition/${competitionId}/chat` }}>交流互动</Link>
|
||||
</li>
|
||||
<li className={active === "contact" ? "active" : ""}>
|
||||
<Link to={{ pathname: `/competition/qz2022/contact` }}>联系我们</Link>
|
||||
<Link to={{ pathname: `/competition/${competitionId}/contact` }}>联系我们</Link>
|
||||
</li>
|
||||
{qzDetail && qzDetail.is_manager && <li className={(active === "applys" || active === "production") ? "active" : ""}>
|
||||
<Popover content={menu} placement="bottomRight" overlayClassName="qz_manage">
|
||||
|
@ -217,91 +219,91 @@ const Qz2022 = (props) => {
|
|||
<Spin spinning={false} wrapperClassName="spinstyle qzCont" tip="正在同步镜像" size="large">
|
||||
<Switch {...props}>
|
||||
{/* 通知公告详情页 */}
|
||||
<Route path="/competition/qz2022/notice/detail/:noticeId"
|
||||
<Route path="/competition/:competitionId/notice/detail/:noticeId"
|
||||
render={
|
||||
({ match, history }) => (<NoticeDetail match={match} history={history} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 通知公告编辑页 */}
|
||||
<Route path="/competition/qz2022/notice/:type/:noticeId"
|
||||
<Route path="/competition/:competitionId/notice/:type/:noticeId"
|
||||
render={
|
||||
({ match }) => (<NoticeEdit {...props} match={match} qzDetail={qzDetail} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 通知公告新增页 */}
|
||||
<Route path="/competition/qz2022/notice/:type"
|
||||
<Route path="/competition/:competitionId/notice/:type"
|
||||
render={
|
||||
({ match }) => (<NoticeEdit {...props} match={match} qzDetail={qzDetail} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 大赛介绍、大赛指南、关于我们 编辑页 */}
|
||||
<Route path="/competition/qz2022/:type/edit"
|
||||
<Route path="/competition/:competitionId/:type/edit"
|
||||
render={
|
||||
({ match }) => (<ManageEdit {...props} qzDetail={qzDetail} match={match} setReloadDetail={setReloadDetail} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 通知公告 */}
|
||||
<Route path="/competition/qz2022/notice"
|
||||
<Route path="/competition/:competitionId/notice"
|
||||
render={
|
||||
() => (<Notice {...props} qzDetail={qzDetail} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 参赛报名 */}
|
||||
<Route path="/competition/qz2022/apply"
|
||||
<Route path="/competition/:competitionId/apply"
|
||||
render={
|
||||
() => (<Apply {...props} qzDetail={qzDetail} enrollStatus={enrollStatus} setReload={setReload} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 提案提交 */}
|
||||
<Route path="/competition/qz2022/refer"
|
||||
<Route path="/competition/:competitionId/refer"
|
||||
render={
|
||||
() => (<Refer {...props} enrollStatus={enrollStatus} qzDetail={qzDetail} setReload={setReload} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 交流互动 */}
|
||||
<Route path="/competition/qz2022/chat"
|
||||
<Route path="/competition/:competitionId/chat"
|
||||
render={
|
||||
() => (<Chat {...props} isLoacl={qzDetail && qzDetail.is_local} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 联系我们 */}
|
||||
<Route path="/competition/qz2022/contact"
|
||||
<Route path="/competition/:competitionId/contact"
|
||||
render={
|
||||
() => (<Contact {...props} aboutUs={qzDetail && qzDetail.about_us} qzDetail={qzDetail} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 数据统计 */}
|
||||
<Route path="/competition/qz2022/statistics"
|
||||
<Route path="/competition/:competitionId/statistics"
|
||||
render={
|
||||
() => (<Statistics {...props} qzDetail={qzDetail} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 后台管理-报名列表 */}
|
||||
<Route path="/competition/qz2022/management/applys"
|
||||
<Route path="/competition/:competitionId/management/applys"
|
||||
render={
|
||||
() => (<Management {...props} qzDetail={qzDetail} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 后台管理-作品列表 */}
|
||||
<Route path="/competition/qz2022/management/production"
|
||||
<Route path="/competition/:competitionId/management/production"
|
||||
render={
|
||||
() => (<Management {...props} qzDetail={qzDetail} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 大赛介绍 */}
|
||||
<Route path="/competition/qz2022/introduce"
|
||||
<Route path="/competition/:competitionId/introduce"
|
||||
render={
|
||||
() => (<Introduce {...props} qzDetail={qzDetail} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 大赛指南 */}
|
||||
<Route path="/competition/qz2022/fingerpost"
|
||||
<Route path="/competition/:competitionId/fingerpost"
|
||||
render={
|
||||
() => (<Fingerpost {...props} qzDetail={qzDetail} />)
|
||||
}
|
||||
></Route>
|
||||
{/* 大赛介绍 */}
|
||||
<Route path="/competition/qz2022"
|
||||
<Route path="/competition/:competitionId"
|
||||
render={
|
||||
() => (<Introduce {...props} qzDetail={qzDetail} />)
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ export async function userCompetitionStatus(id) {
|
|||
}
|
||||
|
||||
// 启智2022详情接口
|
||||
export function getQz2022() {
|
||||
return axios.get(`/competition_infos/qz2022.json`);
|
||||
export function getQz2022(competitionId) {
|
||||
return axios.get(`/competition_infos/${competitionId}.json`);
|
||||
}
|
||||
|
||||
// 报名启智2022 竞赛?debug=teacher
|
||||
|
|
Loading…
Reference in New Issue