Commit 52d05330 by zhangleyuan

Merge branch 'master' into feature/zhangleyuan/20210709/work-qrcode

parents dd2f9968 b4a6428c
...@@ -110,6 +110,7 @@ ...@@ -110,6 +110,7 @@
"start:dev1": "cross-env DEPLOY_ENV=dev node scripts/start.js", "start:dev1": "cross-env DEPLOY_ENV=dev node scripts/start.js",
"start:rc": "cross-env DEPLOY_ENV=rc node scripts/start.js", "start:rc": "cross-env DEPLOY_ENV=rc node scripts/start.js",
"start:gray": "cross-env DEPLOY_ENV=gray node scripts/start.js", "start:gray": "cross-env DEPLOY_ENV=gray node scripts/start.js",
"start:prod": "cross-env DEPLOY_ENV=prod node scripts/start.js",
"build:dev": "cross-env DEPLOY_ENV=dev node scripts/build.js", "build:dev": "cross-env DEPLOY_ENV=dev node scripts/build.js",
"build:dev1": "cross-env DEPLOY_ENV=dev node scripts/build.js", "build:dev1": "cross-env DEPLOY_ENV=dev node scripts/build.js",
"build:rc": "cross-env DEPLOY_ENV=rc node scripts/build.js", "build:rc": "cross-env DEPLOY_ENV=rc node scripts/build.js",
...@@ -143,7 +144,6 @@ ...@@ -143,7 +144,6 @@
"@types/ali-oss": "^6.0.5", "@types/ali-oss": "^6.0.5",
"@types/jquery": "^3.5.4", "@types/jquery": "^3.5.4",
"ali-oss": "^6.12.0", "ali-oss": "^6.12.0",
"react-sortable-hoc": "^1.11.0", "react-sortable-hoc": "^1.11.0"
"vconsole-webpack-plugin": "^1.5.2"
} }
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
@import './variables.less'; @import './variables.less';
@active-color: #2966FF; @active-color: #2966ff;
// 消息提示框 // 消息提示框
.ant-message { .ant-message {
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
.ant-switch-small:after { .ant-switch-small:after {
top: 0.3px; top: 0.3px;
} }
tbody .ant-switch-small {
min-width: 32px;
}
.ant-pagination { .ant-pagination {
display: inline !important; display: inline !important;
...@@ -234,7 +237,7 @@ ...@@ -234,7 +237,7 @@
} }
.ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn { .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn {
font-weight: 500!important; font-weight: 500 !important;
} }
.ant-tabs-nav .ant-tabs-tab-active { .ant-tabs-nav .ant-tabs-tab-active {
...@@ -264,7 +267,7 @@ ...@@ -264,7 +267,7 @@
position: absolute; position: absolute;
width: 30px; width: 30px;
height: 4px; height: 4px;
background: #2966FF !important; background: #2966ff !important;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
} }
...@@ -339,14 +342,14 @@ mr0 { ...@@ -339,14 +342,14 @@ mr0 {
background: #f3f6fa; background: #f3f6fa;
.ant-select-selected-icon { .ant-select-selected-icon {
color:#2966FF !important; color: #2966ff !important;
} }
} }
.ant-select-dropdown-menu-item-selected { .ant-select-dropdown-menu-item-selected {
background: none; background: none;
font-weight: 400 !important; font-weight: 400 !important;
color:#2966FF; color: #2966ff;
} }
.ant-select-open .ant-select-selection { .ant-select-open .ant-select-selection {
...@@ -444,7 +447,7 @@ mr0 { ...@@ -444,7 +447,7 @@ mr0 {
.ant-modal { .ant-modal {
.ant-input { .ant-input {
&:focus { &:focus {
border: 1px solid #2966FF !important; border: 1px solid #2966ff !important;
} }
} }
} }
...@@ -457,8 +460,8 @@ mr0 { ...@@ -457,8 +460,8 @@ mr0 {
.ant-calendar-footer-extra { .ant-calendar-footer-extra {
.ant-tag-blue { .ant-tag-blue {
background: #fff; background: #fff;
color: #2966FF; color: #2966ff;
border-color: #2966FF; border-color: #2966ff;
} }
} }
} }
...@@ -474,7 +477,7 @@ mr0 { ...@@ -474,7 +477,7 @@ mr0 {
} }
.ant-modal-confirm-info .ant-modal-confirm-body > .anticon { .ant-modal-confirm-info .ant-modal-confirm-body > .anticon {
color: #2966FF!important; color: #2966ff !important;
} }
.ant-breadcrumb > span:last-child .ant-breadcrumb-separator { .ant-breadcrumb > span:last-child .ant-breadcrumb-separator {
...@@ -502,7 +505,7 @@ mr0 { ...@@ -502,7 +505,7 @@ mr0 {
font-size: 22px !important; font-size: 22px !important;
line-height: 22px !important; line-height: 22px !important;
float: left !important; float: left !important;
color:#2966FF !important; color: #2966ff !important;
margin-right: 16px !important; margin-right: 16px !important;
&.blue { &.blue {
color: #5cbaff !important; color: #5cbaff !important;
...@@ -527,8 +530,8 @@ mr0 { ...@@ -527,8 +530,8 @@ mr0 {
float: left; float: left;
margin-right: 16px; margin-right: 16px;
} }
>.confirm-icon{ > .confirm-icon {
color: #2966FF; color: #2966ff;
} }
.ant-modal-confirm-content { .ant-modal-confirm-content {
margin-left: 38px; margin-left: 38px;
...@@ -594,9 +597,9 @@ mr0 { ...@@ -594,9 +597,9 @@ mr0 {
// background: #FAFAFA !important; // background: #FAFAFA !important;
// } // }
.ant-table-thead > tr > th{ .ant-table-thead > tr > th {
font-weight:bold !important; font-weight: bold !important;
color:#333 !important; color: #333 !important;
} }
td.ant-table-column-sort { td.ant-table-column-sort {
background: none; background: none;
...@@ -657,11 +660,11 @@ td.ant-table-column-sort { ...@@ -657,11 +660,11 @@ td.ant-table-column-sort {
border-color: @xm-color-text-select-primary !important; border-color: @xm-color-text-select-primary !important;
border: none !important; border: none !important;
&:hover { &:hover {
background-color: #2966FF !important; background-color: #2966ff !important;
opacity: 0.8 !important; opacity: 0.8 !important;
} }
&:active{ &:active {
background-color:#5C8AFF !important; background-color: #5c8aff !important;
} }
} }
...@@ -720,9 +723,9 @@ td.ant-table-column-sort { ...@@ -720,9 +723,9 @@ td.ant-table-column-sort {
border-right: 0px !important; border-right: 0px !important;
} }
.ant-input-search > .ant-input-group > .ant-input-group-addon:last-child .ant-input-search-button span{ .ant-input-search > .ant-input-group > .ant-input-group-addon:last-child .ant-input-search-button span {
color:#bfbfbf !important; color: #bfbfbf !important;
font-size:12px; font-size: 12px;
} }
.ant-modal-footer { .ant-modal-footer {
...@@ -774,4 +777,3 @@ td.ant-table-column-sort { ...@@ -774,4 +777,3 @@ td.ant-table-column-sort {
.ant-table-column-sorter { .ant-table-column-sorter {
margin-left: 8px !important; margin-left: 8px !important;
} }
...@@ -125,7 +125,7 @@ class LiveCourseList extends React.Component { ...@@ -125,7 +125,7 @@ class LiveCourseList extends React.Component {
columns = [ columns = [
{ {
title: '直播课', title: '直播课',
width: '23%',
key: 'course', key: 'course',
fixed: 'left', fixed: 'left',
dataIndex: 'courseName', dataIndex: 'courseName',
...@@ -284,6 +284,7 @@ class LiveCourseList extends React.Component { ...@@ -284,6 +284,7 @@ class LiveCourseList extends React.Component {
render: (val, item, index) => { render: (val, item, index) => {
return ( return (
<Switch <Switch
size='small'
checked={item.shelfState === 'YES'} checked={item.shelfState === 'YES'}
defaultChecked={item.shelfState === 'YES' ? true : false} defaultChecked={item.shelfState === 'YES' ? true : false}
onChange={(checked) => this.changeShelfState(index, item, checked)} onChange={(checked) => this.changeShelfState(index, item, checked)}
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
import User from '@/common/js/user'; import User from '@/common/js/user';
import college from '@/common/lottie/college'; import college from '@/common/lottie/college';
import { PageControl, XMTable } from '@/components'; import { PageControl, XMTable } from '@/components';
import { appId, LIVE_SHARE } from '@/domains/course-domain/constants'; import { LIVE_SHARE } from '@/domains/course-domain/constants';
import CourseService from '@/domains/course-domain/CourseService'; import CourseService from '@/domains/course-domain/CourseService';
import ShareLiveModal from '@/modules/course-manage/modal/ShareLiveModal'; import ShareLiveModal from '@/modules/course-manage/modal/ShareLiveModal';
import { Dropdown, message, Modal, Switch, Tooltip } from 'antd'; import { Dropdown, message, Modal, Switch, Tooltip } from 'antd';
...@@ -57,7 +57,7 @@ class GraphicsCourseList extends React.Component { ...@@ -57,7 +57,7 @@ class GraphicsCourseList extends React.Component {
handlePlanName = (planArray) => { handlePlanName = (planArray) => {
let planStr = ''; let planStr = '';
planArray.map((item, index) => { planArray.forEach((item, index) => {
if (index < planArray.length - 1) { if (index < planArray.length - 1) {
planStr = planStr + item.planName + '、'; planStr = planStr + item.planName + '、';
} else { } else {
...@@ -76,18 +76,21 @@ class GraphicsCourseList extends React.Component { ...@@ -76,18 +76,21 @@ class GraphicsCourseList extends React.Component {
width: 321, width: 321,
fixed: 'left', fixed: 'left',
render: (val, record) => { render: (val, record) => {
const { coverUrl, scheduleVideoUrl } = record; const { coverUrl } = record;
return ( return (
<div className='record__item'> <div className='record__item'>
{/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */} {/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */}
<img className='course-cover' src={coverUrl || defaultCoverUrl} /> <img className='course-cover' src={coverUrl || defaultCoverUrl} alt='' />
{record.courseName.length > 25 ? ( <Choose>
<Tooltip title={record.courseName}> <When condition={record.courseName.length > 25}>
<Tooltip title={record.courseName}>
<div className='course-name'>{record.courseName}</div>
</Tooltip>
</When>
<Otherwise>
<div className='course-name'>{record.courseName}</div> <div className='course-name'>{record.courseName}</div>
</Tooltip> </Otherwise>
) : ( </Choose>
<div className='course-name'>{record.courseName}</div>
)}
</div> </div>
); );
}, },
...@@ -144,12 +147,14 @@ class GraphicsCourseList extends React.Component { ...@@ -144,12 +147,14 @@ class GraphicsCourseList extends React.Component {
width: 120, width: 120,
dataIndex: 'courseware', dataIndex: 'courseware',
render: (val, item, index) => { render: (val, item, index) => {
return ( return (
<Switch <Switch
checked={item.shelfState === "YES"} size='small'
defaultChecked={item.shelfState==="YES"?true:false} checked={item.shelfState === 'YES'}
onChange={(checked)=>this.changeShelfState(index,item,checked)}/> defaultChecked={item.shelfState === 'YES' ? true : false}
) onChange={(checked) => this.changeShelfState(index, item, checked)}
/>
);
}, },
}, },
{ {
...@@ -168,7 +173,7 @@ class GraphicsCourseList extends React.Component { ...@@ -168,7 +173,7 @@ class GraphicsCourseList extends React.Component {
dataIndex: 'created', dataIndex: 'created',
sorter: true, sorter: true,
render: (val) => { render: (val) => {
return formatDate('YYYY-MM-DD H:i', val); return window.formatDate('YYYY-MM-DD H:i', val);
}, },
}, },
{ {
...@@ -178,7 +183,7 @@ class GraphicsCourseList extends React.Component { ...@@ -178,7 +183,7 @@ class GraphicsCourseList extends React.Component {
dataIndex: 'updated', dataIndex: 'updated',
sorter: true, sorter: true,
render: (val) => { render: (val) => {
return formatDate('YYYY-MM-DD H:i', val); return window.formatDate('YYYY-MM-DD H:i', val);
}, },
}, },
{ {
...@@ -189,19 +194,22 @@ class GraphicsCourseList extends React.Component { ...@@ -189,19 +194,22 @@ class GraphicsCourseList extends React.Component {
render: (val, record) => { render: (val, record) => {
return ( return (
<div className='related-task'> <div className='related-task'>
{record.relatedPlanList ? ( <Choose>
<Tooltip title={this.handlePlanName(record.relatedPlanList)} placement='top' arrowPointAtCenter> <When condition={record.relatedPlanList}>
{record.relatedPlanList.map((item, index) => { <Tooltip title={this.handlePlanName(record.relatedPlanList)} placement='top' arrowPointAtCenter>
return ( {record.relatedPlanList.map((item, index) => {
<span> return (
{item.planName} {index < record.relatedPlanList.length - 1 && <span></span>}{' '} <span>
</span> {item.planName} {index < record.relatedPlanList.length - 1 && <span></span>}{' '}
); </span>
})} );
</Tooltip> })}
) : ( </Tooltip>
<span></span> </When>
)} <Otherwise>
<span></span>
</Otherwise>
</Choose>
</div> </div>
); );
}, },
...@@ -297,7 +305,7 @@ class GraphicsCourseList extends React.Component { ...@@ -297,7 +305,7 @@ class GraphicsCourseList extends React.Component {
className='operate__item' className='operate__item'
key='edit' key='edit'
onClick={() => { onClick={() => {
RCHistory.push(`/create-graphics-course?type=edit&id=${item.id}`); window.RCHistory.push(`/create-graphics-course?type=edit&id=${item.id}`);
}}> }}>
编辑 编辑
</div> </div>
...@@ -305,17 +313,17 @@ class GraphicsCourseList extends React.Component { ...@@ -305,17 +313,17 @@ class GraphicsCourseList extends React.Component {
删除 删除
</div> </div>
</div> </div>
) );
} };
//改变上架状态 //改变上架状态
changeShelfState = (index,item,checked) =>{ changeShelfState = (index, item, checked) => {
let _shelfState = checked ? "YES" : "NO" let _shelfState = checked ? 'YES' : 'NO';
// if(_shelfState==='NO'){ // if(_shelfState==='NO'){
// _shelfState = "YES"; // _shelfState = "YES";
// }else{ // }else{
// _shelfState = "NO" // _shelfState = "NO"
// } // }
const params={ const params = {
courseId: item.id, courseId: item.id,
shelfState: _shelfState, shelfState: _shelfState,
}; };
...@@ -326,7 +334,7 @@ class GraphicsCourseList extends React.Component { ...@@ -326,7 +334,7 @@ class GraphicsCourseList extends React.Component {
} else { } else {
message.success('已取消展示'); message.success('已取消展示');
} }
this.props.changeShelfState(index,_shelfState) this.props.changeShelfState(index, _shelfState);
} }
}); });
}; };
...@@ -355,8 +363,6 @@ class GraphicsCourseList extends React.Component { ...@@ -355,8 +363,6 @@ class GraphicsCourseList extends React.Component {
// 显示分享弹窗 // 显示分享弹窗
handleShowShareModal = (record, needStr = false) => { handleShowShareModal = (record, needStr = false) => {
const { id, scheduleVideoUrl } = record; const { id, scheduleVideoUrl } = record;
const _appId = appId;
const htmlUrl = `${LIVE_SHARE}graphics_detail/${id}?id=${User.getStoreId()}`; const htmlUrl = `${LIVE_SHARE}graphics_detail/${id}?id=${User.getStoreId()}`;
const longUrl = htmlUrl; const longUrl = htmlUrl;
const { coverUrl, courseName } = record; const { coverUrl, courseName } = record;
......
...@@ -17,6 +17,7 @@ import OfflineCourseData from '@/modules/course-manage/offline-course/OfflineCou ...@@ -17,6 +17,7 @@ import OfflineCourseData from '@/modules/course-manage/offline-course/OfflineCou
import { Dropdown, message, Modal, Switch, Tooltip } from 'antd'; import { Dropdown, message, Modal, Switch, Tooltip } from 'antd';
import moment from 'moment'; import moment from 'moment';
import React from 'react'; import React from 'react';
import { find, reduce, last } from 'underscore';
import { Route, withRouter } from 'react-router-dom'; import { Route, withRouter } from 'react-router-dom';
import ENUM from '../../../knowledge-base/ENUM.js'; import ENUM from '../../../knowledge-base/ENUM.js';
import PreviewOfflineModal from '../modal/PreviewOfflineModal'; import PreviewOfflineModal from '../modal/PreviewOfflineModal';
...@@ -44,7 +45,7 @@ class OfflineCourseList extends React.Component { ...@@ -44,7 +45,7 @@ class OfflineCourseList extends React.Component {
handlePlanName = (planArray) => { handlePlanName = (planArray) => {
let planStr = ''; let planStr = '';
planArray.map((item, index) => { planArray.forEach((item, index) => {
if (index < planArray.length - 1) { if (index < planArray.length - 1) {
planStr = planStr + item.planName + '、'; planStr = planStr + item.planName + '、';
} else { } else {
...@@ -64,13 +65,13 @@ class OfflineCourseList extends React.Component { ...@@ -64,13 +65,13 @@ class OfflineCourseList extends React.Component {
fixed: 'left', fixed: 'left',
render: (val, record) => { render: (val, record) => {
const { courseMediaVOS, courseName, offlinePlace, calendarTime, startTime, endTime } = record; const { courseMediaVOS, courseName, offlinePlace, calendarTime, startTime, endTime } = record;
const coverUrl = (_.find(courseMediaVOS, (data) => data.contentType === 'COVER') || {}).mediaUrl; const coverUrl = (find(courseMediaVOS, (data) => data.contentType === 'COVER') || {}).mediaUrl;
let isContinue = calendarTime.length > 1; let isContinue = calendarTime.length > 1;
_.reduce(calendarTime, (a, b) => { reduce(calendarTime, (a, b) => {
isContinue = isContinue && b - a === 86400000; isContinue = isContinue && b - a === 86400000;
return b; return b;
}); });
const lastTime = _.last(calendarTime); const lastTime = last(calendarTime);
const time = `${ const time = `${
!isContinue !isContinue
? calendarTime.map((item) => moment(item).format('MM-DD')).join('、') ? calendarTime.map((item) => moment(item).format('MM-DD')).join('、')
...@@ -138,7 +139,9 @@ class OfflineCourseList extends React.Component { ...@@ -138,7 +139,9 @@ class OfflineCourseList extends React.Component {
width: 120, width: 120,
dataIndex: 'courseware', dataIndex: 'courseware',
render: (val, item, index) => { render: (val, item, index) => {
return <Switch disabled={item.courseState === 'EXPIRED'} checked={item.shelfState === 'YES'} onChange={() => this.changeShelfState(item)} />; return (
<Switch size='small' disabled={item.courseState === 'EXPIRED'} checked={item.shelfState === 'YES'} onChange={() => this.changeShelfState(item)} />
);
}, },
}, },
{ {
......
...@@ -159,6 +159,7 @@ class VideoCourseList extends React.Component { ...@@ -159,6 +159,7 @@ class VideoCourseList extends React.Component {
render: (val, item, index) => { render: (val, item, index) => {
return ( return (
<Switch <Switch
size='small'
loading={ShelfLoading} loading={ShelfLoading}
checked={item.shelfState === 'YES'} checked={item.shelfState === 'YES'}
defaultChecked={item.shelfState} defaultChecked={item.shelfState}
......
...@@ -7,17 +7,16 @@ ...@@ -7,17 +7,16 @@
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import React from 'react'; import React from 'react';
import { Button, Input, Switch, Radio, Row, Col, Modal, message, Tooltip } from 'antd'; import { Button, Input, Switch, Radio, Row, Col, message, Tooltip } from 'antd';
import { withRouter } from 'react-router-dom'; import { withRouter } from 'react-router-dom';
import SelectOperatorModal from '../modal/SelectOperatorModal'; import SelectOperatorModal from '../modal/SelectOperatorModal';
import SelectPrepareFileModal from '@/modules/prepare-lesson/modal/SelectPrepareFileModal'; import SelectPrepareFileModal from '@/modules/prepare-lesson/modal/SelectPrepareFileModal';
import Upload from '@/core/upload'; import Upload from '@/core/upload';
import ImgClipModal from '@/components/ImgClipModal' import ImgClipModal from '@/components/ImgClipModal';
import './BasicInfo.less'; import './BasicInfo.less';
const { TextArea } = Input; const { TextArea } = Input;
const defaultCover = 'https://image.xiaomaiketang.com/xm/rEAetaTEh3.png'; const defaultCover = 'https://image.xiaomaiketang.com/xm/rEAetaTEh3.png';
let cutFlag = false;
class BasicInfo extends React.Component { class BasicInfo extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -74,7 +73,7 @@ class BasicInfo extends React.Component { ...@@ -74,7 +73,7 @@ class BasicInfo extends React.Component {
handleSelectCover = (file) => { handleSelectCover = (file) => {
this.setState({ this.setState({
visible: true, visible: true,
imageFile:file imageFile: file,
}); });
}; };
//获取resourceId //获取resourceId
...@@ -125,7 +124,7 @@ class BasicInfo extends React.Component { ...@@ -125,7 +124,7 @@ class BasicInfo extends React.Component {
}; };
render() { render() {
const { operatorModalVisible, showSelectFileModal, visible, hasImgReady, cutImageBlob,imageFile} = this.state; const { operatorModalVisible, showSelectFileModal, visible, imageFile } = this.state;
const { data } = this.props; const { data } = this.props;
const { planName, coverUrl, instro, enableState, operateType, selectOperatorList, percentCompleteLive, percentCompleteVideo, percentCompletePicture } = const { planName, coverUrl, instro, enableState, operateType, selectOperatorList, percentCompleteLive, percentCompleteVideo, percentCompletePicture } =
data; data;
...@@ -325,9 +324,16 @@ class BasicInfo extends React.Component { ...@@ -325,9 +324,16 @@ class BasicInfo extends React.Component {
onSelect={this.handleSelectCover} onSelect={this.handleSelectCover}
/> />
)} )}
{ visible && {visible && (
<ImgClipModal visible={visible} imgUrl={imageFile.ossUrl} onConfirm={this.getSignature} onClose={()=>{this.setState({ visible: false });}}/> <ImgClipModal
} visible={visible}
imgUrl={imageFile.ossUrl}
onConfirm={this.getSignature}
onClose={() => {
this.setState({ visible: false });
}}
/>
)}
</div> </div>
); );
} }
......
...@@ -64,6 +64,7 @@ function PlanList(props) { ...@@ -64,6 +64,7 @@ function PlanList(props) {
render: (val, item, index) => { render: (val, item, index) => {
return ( return (
<Switch <Switch
size='small'
checked={item.enableState === 'NO' ? false : true} checked={item.enableState === 'NO' ? false : true}
onChange={() => changeEnableState(item)} onChange={() => changeEnableState(item)}
disabled={User.getUserRole() === 'CloudManager' || User.getUserRole() === 'StoreManager' ? false : true} disabled={User.getUserRole() === 'CloudManager' || User.getUserRole() === 'StoreManager' ? false : true}
......
...@@ -3,108 +3,86 @@ ...@@ -3,108 +3,86 @@
* @Date: 2020-04-28 18:05:30 * @Date: 2020-04-28 18:05:30
* @LastEditors: wufan * @LastEditors: wufan
* @LastEditTime: 2020-12-26 14:37:23 * @LastEditTime: 2020-12-26 14:37:23
* @Description: * @Description:
*/ */
import mainRoutes from './config/mainRoutes'; import mainRoutes from './config/mainRoutes';
import redirectRoutes from './config/redirectRoutes'; import redirectRoutes from './config/redirectRoutes';
import React from 'react' import React from 'react';
import { Redirect,HashRouter as Router,Route ,Switch} from 'react-router-dom'; import { HashRouter as Router, Route, Switch } from 'react-router-dom';
import { createHashHistory } from 'history'; import { createHashHistory } from 'history';
import App from '../modules/root/App';
import AppContext from '@/modules/root/AppContent'; import AppContext from '@/modules/root/AppContent';
import Login from '../modules/root/Login'; import Login from '../modules/root/Login';
import CollegeManagePage from '../modules/root/CollegeManagePage'; import CollegeManagePage from '../modules/root/CollegeManagePage';
import CreateCollege from '../modules/root/CreateCollege'; import CreateCollege from '../modules/root/CreateCollege';
import _ from 'underscore'; import _ from 'underscore';
import { asyncComponent } from 'react-async-component'
import SwitchRoute from '@/modules/root/SwitchRoute'; import SwitchRoute from '@/modules/root/SwitchRoute';
import ErrorCollege from '@/modules/root/ErrorCollege'; import ErrorCollege from '@/modules/root/ErrorCollege';
const history = createHashHistory(); const history = createHashHistory();
window.RCHistory = _.extend({}, history, { window.RCHistory = _.extend({}, history, {
push: (obj: any) => { push: (obj: any) => {
history.push(obj) history.push(obj);
}, },
pushState: (obj: any) => { pushState: (obj: any) => {
history.push(obj) history.push(obj);
}, },
pushStateWithStatus: (obj: any) => { pushStateWithStatus: (obj: any) => {
history.push(obj) history.push(obj);
}, },
goBack: history.goBack, goBack: history.goBack,
location: history.location, location: history.location,
replace: (obj: any) => { replace: (obj: any) => {
history.replace(obj) history.replace(obj);
} },
}); });
const cache:any = {
path: '',
component: null
}
function dynamic (component:any) {
const resolveComponent = component
return asyncComponent({
resolve: () => {
const ts = resolveComponent()
return ts
},
})
}
export const RootRouter = () => { export const RootRouter = () => {
return ( return (
<Router {...history}> <Router {...history}>
<Switch> <Switch>
<Route key="1" exact path="/login" render={() => <Login />} /> <Route key='1' exact path='/login' render={() => <Login />} />
<Route key="2" exact path="/switch-route" render={() => <SwitchRoute />} /> <Route key='2' exact path='/switch-route' render={() => <SwitchRoute />} />
<Route key="3" exact path="/college-manage" render={() => <CollegeManagePage />} /> <Route key='3' exact path='/college-manage' render={() => <CollegeManagePage />} />
<Route key="4" exact path="/college-manage/create" render={() => <CreateCollege />} /> <Route key='4' exact path='/college-manage/create' render={() => <CreateCollege />} />
<Route key="6" exact path="/error-college" render={() => <ErrorCollege />} /> <Route key='6' exact path='/error-college' render={() => <ErrorCollege />} />
<Route key="5" path="/" render={() => <AppContext />} /> <Route key='5' path='/' render={() => <AppContext />} />
</Switch> </Switch>
</Router> </Router>
) );
} };
export const MainRoutes = () => { export const MainRoutes = () => {
return ( return (
<Switch> <Switch>
{ {_.map(mainRoutes, ({ path, component }, key) => {
_.map(mainRoutes, ({ return (
path, <Route
component, key={key}
}, key) => { path={path}
return <Route render={() => {
key={key} const Component = component;
path={path} return <Component />;
render={() => { }}
const Component = component; />
return <Component /> );
}} })}
/> </Switch>
}) );
} };
</Switch>
)
}
export const RedirectRoutes = () => { export const RedirectRoutes = () => {
return ( return (
<Switch> <Switch>
{ {_.map(redirectRoutes, ({ path, component }, key) => {
_.map(redirectRoutes, ({ return (
path, <Route
component, key={key}
}, key) => { path={path}
return <Route render={() => {
key={key} const Component = component;
path={path} return <Component />;
render={() => { }}
const Component = component; />
return <Component /> );
}} })}
/> </Switch>
}) );
} };
</Switch>
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment