parent
c9c66f2f7f
commit
bae0380eb2
@ -1,24 +1,24 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import {Link} from 'react-router-dom'
|
import {Link} from 'react-router-dom'
|
||||||
|
|
||||||
const map={"blue":"colorblue","white":"colorwhite","grey":"colorgrey", 'orange': "color-orange"}
|
const map={"blue":"colorblue","white":"colorwhite","grey":"colorgrey", 'orange': "color-orange"}
|
||||||
class WordsBtn extends Component {
|
class WordsBtn extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let{to, href}=this.props
|
let{to, href,target}=this.props
|
||||||
return(
|
return(
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{
|
{
|
||||||
to==undefined ?
|
to==undefined ?
|
||||||
<a href={href || "javascript:void(0)"} onClick={this.props.onClick} className={"btn "+`${map[this.props.style]} ${this.props.className}`}>{this.props.children}</a>
|
<a href={href || "javascript:void(0)"} target={target} onClick={this.props.onClick} className={"btn "+`${map[this.props.style]} ${this.props.className}`}>{this.props.children}</a>
|
||||||
:
|
:
|
||||||
<Link to={to} className={"btn "+`${map[this.props.style]} ${this.props.className}`}>{this.props.children}</Link>
|
<Link to={to} className={"btn "+`${map[this.props.style]} ${this.props.className}`}>{this.props.children}</Link>
|
||||||
}
|
}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default WordsBtn;
|
export default WordsBtn;
|
@ -1,184 +1,184 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
export const STATUS_UN_PUBLISH = "未发布"
|
export const STATUS_UN_PUBLISH = "未发布"
|
||||||
// homework_status: ["提交中", "未开启补交"]
|
// homework_status: ["提交中", "未开启补交"]
|
||||||
export const STATUS_SUBMIT = "提交中"
|
export const STATUS_SUBMIT = "提交中"
|
||||||
// export const STATUS_UN_PUBLISH = "未发布"
|
// export const STATUS_UN_PUBLISH = "未发布"
|
||||||
|
|
||||||
// homework_status: ["提交中"] 未发布 未开启补交
|
// homework_status: ["提交中"] 未发布 未开启补交
|
||||||
|
|
||||||
|
|
||||||
export function RouteHOC(options = {}) {
|
export function RouteHOC(options = {}) {
|
||||||
return function wrap(WrappedComponent) {
|
return function wrap(WrappedComponent) {
|
||||||
return class Wrapper extends Component {
|
return class Wrapper extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toCreateProject = () => {
|
toCreateProject = () => {
|
||||||
let url = '/projects/new'
|
let url = '/projects/new'
|
||||||
if (window.location.port == 3007) {
|
if (window.location.port == 3007) {
|
||||||
// window.location.href
|
// window.location.href
|
||||||
url = '/testbdweb.educoder.net/projects/new'
|
url = '/testbdweb.educoder.net/projects/new'
|
||||||
}
|
}
|
||||||
window.open(
|
window.open(
|
||||||
url,
|
url,
|
||||||
'_blank' // <- This is what makes it open in a new window.
|
'_blank' // <- This is what makes it open in a new window.
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// common_homework group_homework
|
// common_homework group_homework
|
||||||
// 是否是分组作业
|
// 是否是分组作业
|
||||||
isGroup = () => {
|
isGroup = () => {
|
||||||
return window.location.pathname.indexOf('group_homeworks') != -1
|
return window.location.pathname.indexOf('group_homeworks') != -1
|
||||||
}
|
}
|
||||||
getModuleName = (isChinese) => {
|
getModuleName = (isChinese) => {
|
||||||
const isGroup = this.isGroup()
|
const isGroup = this.isGroup()
|
||||||
if (isChinese) {
|
if (isChinese) {
|
||||||
let chName = isGroup ? '分组作业' : '普通作业'
|
let chName = isGroup ? '分组作业' : '普通作业'
|
||||||
return chName;
|
return chName;
|
||||||
}
|
}
|
||||||
const secondName = isGroup ? 'group_homeworks' : 'common_homeworks'
|
const secondName = isGroup ? 'group_homeworks' : 'common_homeworks'
|
||||||
return secondName;
|
return secondName;
|
||||||
}
|
}
|
||||||
getModuleType = () => {
|
getModuleType = () => {
|
||||||
const isGroup = this.isGroup()
|
const isGroup = this.isGroup()
|
||||||
return isGroup ? 3 : 1
|
return isGroup ? 3 : 1
|
||||||
}
|
}
|
||||||
toDetailPage = (_courseId, workId, topicId) => {
|
toDetailPage = (_courseId, workId, topicId) => {
|
||||||
if (typeof _courseId == "object") {
|
if (typeof _courseId == "object") {
|
||||||
const topicId = _courseId.topicId
|
const topicId = _courseId.topicId
|
||||||
const workId = _courseId.workId
|
const workId = _courseId.workId
|
||||||
const courseId = _courseId.coursesId
|
const courseId = _courseId.coursesId
|
||||||
this.props.history.push(`/courses/${courseId}/boards/${workId}/messages/${topicId}`)
|
this.props.history.push(`/courses/${courseId}/boards/${workId}/messages/${topicId}`)
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/courses/${_courseId}/boards/${workId}/messages/${topicId}`)
|
this.props.history.push(`/courses/${_courseId}/boards/${workId}/messages/${topicId}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
toEditPage = (_courseId, _workId) => {
|
toEditPage = (_courseId, _workId) => {
|
||||||
const secondName = this.getModuleName()
|
const secondName = this.getModuleName()
|
||||||
if (typeof _courseId == "object") {
|
if (typeof _courseId == "object") {
|
||||||
const workId = _courseId.workId
|
const workId = _courseId.workId
|
||||||
const courseId = _courseId.coursesId
|
const courseId = _courseId.coursesId
|
||||||
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}/edit`)
|
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}/edit`)
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/edit`)
|
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/edit`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toWorkDetailPage = (_courseId, _workId, _studentWorkId) => {
|
toWorkDetailPage = (_courseId, _workId, _studentWorkId) => {
|
||||||
const secondName = this.getModuleName()
|
const secondName = this.getModuleName()
|
||||||
if (typeof _courseId == "object") {
|
if (typeof _courseId == "object") {
|
||||||
const workId = _courseId.workId
|
const workId = _courseId.workId
|
||||||
const courseId = _courseId.coursesId
|
const courseId = _courseId.coursesId
|
||||||
const studentWorkId = _courseId.studentWorkId
|
const studentWorkId = _courseId.studentWorkId
|
||||||
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}/${_studentWorkId || studentWorkId}/appraise`)
|
window.open(`/courses/${courseId}/${secondName}/${_workId || workId}/${_studentWorkId || studentWorkId}/appraise`);
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/${_studentWorkId}/appraise`)
|
window.open(`/courses/${_courseId}/${secondName}/${_workId}/${_studentWorkId}/appraise`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toNewPage = (courseId) => {
|
toNewPage = (courseId) => {
|
||||||
const secondName = this.getModuleName()
|
const secondName = this.getModuleName()
|
||||||
this.props.history.push(`/courses/${courseId.coursesId}/${secondName}/${courseId.category_id}/new`)
|
this.props.history.push(`/courses/${courseId.coursesId}/${secondName}/${courseId.category_id}/new`)
|
||||||
}
|
}
|
||||||
toListPage = (_courseId, _workId) => {
|
toListPage = (_courseId, _workId) => {
|
||||||
const secondName = this.getModuleName()
|
const secondName = this.getModuleName()
|
||||||
if (typeof _courseId == "object") {
|
if (typeof _courseId == "object") {
|
||||||
const workId = _courseId.workId
|
const workId = _courseId.workId
|
||||||
const courseId = _courseId.coursesId
|
const courseId = _courseId.coursesId
|
||||||
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}`)
|
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}`)
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/courses/${_courseId}/${secondName}${_workId ? '/' + _workId : ''}`)
|
this.props.history.push(`/courses/${_courseId}/${secondName}${_workId ? '/' + _workId : ''}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
toWorkPostPage = (_courseId, _workId, isEdit, _studentWorkId) => {
|
toWorkPostPage = (_courseId, _workId, isEdit, _studentWorkId) => {
|
||||||
const secondName = this.getModuleName()
|
const secondName = this.getModuleName()
|
||||||
if (typeof _courseId == "object") {
|
if (typeof _courseId == "object") {
|
||||||
const workId = _courseId.workId
|
const workId = _courseId.workId
|
||||||
const courseId = _courseId.coursesId
|
const courseId = _courseId.coursesId
|
||||||
const studentWorkId = _courseId.studentWorkId
|
const studentWorkId = _courseId.studentWorkId
|
||||||
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}/${isEdit? `${_studentWorkId || studentWorkId}/post_edit` : 'post'}`)
|
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}/${isEdit? `${_studentWorkId || studentWorkId}/post_edit` : 'post'}`)
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/${isEdit? `${_studentWorkId}/post_edit` : 'post'}`)
|
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/${isEdit? `${_studentWorkId}/post_edit` : 'post'}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toWorkListPage = (_courseId, _workId) => {
|
toWorkListPage = (_courseId, _workId) => {
|
||||||
const secondName = this.getModuleName()
|
const secondName = this.getModuleName()
|
||||||
if (typeof _courseId == "object") {
|
if (typeof _courseId == "object") {
|
||||||
const workId = _courseId.workId
|
const workId = _courseId.workId
|
||||||
const courseId = _courseId.coursesId
|
const courseId = _courseId.coursesId
|
||||||
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}/list`)
|
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}/list`)
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/list`)
|
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/list`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toWorkAnswerPage = (_courseId, _workId) => {
|
toWorkAnswerPage = (_courseId, _workId) => {
|
||||||
const secondName = this.getModuleName()
|
const secondName = this.getModuleName()
|
||||||
if (typeof _courseId == "object") {
|
if (typeof _courseId == "object") {
|
||||||
const workId = _courseId.workId
|
const workId = _courseId.workId
|
||||||
const courseId = _courseId.coursesId
|
const courseId = _courseId.coursesId
|
||||||
this.props.history.push(`/courses/${courseId}/${secondName}/${workId}/answer`)
|
this.props.history.push(`/courses/${courseId}/${secondName}/${workId}/answer`)
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/answer`)
|
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/answer`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toWorkQuestionPage = (_courseId, _workId) => {
|
toWorkQuestionPage = (_courseId, _workId) => {
|
||||||
const secondName = this.getModuleName()
|
const secondName = this.getModuleName()
|
||||||
if (typeof _courseId == "object") {
|
if (typeof _courseId == "object") {
|
||||||
const workId = _workId || _courseId.workId
|
const workId = _workId || _courseId.workId
|
||||||
const courseId = _courseId.coursesId
|
const courseId = _courseId.coursesId
|
||||||
this.props.history.push(`/courses/${courseId}/${secondName}/${workId}/question`)
|
this.props.history.push(`/courses/${courseId}/${secondName}/${workId}/question`)
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/question`)
|
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/question`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toWorkSettingPage = (_courseId, _workId) => {
|
toWorkSettingPage = (_courseId, _workId) => {
|
||||||
const secondName = this.getModuleName()
|
const secondName = this.getModuleName()
|
||||||
if (typeof _courseId == "object") {
|
if (typeof _courseId == "object") {
|
||||||
const workId = _courseId.workId
|
const workId = _courseId.workId
|
||||||
const courseId = _courseId.coursesId
|
const courseId = _courseId.coursesId
|
||||||
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}/setting`)
|
this.props.history.push(`/courses/${courseId}/${secondName}/${_workId || workId}/setting`)
|
||||||
} else {
|
} else {
|
||||||
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/setting`)
|
this.props.history.push(`/courses/${_courseId}/${secondName}/${_workId}/setting`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { snackbarOpen} = this.state;
|
const { snackbarOpen} = this.state;
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<WrappedComponent {...this.props}
|
<WrappedComponent {...this.props}
|
||||||
toDetailPage={this.toDetailPage}
|
toDetailPage={this.toDetailPage}
|
||||||
toEditPage={this.toEditPage}
|
toEditPage={this.toEditPage}
|
||||||
toNewPage={this.toNewPage}
|
toNewPage={this.toNewPage}
|
||||||
toListPage={this.toListPage}
|
toListPage={this.toListPage}
|
||||||
toWorkDetailPage={this.toWorkDetailPage}
|
toWorkDetailPage={this.toWorkDetailPage}
|
||||||
|
|
||||||
toWorkPostPage={this.toWorkPostPage}
|
toWorkPostPage={this.toWorkPostPage}
|
||||||
toWorkListPage={this.toWorkListPage}
|
toWorkListPage={this.toWorkListPage}
|
||||||
toWorkAnswerPage={this.toWorkAnswerPage}
|
toWorkAnswerPage={this.toWorkAnswerPage}
|
||||||
toWorkQuestionPage={this.toWorkQuestionPage}
|
toWorkQuestionPage={this.toWorkQuestionPage}
|
||||||
toWorkSettingPage={this.toWorkSettingPage}
|
toWorkSettingPage={this.toWorkSettingPage}
|
||||||
|
|
||||||
toCreateProject={this.toCreateProject}
|
toCreateProject={this.toCreateProject}
|
||||||
|
|
||||||
isGroup={this.isGroup}
|
isGroup={this.isGroup}
|
||||||
getModuleName={this.getModuleName}
|
getModuleName={this.getModuleName}
|
||||||
getModuleType={this.getModuleType}
|
getModuleType={this.getModuleType}
|
||||||
|
|
||||||
>
|
>
|
||||||
|
|
||||||
</WrappedComponent>
|
</WrappedComponent>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue