代码清理

This commit is contained in:
caishi 2020-05-07 09:05:43 +08:00
parent 3e96e210f3
commit 2dc7710a5b
4 changed files with 166 additions and 223 deletions

View File

@ -351,7 +351,7 @@ class MessageCount extends Component{
if(values.issue_tag_ids===''){
values.issue_tag_ids = []
}else{
values.issue_tag_ids = [parseInt(values.issue_tag_ids,0)]
values.issue_tag_ids = [parseInt(values.issue_tag_ids,10)]
}
if(values.assigned_to_id===0){

View File

@ -1,91 +1,84 @@
import React, { Component } from 'react';
import {Link} from 'react-router-dom';
import {Tooltip,Menu} from 'antd';
import Loadable from 'react-loadable';
import Loading from '../../../Loading';
import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';
import { Route, Switch } from 'react-router-dom';
import UpgradeModals from '../../modals/UpgradeModals';
import axios from 'axios';
import {getImageUrl} from 'educoder';
import InfosBanner from './InfosBanner'
import "./usersInfo.css"
import "../../courses/css/members.css"
import "../../courses/css/Courses.css"
import Trialapplication from '../../login/Trialapplication'
const InfosPackage = Loadable({
loader: () => import('./InfosPackage'),
loading:Loading,
loader: () => import('./InfosPackage'),
loading: Loading,
})
const InfosCourse = Loadable({
loader: () => import('./InfosCourse'),
loading:Loading,
loading: Loading,
})
const InfosShixun = Loadable({
loader: () => import('./InfosShixun'),
loading:Loading,
loading: Loading,
})
const InfosPath = Loadable({
loader: () => import('./InfosPath'),
loading:Loading,
loading: Loading,
})
const InfosProject = Loadable({
loader: () => import('./InfosProject'),
loading:Loading,
loading: Loading,
})
const InfosVideo = Loadable({
loader: () => import('./video/InfosVideo'),
loading:Loading,
loading: Loading,
})
const InfosTopics=Loadable({
loader: () => import('./InfosTopics'),
loading:Loading,
const InfosTopics = Loadable({
loader: () => import('./InfosTopics'),
loading: Loading,
})
const $ = window.$;
class Infos extends Component{
constructor(props){
class Infos extends Component {
constructor(props) {
super(props);
this.state={
data:undefined,
is_current:undefined,
is_edit:false,
sign:undefined,
type:0,
login:undefined,
isRenders:false,
moduleName:"classrooms",
next_gold:undefined
this.state = {
data: undefined,
is_current: undefined,
is_edit: false,
sign: undefined,
type: 0,
login: undefined,
isRenders: false,
moduleName: "classrooms",
next_gold: undefined
}
}
componentDidMount =()=>{
let upsystem=`/users/system_update.json`;
axios.get(upsystem).then((response)=>{
let updata=response.data;
this.setState({
updata:updata
})
}).catch((error)=>{
console.log(error);
})
componentDidMount = () => {
let upsystem = `/users/system_update.json`;
axios.get(upsystem).then((response) => {
let updata = response.data;
this.setState({
updata: updata
})
}).catch((error) => {
console.log(error);
})
this.getInfo(this.props.match.params.username);
this.getInfo(this.props.match.params.username);
}
//判断是否看的是当前用户的个人主页
componentDidUpdate =(prevProps)=> {
if(this.props.current_user && prevProps.current_user != this.props.current_user){
if(this.props.current_user.login != this.props.match.params.username){
componentDidUpdate = (prevProps) => {
if (this.props.current_user && prevProps.current_user != this.props.current_user) {
if (this.props.current_user.login != this.props.match.params.username) {
this.setState({
is_current:false,
login:this.props.current_user.login
is_current: false,
login: this.props.current_user.login
})
}
} else {
@ -98,235 +91,208 @@ class Infos extends Component{
//获取个人主页信息
getInfo = (user_login) =>{
let url =`/users/${user_login}/homepage_info.json`;
axios.get(url).then((result)=>{
if(result){
if (result.data.status === 403||result.data.status === 401||result.data.status === 500||result.data.status === 404) {
getInfo = (user_login) => {
let url = `/users/${user_login}/homepage_info.json`;
axios.get(url).then((result) => {
if (result) {
if (result.data.status === 403 || result.data.status === 401 || result.data.status === 500 || result.data.status === 404) {
}else{
this.setState({
data:result.data,
followed:result.data.followed,
sign:result.data.brief_introduction,
id:result.data.id,
next_gold:result.data.tomorrow_attendance_gold
})
}
} else {
this.setState({
data: result.data,
followed: result.data.followed,
sign: result.data.brief_introduction,
id: result.data.id,
next_gold: result.data.tomorrow_attendance_gold
})
}
}
}).catch((error)=>{
}).catch((error) => {
console.log(error);
})
}
// 编辑签名
editmysign=()=>{
editmysign = () => {
this.setState({
is_edit:true
},()=>{
is_edit: true
}, () => {
$("#mysign").focus();
})
}
// 输入签名
inputSign=(e)=>{
inputSign = (e) => {
this.setState({
sign:e.target.value
sign: e.target.value
})
}
//取消编辑签名
savemysign=()=>{
let { sign } =this.state;
let url=`/users/brief_introduction.json`;
axios.post((url),{
content:sign
}).then((result)=>{
if(result){
savemysign = () => {
let { sign } = this.state;
let url = `/users/brief_introduction.json`;
axios.post((url), {
content: sign
}).then((result) => {
if (result) {
this.setState({
is_edit:false
is_edit: false
})
}
}).catch((error)=>{
}).catch((error) => {
console.log(error)
})
}
changeType=(e)=>{
changeType = (e) => {
this.setState({
type:e.key
type: e.key
})
}
turnTo=(url)=>{
turnTo = (url) => {
this.props.history.push(url);
}
//签到
signFor=()=>{
let url=`/users/attendance.json`
axios.post(url).then((result)=>{
if(result){
// this.setState(
// (prevState) => ({
// data : update(prevState.data, {attendance_signed: {$set: true} })
// })
// )
// this.setState({
// next_gold:result.data.next_gold
// })
signFor = () => {
let url = `/users/attendance.json`
axios.post(url).then((result) => {
if (result) {
this.getInfo(this.props.match.params.username);
}
}).catch((error)=>{
}).catch((error) => {
console.log(error);
})
}
// 关注
followPerson=()=>{
let{followed,id}=this.state;
let url=`/users/${id}/watch.json`;
followPerson = () => {
let { followed, id } = this.state;
let url = `/users/${id}/watch.json`;
// 取消关注
if(followed){
axios.delete(url).then((result)=>{
if(result){
if (followed) {
axios.delete(url).then((result) => {
if (result) {
this.setState({
followed:false
followed: false
})
}
}).catch((error)=>{
}).catch((error) => {
console.log(error)
})
}else{
} else {
// 关注
axios.post(url).then((result)=>{
if(result){
axios.post(url).then((result) => {
if (result) {
this.setState({
followed:true
followed: true
})
}
}).catch((error)=>{
}).catch((error) => {
console.log(error);
})
}
}
// 试用申请
// trialapplications =()=>{
// this.setState({
// isRenders: true,
// showTrial:true
// })
// }
cancelModulationModels=()=>{
cancelModulationModels = () => {
this.setState({
isRenders: false
})
}
ToBank=(url)=>{
window.location.href=url;
ToBank = (url) => {
window.location.href = url;
}
render(){
render() {
let {
data ,
is_edit,
sign,
type,
followed,
id,
isRenders,
moduleName,
next_gold
}=this.state;
} = this.state;
let isCurrent = true;
let currentLogin;
if(this.props.current_user && this.props.current_user.login != this.props.match.params.username){
isCurrent=false;
if (this.props.current_user && this.props.current_user.login != this.props.match.params.username) {
isCurrent = false;
currentLogin = this.props.current_user.login;
}
const _commonProps = {
is_current: isCurrent,
login: currentLogin
}
return(
return (
<div className="newMain">
{this.state.updata===undefined?"":<UpgradeModals
{...this.state}
/>}
{this.state.updata === undefined ? "" : <UpgradeModals
{...this.state}
/>}
{
isRenders && <Trialapplication {...this.props} {...this.state} Cancel={() => this.cancelModulationModels()}/>
isRenders && <Trialapplication {...this.props} {...this.state} Cancel={() => this.cancelModulationModels()} />
}
<InfosBanner
{...this.props}
{...this.state}
{..._commonProps}
signFor={this.signFor}
followPerson={this.followPerson}
{..._commonProps}
signFor={this.signFor}
followPerson={this.followPerson}
></InfosBanner>
<Switch {...this.props}>
{/* --------------------------------------------------------------------- */}
{/* 题库 */}
<Route exact path="/users/:username/topics/:topicstype"
render={
(props) => (<InfosTopics {...this.props} {...props} {...this.state} {..._commonProps}/>)
}
></Route>
{/* --------------------------------------------------------------------- */}
{/* 题库 */}
<Route exact path="/users/:username/topics/:topicstype"
render={
(props) => (<InfosTopics {...this.props} {...props} {...this.state} {..._commonProps} />)
}
></Route>
{/* 课堂 */}
{/* http://localhost:3007/courses/1309/homework/9300/setting */}
{/* 课堂 */}
<Route exact path="/users/:username/classrooms"
render={
(props) => (<InfosCourse {...this.props} {...props} {...this.state} {..._commonProps}/>)
}
></Route>
render={
(props) => (<InfosCourse {...this.props} {...props} {...this.state} {..._commonProps} />)
}
></Route>
{/* 实训项目 */}
<Route exact path="/users/:username/shixuns"
render={
(props) => (<InfosShixun {...this.props} {...props} {...this.state} {..._commonProps}/>)
}
></Route>
<Route exact path="/users/:username/shixuns"
render={
(props) => (<InfosShixun {...this.props} {...props} {...this.state} {..._commonProps} />)
}
></Route>
{/* 实践课程 */}
<Route exact path="/users/:username/paths"
render={
(props) => (<InfosPath {...this.props} {...props} {...this.state} {..._commonProps}/>)
}
></Route>
<Route exact path="/users/:username/paths"
render={
(props) => (<InfosPath {...this.props} {...props} {...this.state} {..._commonProps} />)
}
></Route>
{/* 开发项目 */}
<Route exact path="/users/:username/projects"
render={
(props) => (<InfosProject {...this.props} {...props} {...this.state} {..._commonProps}/>)
}
></Route>
<Route exact path="/users/:username/projects"
render={
(props) => (<InfosProject {...this.props} {...props} {...this.state} {..._commonProps} />)
}
></Route>
{/* 众包 */}
{/* http://localhost:3007/courses/1309/homework/9300/setting */}
<Route exact path="/users/:username/package"
render={
(props) => (<InfosPackage {...this.props} {...props} {...this.state} {..._commonProps}/>)
}
></Route>
{/* 众包 */}
<Route exact path="/users/:username/package"
render={
(props) => (<InfosPackage {...this.props} {...props} {...this.state} {..._commonProps} />)
}
></Route>
{/* 视频 */}
<Route exact path="/users/:username/videos"
render={
(props) => (<InfosVideo {...this.props} {...props} {...this.state} {..._commonProps}/>)
}
></Route>
{/* 视频 */}
<Route exact path="/users/:username/videos"
render={
(props) => (<InfosVideo {...this.props} {...props} {...this.state} {..._commonProps} />)
}
></Route>
<Route exact path="/users/:username"
render={
(props) => (<InfosCourse {...this.props} {...props} {...this.state} {..._commonProps}/>)
}
></Route>
render={
(props) => (<InfosCourse {...this.props} {...props} {...this.state} {..._commonProps} />)
}
></Route>
</Switch>
</div>
)
}
}
// CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC))
export default (Infos) ;
export default (Infos);

View File

@ -1,13 +1,11 @@
import React, { Component } from 'react';
import { Pagination, Spin, Checkbox, Modal } from 'antd';
import { Pagination, Spin, Checkbox } from 'antd';
import moment from 'moment';
import axios from 'axios';
import NoneData from '../../courses/coursesPublic/NoneData'
import { getImageUrl } from 'educoder';
import "./usersInfo.css"
import Modals from '../../modals/Modals'
const dateFormat = "YYYY-MM-DD HH:mm"
class InfosBank extends Component {
constructor(props) {
super(props);
@ -151,7 +149,6 @@ class InfosBank extends Component {
modalsTopval,
modalsBottomval, modalSave
} = this.state;
let isStudent = this.props.isStudent();
let is_current = this.props.is_current;
return (
<div className="educontent">
@ -164,15 +161,15 @@ class InfosBank extends Component {
></Modals>
<Spin size="large" spinning={isSpin}>
<div className="white-panel edu-back-white pt20 pb20 clearfix ">
<li className={type == "publicly" ? "active" : ""}><a onClick={() => this.changeType("publicly")}>{is_current ? "我" : "TA"}的题库</a></li>
<li className={type == "personal" ? "active" : ""}><a onClick={() => this.changeType("personal")}>公共题库</a></li>
<li className={type === "publicly" ? "active" : ""}><a onClick={() => this.changeType("publicly")}>{is_current ? "我" : "TA"}的题库</a></li>
<li className={type === "personal" ? "active" : ""}><a onClick={() => this.changeType("personal")}>公共题库</a></li>
</div>
<div className="edu-back-white padding10-30 bor-top-greyE">
<ul className="clearfix secondNav">
<li className={category == "common" ? "active" : ""}><a onClick={() => this.changeCategory("common")}>普通作业</a></li>
<li className={category == "group" ? "active" : ""}><a onClick={() => this.changeCategory("group")}>分组作业</a></li>
<li className={category == "exercise" ? "active" : ""}><a onClick={() => this.changeCategory("exercise")}>试卷</a></li>
<li className={category == "poll" ? "active" : ""}><a onClick={() => this.changeCategory("poll")}>问卷</a></li>
<li className={category === "common" ? "active" : ""}><a onClick={() => this.changeCategory("common")}>普通作业</a></li>
<li className={category === "group" ? "active" : ""}><a onClick={() => this.changeCategory("group")}>分组作业</a></li>
<li className={category === "exercise" ? "active" : ""}><a onClick={() => this.changeCategory("exercise")}>试卷</a></li>
<li className={category === "poll" ? "active" : ""}><a onClick={() => this.changeCategory("poll")}>问卷</a></li>
</ul>
<div className="edu-txt-left mt10 bankTag">
<ul className="inline" id="sourceTag">
@ -182,7 +179,7 @@ class InfosBank extends Component {
{
data && data.course_list && data.course_list.map((item, key) => {
return (
<li className={CoursesId == item.id ? "active" : ""} key={key} onClick={() => this.changeCourseListId(`${item.id}`)}>
<li className={CoursesId === item.id ? "active" : ""} key={key} onClick={() => this.changeCourseListId(`${item.id}`)}>
<a >{item.name}</a>
</li>
)
@ -195,7 +192,7 @@ class InfosBank extends Component {
<span className="fl color-grey-9">共参与{totalCount}个题库</span>
<div className="fr">
<li className="drop_down">
<span className="color-grey-9 font-12">{sort_by == "updated_at" ? "时间最新" : sort_by == "name" ? "作业名称" : "贡献者"}</span><i className="iconfont icon-xiajiantou font-12 ml2 color-grey-6"></i>
<span className="color-grey-9 font-12">{sort_by === "updated_at" ? "时间最新" : sort_by == "name" ? "作业名称" : "贡献者"}</span><i className="iconfont icon-xiajiantou font-12 ml2 color-grey-6"></i>
<ul className="drop_down_normal">
<li onClick={() => this.changeOrder("updated_at")}>时间最新</li>
<li onClick={() => this.changeOrder("name")}>作业名称</li>
@ -206,7 +203,7 @@ class InfosBank extends Component {
</p>
<div className="dataBank_list edu-back-white educontent">
{
!data || data.question_banks.length == 0 && <NoneData></NoneData>
!data || data.question_banks.length === 0 && <NoneData></NoneData>
}
{
data && data.question_banks && data.question_banks.map((item, key) => {
@ -220,7 +217,7 @@ class InfosBank extends Component {
<span className="dataTitle fl mr80">{item.name}</span>
<a data-object="2599" className="bank_send fr">发送</a>
{
item.is_public == false ?
item.is_public === false ?
<a onClick={() => this.setPublic(1)} className="bank_public color-blue_4C fr mr60">设为公开</a> : ""
}
</p>

View File

@ -3,8 +3,10 @@ import { Pagination, Spin } from 'antd';
import axios from 'axios';
import Modals from '../../modals/Modals';
import NoneData from '../../courses/coursesPublic/NoneData';
import "./usersInfo.css"
import "./usersInfo.css";
import moment from 'moment';
let categorylist = [
{ name: "全部", value: undefined },
{ name: "前端开发", value: "front" },
@ -138,9 +140,9 @@ class InfosPackage extends Component {
this.getCourses(category, status, 1);
}
})
.catch(function (error) {
console.log(error);
});
.catch(function (error) {
console.log(error);
});
this.cancelProject();
}
render() {
@ -153,11 +155,8 @@ class InfosPackage extends Component {
isSpin
} = this.state;
let is_current = this.props.is_current;
// console.log(data)
return (
<div className="educontent mb50">
{/*提示*/}
<Modals
modalsType={this.state.Modalstype}
modalsTopval={this.state.Modalstopval}
@ -190,9 +189,6 @@ class InfosPackage extends Component {
border: none !important;
color: #4CACFF;
}
`
}
</style>
@ -206,22 +202,6 @@ class InfosPackage extends Component {
onClick={() => this.changeCategory("study")}
className="font-16 w66">{is_current ? "我" : "TA"}学习的</a></li>
</div>
<style>
{
` .secondNavs li {
color: #676767;
/* margin: 0px 20px; */
float: left;
}
.secondNavs li a:hover{
color: #4CACFF
}
.secondNavs li.active a{
color: #4CACFF
}
`
}
</style>
{
category == "manage" ?
<div className="edu-back-white padding10-30 clearfix secondNavs bor-top-greyE">