import React, { Component } from 'react'; import './public-path'; import { ConfigProvider } from 'antd' import zhCN from 'antd/lib/locale-provider/zh_CN'; import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; import axios from 'axios'; import LoginDialog from './modules/login/LoginDialog'; import Notcompletedysl from './modules/user/Notcompletedysl'; import Trialapplicationysl from './modules/login/Trialapplicationysl'; import Trialapplicationreview from './modules/user/Trialapplicationreview'; import Addcourses from "./modules/courses/coursesPublic/Addcourses"; import AccountProfile from "./modules/user/AccountProfile"; import Accountnewprofile from './modules/user/Accountnewprofile'; import Certifiedprofessional from './modules/modals/Certifiedprofessional'; import Loading from './Loading' import { Loadable } from 'educoder'; import moment from 'moment' import history from './history'; import { SnackbarHOC } from 'educoder' import { initAxiosInterceptors } from './AppConfig' import { Provider } from 'react-redux'; import configureStore from './redux/stores/configureStore'; const store = configureStore(); //登入 const EducoderLogin = Loadable({ loader: () => import('./modules/login/EducoderLogin'), loading: Loading, }) //微信登录 const Otherlogin = Loadable({ loader: () => import('./modules/login/Otherlogin'), loading: Loading, }) //微信登录 const Loginqq = Loadable({ loader: () => import('./modules/login/Loginqq'), loading: Loading, }) const Otherloginstart = Loadable({ loader: () => import('./modules/login/Otherloginstart'), loading: Loading, }) const Otherloginsqq = Loadable({ loader: () => import('./modules/login/Otherloginqq'), loading: Loading, }) const IndexWrapperComponent = Loadable({ loader: () => import('./modules/page/IndexWrapper'), loading: Loading, }) const CommentComponent = Loadable({ loader: () => import('./modules/comment/CommentContainer'), loading: Loading, }) const TPMIndexComponent = Loadable({ loader: () => import('./modules/tpm/TPMIndex'), loading: Loading, }) const TPMShixunsIndexComponent = Loadable({ loader: () => import('./modules/tpm/shixuns/ShixunsIndex'), loading: Loading, }) //实训课程(原实训路径) const ShixunPaths = Loadable({ loader: () => import('./modules/paths/Index'), loading: Loading, }) //在线课堂 const CoursesIndex = Loadable({ loader: () => import('./modules/courses/Index'), loading: Loading, }) const SearchPage = Loadable({ loader: () => import('./search/SearchPage'), loading: Loading, }) const ForumsIndexComponent = Loadable({ loader: () => import('./modules/forums/ForumsIndex'), loading: Loading, }) //新建实训 const Newshixuns = Loadable({ loader: () => import('./modules/tpm/newshixuns/Newshixuns'), loading: Loading, }) //实训首页 const ShixunsHome = Loadable({ loader: () => import('./modules/home/shixunsHome'), loading: Loading, }) const CompatibilityPageLoadable = Loadable({ loader: () => import('./modules/common/CompatibilityPage'), loading: Loading, }) //403页面 const Shixunauthority = Loadable({ loader: () => import('./modules/403/Shixunauthority'), loading: Loading, }) //404页面 const Shixunnopage = Loadable({ loader: () => import('./modules/404/Shixunnopage'), loading: Loading, }) //500页面 const http500 = Loadable({ loader: () => import('./modules/500/http500'), loading: Loading, }) const AccountPage = Loadable({ loader: () => import('./modules/user/AccountPage'), loading: Loading, }) const InfosIndex = Loadable({ loader: () => import('./modules/user/usersInfo/InfosIndex'), loading: Loading, }) // 题库 const BanksIndex = Loadable({ loader: () => import('./modules/user/usersInfo/banks/BanksIndex'), loading: Loading, }) // 教学案例 const MoopCases = Loadable({ loader: () => import('./modules/moop_cases/index'), loading: Loading, }) //竞赛 const NewCompetitions = Loadable({ loader: () => import('./modules/competitions/Competitions'), loading: Loading, }) //黑客松定制竞赛 const Osshackathon = Loadable({ loader: () => import('./modules/osshackathon/Osshackathon'), loading: Loading, }) const Messagerouting = Loadable({ loader: () => import('./modules/message/js/Messagerouting'), loading: Loading, }) const Topicbank = Loadable({ loader: () => import('./modules/topic_bank/Topic_bank'), loading: Loading, }) const Help = Loadable({ loader: () => import('./modules/help/Help'), loading: Loading, }) const Ecs = Loadable({ loader: () => import('./modules/ecs/Ecs'), loading: Loading, }) // 添加开发者社区 const Developer = Loadable({ loader: () => import('./modules/developer'), loading: Loading }) // 试题库 const Headplugselection = Loadable({ loader: () => import('./modules/question/Question'), loading: Loading }) //试题库新建 //题库编辑 const Questionitem_banks = Loadable({ loader: () => import('./modules/question/Questionitem_banks'), loading: Loading }) //试卷库 const Testpaperlibrary = Loadable({ loader: () => import('./modules/testpaper/Testpaperlibrary'), loading: Loading }) //试卷编辑 const Paperlibraryeditid = Loadable({ loader: () => import('./modules/testpaper/Paperlibraryeditid'), loading: Loading }) //试卷查看 const Paperlibraryseeid = Loadable({ loader: () => import('./modules/testpaper/Paperlibraryseeid'), loading: Loading }) //人工组卷 const Paperreview = Loadable({ loader: () => import('./modules/question/Paperreview'), loading: Loading }) //智能组卷 const Integeneration = Loadable({ loader: () => import('./modules/testpaper/Intecomponents'), loading: Loading }) // 学院统计 const College = Loadable({ loader: () => import('./college/College'), loading: Loading }) // 开发者编辑模块 const NewOrEditTask = Loadable({ loader: () => import('./modules/developer/newOrEditTask'), loading: Loading }); // 学员学习 const StudentStudy = Loadable({ loader: () => import('./modules/developer/studentStudy'), loading: Loading }); // 提交记录详情 const RecordDetail = Loadable({ loader: () => import('./modules/developer/recordDetail'), loading: Loading }); // jupyter tpi const JupyterTPI = Loadable({ loader: () => import('./modules/tpm/jupyter'), loading: Loading }); class App extends Component { constructor(props) { super(props) this.state = { Addcoursestype: false, Addcoursestypes: false, mydisplay: false, occupation: 0, mygetHelmetapi: null, } } HideAddcoursestypess = (i) => { console.log("调用了"); this.setState({ Addcoursestype: false, Addcoursestypes: false, mydisplay: true, occupation: i, }) }; hideAddcoursestypes = () => { this.setState({ Addcoursestypes: false }) }; ModalCancelsy = () => { this.setState({ mydisplay: false, }) window.location.href = "/"; }; ModalshowCancelsy = () => { this.setState({ mydisplay: true, }) }; disableVideoContextMenu = () => { window.$("body").on("mousedown", "video", function (event) { if (event.which === 3) { window.$('video').bind('contextmenu', function () { return false; }); } else { window.$('video').unbind('contextmenu'); } }); } componentDidMount() { document.title = "loading..."; this.disableVideoContextMenu(); // force an update if the URL changes history.listen(() => { this.forceUpdate() const $ = window.$ // https://www.trustie.net/issues/21919 可能会有问题 $("html").animate({ scrollTop: $('html').scrollTop() - 0 }) }); initAxiosInterceptors(this.props); this.getAppdata(); window.addEventListener('error', (event) => { const msg = `${event.type}: ${event.message}`; console.log(msg) }); } //修改登录方法 Modifyloginvalue = () => { this.setState({ isRender: false, }) }; //获取数据为空的时候 gettablogourlnull = () => { this.setState({ mygetHelmetapi: undefined }); document.title = "EduCoder"; var link = document.createElement('link'), oldLink = document.getElementById('dynamic-favicon'); link.id = 'dynamic-favicon'; link.rel = 'shortcut icon'; link.href = "/react/build/./favicon.ico"; if (oldLink) { document.head.removeChild(oldLink); } document.head.appendChild(link); }; //获取数据的时候 gettablogourldata = (response) => { document.title = response.data.setting.name; var link = document.createElement('link'), oldLink = document.getElementById('dynamic-favicon'); link.id = 'dynamic-favicon'; link.rel = 'shortcut icon'; link.href = '/' + response.data.setting.tab_logo_url; if (oldLink) { document.head.removeChild(oldLink); } document.head.appendChild(link); } //获取当前定制信息 getAppdata = () => { let url = "/setting.json"; axios.get(url).then((response) => { if (response) { if (response.data) { this.setState({ mygetHelmetapi: response.data.setting }); //存储配置到游览器 localStorage.setItem('chromesetting', JSON.stringify(response.data.setting)); localStorage.setItem('chromesettingresponse', JSON.stringify(response)); try { if (response.data.setting.tab_logo_url) { this.gettablogourldata(response); } else { this.gettablogourlnull(); } } catch (e) { this.gettablogourlnull(); } } else { this.gettablogourlnull(); } } else { this.gettablogourlnull(); } }).catch((error) => { this.gettablogourlnull(); }); }; render() { return ( this.Modifyloginvalue()}> this.HideAddcoursestypess(i)} /> {/*题库*/} { return () } }> {/*题库*/} { return () } }> {/*竞赛*/} { return () } }> {/*黑客松定制竞赛*/} { return ( ) } } /> {/*认证*/} {/*403*/} {/*404*/} { return () } } /> { return () } } /> { return () } }> { return () } }> { return () } } /> {/**/} () } /> {/* jupyter */} { return () } } /> {/**/} {/**/} () } > {/*列表页 实训项目列表*/} () } > {/*实训课程(原实训路径)*/} () } > {/*课堂*/} {/* 教学案例 */} () } /> () } > () } > () } /> () } /> { return () } } /> () } /> () } /> () } /> () } /> () } /> () } /> () } /> () } /> () } /> () } /> () } /> () } /> () } /> () } /> () } /> ); } } // moment国际化,设置为中文 moment.defineLocale('zh-cn', { months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'), monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'), weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'), weekdaysMin: '日_一_二_三_四_五_六'.split('_'), longDateFormat: { LT: 'Ah点mm分', LTS: 'Ah点m分s秒', L: 'YYYY-MM-DD', LL: 'YYYY年MMMD日', LLL: 'YYYY年MMMD日Ah点mm分', LLLL: 'YYYY年MMMD日ddddAh点mm分', l: 'YYYY-MM-DD', ll: 'YYYY年MMMD日', lll: 'YYYY年MMMD日Ah点mm分', llll: 'YYYY年MMMD日ddddAh点mm分' }, meridiemParse: /凌晨|早上|上午|中午|下午|晚上/, meridiemHour: function (hour, meridiem) { if (hour === 12) { hour = 0; } if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') { return hour; } else if (meridiem === '下午' || meridiem === '晚上') { return hour + 12; } else { // '中午' return hour >= 11 ? hour : hour + 12; } }, meridiem: function (hour, minute, isLower) { var hm = hour * 100 + minute; if (hm < 600) { return '凌晨'; } else if (hm < 900) { return '早上'; } else if (hm < 1130) { return '上午'; } else if (hm < 1230) { return '中午'; } else if (hm < 1800) { return '下午'; } else { return '晚上'; } }, calendar: { sameDay: function () { return this.minutes() === 0 ? '[今天]Ah[点整]' : '[今天]LT'; }, nextDay: function () { return this.minutes() === 0 ? '[明天]Ah[点整]' : '[明天]LT'; }, lastDay: function () { return this.minutes() === 0 ? '[昨天]Ah[点整]' : '[昨天]LT'; }, nextWeek: function () { var startOfWeek, prefix; startOfWeek = moment().startOf('week'); prefix = this.unix() - startOfWeek.unix() >= 7 * 24 * 3600 ? '[下]' : '[本]'; return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm'; }, lastWeek: function () { var startOfWeek, prefix; startOfWeek = moment().startOf('week'); prefix = this.unix() < startOfWeek.unix() ? '[上]' : '[本]'; return this.minutes() === 0 ? prefix + 'dddAh点整' : prefix + 'dddAh点mm'; }, sameElse: 'LL' }, ordinalParse: /\d{1,2}(日|月|周)/, ordinal: function (number, period) { switch (period) { case 'd': case 'D': case 'DDD': return number + '日'; case 'M': return number + '月'; case 'w': case 'W': return number + '周'; default: return number; } }, relativeTime: { future: '%s内', past: '%s前', s: '几秒', m: '1分钟', mm: '%d分钟', h: '1小时', hh: '%d小时', d: '1天', dd: '%d天', M: '1个月', MM: '%d个月', y: '1年', yy: '%d年' }, week: { // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效 dow: 1, // Monday is the first day of the week. doy: 4 // The week that contains Jan 4th is the first week of the year. } }); export default SnackbarHOC()(App);