Merge branch 'dev_item_bank' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_item_bank

yslnewtiku
cxt 5 years ago
commit 5132ceea06

@ -83,9 +83,9 @@ class Admins::ShixunSettingsController < Admins::BaseController
sheet1[count_row, 6] = shixun.myshixuns_count
sheet1[count_row, 7] = shixun.myshixuns.select{|m| m.status == 1}.size
sheet1[count_row, 8] = shixun.shixun_status
sheet1[count_row, 9] = shixun.user.show_real_name
sheet1[count_row, 10] = shixun.user.school_name
sheet1[count_row, 11] = shixun.user.identity
sheet1[count_row, 9] = shixun.user&.show_real_name
sheet1[count_row, 10] = shixun.user&.school_name
sheet1[count_row, 11] = shixun.user&.identity
shixun.challenges.each do |challenge|
sheet1[count_row, 12] = "#{challenge.position}"
sheet1[count_row, 13] = challenge.subject
@ -112,13 +112,16 @@ class Admins::ShixunSettingsController < Admins::BaseController
sheet1[count_row, 2] = shixun.mirror_repositories.select{|mr| mr.main_type == "1"}.first&.type_name
sheet1[count_row, 3] = shixun.fork_from
sheet1[count_row, 4] = shixun.shixun_status
sheet1[count_row, 5] = shixun.user.show_real_name
sheet1[count_row, 6] = shixun.user.school_name
sheet1[count_row, 7] = shixun.user.identity
shixun.challenges.each do |challenge|
sheet1[count_row, 5] = shixun.user&.show_real_name
sheet1[count_row, 6] = shixun.user&.school_name
sheet1[count_row, 7] = shixun.user&.identity
challenge_count = shixun.challenges.count
shixun.challenges.each_with_index do |challenge, index|
sheet1[count_row, 8] = "#{challenge.position}"
sheet1[count_row, 9] = challenge.subject
count_row += 1
if index + 1 != challenge_count
count_row += 1
end
end
count_row += 1
end

@ -10,9 +10,6 @@ class GamesController < ApplicationController
include GamesHelper
include ApplicationHelper
def show
uid_logger("--games show start")
# 防止评测中途ajaxE被取消;3改成0是为了处理首次进入下一关的问题
@ -91,7 +88,6 @@ class GamesController < ApplicationController
end
end
def jupyter
# Jupyter没有challenge
@myshixun = Myshixun.find_by_identifier params[:identifier]

@ -467,7 +467,7 @@ class ShixunsController < ApplicationController
def update_learn_setting
begin
ActiveRecord::Base.transaction do
@shixun.update_attributes!(shixun_params)
@shixun.update_attributes!(shixun_params.merge(vnc_evaluate: 1))
end
rescue => e
uid_logger_error("实训学习页面设置失败--------#{e.message}")
@ -909,16 +909,20 @@ class ShixunsController < ApplicationController
# 搜索成员
if request.get?
@collaborators = @shixun.shixun_members.where("user_id != #{@shixun.user_id}")
else
if params[:user_id]
man_member = ShixunMember.where(:shixun_id => @shixun.id, :user_id => @shixun.user_id).first
cha_member = ShixunMember.where(:user_id => params[:user_id], :shixun_id => @shixun.id).first
if man_member && cha_member
man_member.update_attribute(:role, 2)
cha_member.update_attribute(:role, 1)
@shixun.update_attribute(:user_id, cha_member.user_id)
end
end
else
begin
raise("请先选择成员") if params[:user_id].blank?
man_member = ShixunMember.where(:shixun_id => @shixun.id, :user_id => @shixun.user_id).first
cha_member = ShixunMember.where(:user_id => params[:user_id], :shixun_id => @shixun.id).first
if man_member && cha_member
man_member.update_attribute(:role, 2)
cha_member.update_attribute(:role, 1)
@shixun.update_attribute(:user_id, cha_member.user_id)
end
rescue => e
logger.error("######change_manager_error: #{e.message}")
render_error(e.message)
end
end
end

@ -32,7 +32,7 @@
<%= link_to shixun.try(:identifier), shixun_path(shixun.try(:identifier)), target: '_blank'%>
<% end%>
</td>
<td><%= overflow_hidden_span(shixun&.fork_reason) %></td>
<td><%= overflow_hidden_span(shixun&.fork_reason, width: 150) %></td>
<td><%= shixun.challenges.where(:st => 0).size %></td>
<td><%= shixun.challenges.where(:st => 1).size %></td>
<td class="shixuns-status-<%= shixun.status %>"><%= shixun_authentication_status shixun %></td>

@ -5,9 +5,11 @@ json.chooses do
json.type choose.category
end
end
json.st @challenge.st
if @tab == 0
# 本关任务tab的编辑模式
json.(@challenge, :id, :subject, :task_pass, :difficulty, :score, :exec_time)
json.(@challenge, :id, :subject, :task_pass, :difficulty, :score, :exec_time, :st)
json.tags @challenge.challenge_tags.map(&:name)
elsif @tab == 1
# 评测设置的编辑模式

@ -1,7 +1,7 @@
json.(@challenge_choose, :challenge_id, :subject, :answer,
:standard_answer, :score, :difficult,
:position, :category)
json.st @challenge.st
# 选项的参数
json.choose_contents @challenge_choose.challenge_questions do |question|
json.(question, :option_name, :position, :right_key)

@ -1,6 +1,6 @@
# 导航栏公共数据
json.partial! "challenges/top_common_data", shixun_identifier: @shixun.identifier
json.(@challenge, :id, :subject, :task_pass, :difficulty, :score, :exec_time)
json.(@challenge, :id, :subject, :task_pass, :difficulty, :score, :exec_time, :st)
json.tags @challenge.challenge_tags.map(&:name)

@ -1,8 +1,12 @@
json.(@hack_user, :id, :status, :error_line, :error_msg, :expected_output,
:input, :output, :execute_time, :execute_memory, :created_at, :code)
json.language @hack_user.hack.language
json.name @hack_user.hack.name
json.myproblem_identifier @my_hack.identifier
json.user do
json.partial! 'users/user', user: current_user
end
json.status 0
json.message "返回成功"
json.data do
json.(@hack_user, :id, :status, :error_line, :error_msg, :expected_output,
:input, :output, :execute_time, :execute_memory, :created_at, :code)
json.language @hack_user.hack.language
json.name @hack_user.hack.name
json.myproblem_identifier @my_hack.identifier
json.user do
json.partial! 'users/user', user: current_user
end
end

@ -180,7 +180,7 @@ $ml: 20px;
background: #fff;
left: 0px;
right: 0px;
top: -220px;
top: -230px;
padding: 0 20px;
}
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-23 11:33:41
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-25 11:07:42
* @LastEditTime : 2019-12-25 17:10:30
// */
import './index.scss';
import React, { useState, useEffect, useMemo } from 'react';
@ -129,7 +129,7 @@ const LeftPane = (props) => {
/>
</div>
<div className="number_flex flex_info">
<TextNumber text="huifu1" number={comments_count} type="icon" onIconClick={handleClickMessage}/>
<TextNumber text="huifu1" number={hack.comments_count} type="icon" onIconClick={handleClickMessage}/>
<TextNumber
className={user_praise ? 'like active' : 'like'}
text="dianzan"

@ -163,142 +163,136 @@ class TPMIndex extends Component {
componentDidUpdate(prevProps, prevState) {
if (prevProps != this.props) {
if (prevProps.user != this.props.user) {
let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings';
let newTPMsettings=window.localStorage.getItem(getnewTPMsettings)
if(this.state.identity <4){
if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){
this.setState({
openknows:true
})
}else{
this.setState({
openknows:false
})
}
}
if (prevProps!=this.props) {
let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings';
let newTPMsettings=window.localStorage.getItem(getnewTPMsettings)
if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){
this.setState({
openknows:true
})
}else{
this.setState({
openknows:false
})
}
}
}
}
componentDidMount = () => {
let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings';
let newTPMsettings=window.localStorage.getItem(getnewTPMsettings)
let id = this.props.match.params.shixunId;
// console.log('props', this.props);
// let collaborators = `/shixuns/` + id + `/propaedeutics.json`;
//
// axios.get(collaborators).then((response) => {
// if (response.status === 200) {
// if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
//
// }else{
// this.setState({
// PropaedeuticsList: response.data,
// shixunId: id
// });
// }
//
// }
// }).catch((error) => {
// console.log(error)
// });
let Url = `/shixuns/` + id + `.json`;
axios.get(Url).then((response) => {
if (response.status === 200) {
document.title=response.data.name;
let newstar_info = [];
// let start1=
for (var i = 0; i < response.data.score_info.length; i++) {
if (i === 0) {
newstar_info.push(response.data.score_info[i])
} else {
newstar_info.push((response.data.score_info[i] / 100) * 5)
}
}
let newstar_infos = response.data.score_info;
this.setState({
shixunsDetails: response.data,
shixunId: id,
star_info: newstar_info,
star_infos: newstar_infos,
power: response.data.power,
identity: response.data.identity,
propaedeutics:response.data.propaedeutics,
status: response.data.shixun_status,
secret_repository: response.data.secret_repository,
public:response.data.public,
is_jupyter:response.data.is_jupyter=== undefined||response.data.is_jupyter===null?false:response.data.is_jupyter,
});
if(response.data.identity <4){
if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){
this.setState({
openknows:true
})
}else{
this.setState({
openknows:false
})
}
}
getcomponentdidmount=()=>{
let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings';
let newTPMsettings=window.localStorage.getItem(getnewTPMsettings)
let id = this.props.match.params.shixunId;
// console.log('props', this.props);
// let collaborators = `/shixuns/` + id + `/propaedeutics.json`;
//
// axios.get(collaborators).then((response) => {
// if (response.status === 200) {
// if (response.data.status === 403||response.data.status === 401||response.data.status === 500) {
//
// }else{
// this.setState({
// PropaedeuticsList: response.data,
// shixunId: id
// });
// }
//
// }
// }).catch((error) => {
// console.log(error)
// });
let Url = `/shixuns/` + id + `.json`;
axios.get(Url).then((response) => {
if (response.status === 200) {
document.title=response.data.name;
let newstar_info = [];
// let start1=
for (var i = 0; i < response.data.score_info.length; i++) {
if (i === 0) {
newstar_info.push(response.data.score_info[i])
} else {
newstar_info.push((response.data.score_info[i] / 100) * 5)
}
}).catch((error) => {
this.setState({
shixunsDetails: undefined,
shixunId: undefined,
star_info: undefined,
star_infos: undefined,
power: undefined,
identity: undefined,
status: undefined,
propaedeutics:undefined,
is_jupyter:false,
});
});
this.tpmContentRequestInterceptor = axios.interceptors.request.use((config) => {
let url = config.url;
// console.log('tpmContentRequestInterceptor:', url)
for ( let i = 0; i < interceptorUrlArray.length; i++ ) {
if (url.indexOf(interceptorUrlArray[i]) != -1) {
url = url.split('?')[0]
console.log('loadingContent, url:', url)
this.setState({ loadingContent: true })
cacheInterceptorUrlMap[url] = true
}
}
let newstar_infos = response.data.score_info;
this.setState({
shixunsDetails: response.data,
shixunId: id,
star_info: newstar_info,
star_infos: newstar_infos,
power: response.data.power,
identity: response.data.identity,
propaedeutics:response.data.propaedeutics,
status: response.data.shixun_status,
secret_repository: response.data.secret_repository,
public:response.data.public,
is_jupyter:response.data.is_jupyter=== undefined||response.data.is_jupyter===null?false:response.data.is_jupyter,
});
if(response.data.identity <4){
if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){
this.setState({
openknows:true
})
}else{
this.setState({
openknows:false
})
}
return config;
}, function (error) {
return Promise.reject(error);
}
}
}).catch((error) => {
this.setState({
shixunsDetails: undefined,
shixunId: undefined,
star_info: undefined,
star_infos: undefined,
power: undefined,
identity: undefined,
status: undefined,
propaedeutics:undefined,
is_jupyter:false,
});
});
// Add a response interceptor
this.tpmContentResponseInterceptor = axios.interceptors.response.use((response) => {
// console.log('loadingContent finished, url:', response.config.url)
// TODO 依赖了api这个前缀
let url = response.config.url.split('api')[1];
this.tpmContentRequestInterceptor = axios.interceptors.request.use((config) => {
let url = config.url;
// console.log('tpmContentRequestInterceptor:', url)
for ( let i = 0; i < interceptorUrlArray.length; i++ ) {
if (url.indexOf(interceptorUrlArray[i]) != -1) {
url = url.split('?')[0]
if (cacheInterceptorUrlMap[url]) {
console.log('loadingContent, url:', url)
this.setState({ loadingContent: false })
delete cacheInterceptorUrlMap[response.url]
}
return response;
}, function (error) {
// Do something with response error
return Promise.reject(error);
});
this.setState({ loadingContent: true })
cacheInterceptorUrlMap[url] = true
}
}
return config;
}, function (error) {
return Promise.reject(error);
});
// Add a response interceptor
this.tpmContentResponseInterceptor = axios.interceptors.response.use((response) => {
// console.log('loadingContent finished, url:', response.config.url)
// TODO 依赖了api这个前缀
let url = response.config.url.split('api')[1];
url = url.split('?')[0]
if (cacheInterceptorUrlMap[url]) {
this.setState({ loadingContent: false })
delete cacheInterceptorUrlMap[response.url]
}
return response;
}, function (error) {
// Do something with response error
return Promise.reject(error);
});
//右侧数据
let shixunsDetailsURL=`/shixuns/`+id+`/show_right.json`;
axios.get(shixunsDetailsURL).then((response)=> {
@ -311,6 +305,10 @@ class TPMIndex extends Component {
})
this.getnavdatas()
}
componentDidMount = () => {
this.getcomponentdidmount()
}
componentWillUnmount = () => {
axios.interceptors.request.eject(this.tpmContentRequestInterceptor);
@ -382,7 +380,6 @@ class TPMIndex extends Component {
let url = window.location.href;
let flag = url.indexOf("add_file")>-1;
return (
<div className="newMain clearfix">
{/*头部*/}
@ -447,7 +444,7 @@ class TPMIndex extends Component {
{ this.state.is_jupyter===false? <Menu.Item key="8" className={"competitionmr50"}>
<span className={"tpmbannernavstyler"}>排行榜</span>
</Menu.Item>:""}
<span>
{this.state.identity >4||this.state.identity===undefined ? "":<span>
<Popover
content={
<pre className={"bannerpd201"}>
@ -460,7 +457,7 @@ class TPMIndex extends Component {
visible={this.state.openknows}
>
</Popover>
</span>
</span>}
{this.state.identity >4||this.state.identity===undefined ? "":
<Menu.Item key="9" className={"competitionmr50"}>

@ -172,40 +172,44 @@ class TPMRightSection extends Component {
<div className="recommend-list">
{
TPMRightSectionData === undefined ? "" : TPMRightSectionData.paths === undefined ? "" : TPMRightSectionData.paths.map((i, k) => {
if(k>2){
return (
}else{
return (
<div className="recomments clearfix df" key={k}>
<div className="recomments clearfix df" key={k}>
<a href={"/paths/" + i.id} height="96" width="128" target="_blank">
<img alt="实训" height="96" src={"/" + i.image_url} width="128"/>
</a>
<a href={"/paths/" + i.id} height="96" width="128" target="_blank">
<img alt="实训" height="96" src={"/" + i.image_url} width="128"/>
</a>
<div className="ml10 flex1">
<a href={"/paths/" + i.id} target="_blank" data-tip-down={i.name}
className="color-grey-6 task-hide mb12 recomment-name">{i.name}</a>
<p className="clearfix mt8 font-12 color-grey-B4">
<div className="ml10 flex1">
<a href={"/paths/" + i.id} target="_blank" data-tip-down={i.name}
className="color-grey-6 task-hide mb12 recomment-name">{i.name}</a>
<p className="clearfix mt8 font-12 color-grey-B4">
<Tooltip placement="bottom" title={"章节"}>
<Tooltip placement="bottom" title={"章节"}>
<span className="mr10 fl squareIconSpan"><i
className="iconfont icon-shixun fl mr3"></i>{i.stages_count}</span>
</Tooltip>
</Tooltip>
{/*<Tooltip placement="bottom" title={"经验值"}>*/}
{/*<span className="mr10 fl squareIconSpan"><i className="iconfont icon-jingyan fl mr3"></i>{i.score_count}</span>*/}
{/*</Tooltip>*/}
{/*<Tooltip placement="bottom" title={"经验值"}>*/}
{/*<span className="mr10 fl squareIconSpan"><i className="iconfont icon-jingyan fl mr3"></i>{i.score_count}</span>*/}
{/*</Tooltip>*/}
<Tooltip placement="bottom" title={"学习人数"}>
<Tooltip placement="bottom" title={"学习人数"}>
<span className="mr10 fl squareIconSpan"><i
className="iconfont icon-chengyuan fl mr3"></i>{i.members_count}</span>
</Tooltip>
</Tooltip>
</p>
</div>
</p>
</div>
</div>
)
}
)
})
}
</div>
@ -222,23 +226,28 @@ class TPMRightSection extends Component {
<div className="recommend-list">
{
TPMRightSectionData === undefined ? "" : TPMRightSectionData.recommands === undefined ? "" : TPMRightSectionData.recommands.map((item, key) => {
return (
<div className="recomments clearfix df" key={key}>
<a href={"/shixuns/" + item.identifier + "/challenges"} target="_blank">
<img alt="69?1526971094" height="96" src={"/" + item.pic} width="128"/>
</a>
<div className="ml10 flex1">
<Tooltip placement="bottom" title={item.name}>
<a href={"/shixuns/" + item.identifier + "/challenges"} target="_blank"
className="color-grey-6 task-hide mb12 recomment-name">{item.name}</a>
</Tooltip>
<p className="clearfix mt8 font-12 color-grey-B4">
{item.stu_num} 人学习
</p>
<p className="edu-txt-right color-orange pr10">{item.level}</p>
if(key>2){
}else{
return (
<div className="recomments clearfix df" key={key}>
<a href={"/shixuns/" + item.identifier + "/challenges"} target="_blank">
<img alt="69?1526971094" height="96" src={"/" + item.pic} width="128"/>
</a>
<div className="ml10 flex1">
<Tooltip placement="bottom" title={item.name}>
<a href={"/shixuns/" + item.identifier + "/challenges"} target="_blank"
className="color-grey-6 task-hide mb12 recomment-name">{item.name}</a>
</Tooltip>
<p className="clearfix mt8 font-12 color-grey-B4">
{item.stu_num} 人学习
</p>
<p className="edu-txt-right color-orange pr10">{item.level}</p>
</div>
</div>
</div>
)
)
}
})
}
</div>

@ -88,17 +88,20 @@ class Collaborators extends Component {
this.setState({
Collaboratorsvisibleadmin: false,
Collaboratorslist: [],
Searchadmin: []
Searchadmin: [],
addadminrediovalue:undefined
});
} else if (type === "admin") {
this.setState({
Collaboratorsvisible: false,
Collaboratorslist: [],
Searchadmin: []
Searchadmin: [],
addadminrediovalue:undefined
});
} else if (type === "collaborators_deletetype") {
this.setState({
collaborators_deletetype: false,
addadminrediovalue:undefined
});
}
}
@ -312,12 +315,13 @@ class Collaborators extends Component {
let url = "/shixuns/" + id + "/change_manager.json";
if (addadminrediovalue === undefined) {
this.setState({
Collaboratorsvisible: false,
Collaboratorslist: [],
Searchadmin: []
// Collaboratorsvisible: false,
// Collaboratorslist: [],
// Searchadmin: [],
addadminrediovalue:undefined
});
this.props.showNotification("所选人员为空,没有更换成功");
this.CollaboratorsshowModal("admin")
// this.CollaboratorsshowModal("admin")
return
}
@ -328,7 +332,8 @@ class Collaborators extends Component {
this.setState({
Collaboratorsvisible: false,
Collaboratorslist: [],
Searchadmin: []
Searchadmin: [],
addadminrediovalue:undefined
});
this.updatacomponentDiddata();
this.props.showNotification(response.data.message);

@ -214,12 +214,15 @@ class InfosShixun extends Component{
</style>
<div className="white-panel edu-back-white pt20 pb20 clearfix ">
<li className={category ? " font-16 whitepanelyslli" : "active font-16 whitepanelyslli"}><a
href="javascript:void(0)"
onClick={() => this.changeCategory()} className="font-16 w32">全部</a></li>
<li className={category == "manage" ? "active font-16 whitepanelysllis" : "font-16 whitepanelysllis"}><a
onClick={() => this.changeCategory("manage")}
href="javascript:void(0)"
className={is_current ? "font-16 w66" : "font-16 w80"}>{is_current ? "我" : "TA"}管理的</a></li>
<li className={category == "study" ? "active font-16 whitepanelysllis" : "font-16 whitepanelysllis"}><a
onClick={() => this.changeCategory("study")}
href="javascript:void(0)"
className={is_current ? "font-16 w66" : "font-16 w80"}>{is_current ? "我" : "TA"}学习的</a></li>
</div>
<style>
@ -243,29 +246,29 @@ class InfosShixun extends Component{
category && category == "manage" && is_current &&
<div className="edu-back-white padding10-30 clearfix secondNavs bor-top-greyE">
<li className={status ? "whitepanelyslliss" : "active whitepanelyslliss"}>
<a onClick={() => this.changeStatus()} className="w32">全部</a></li>
<a onClick={() => this.changeStatus()} className="w32" href="javascript:void(0)">全部</a></li>
<li className={status == "editing" ? "active whitepanelysllisyt" : "whitepanelysllisyt"}><a
onClick={() => this.changeStatus("editing")} className="w60">编辑中</a></li>
onClick={() => this.changeStatus("editing")} className="w60" href="javascript:void(0)">编辑中</a></li>
<li className={status == "published" ? "active whitepanelysllisyt" : "whitepanelysllisyt"}><a
onClick={() => this.changeStatus("published")} className="w60">已发布</a></li>
onClick={() => this.changeStatus("published")} className="w60" href="javascript:void(0)">已发布</a></li>
<li className={status == "applying" ? "active whitepanelysllisyt" : "whitepanelysllisyt"}><a
onClick={() => this.changeStatus("applying")} className="w60">待审核</a></li>
onClick={() => this.changeStatus("applying")} className="w60" href="javascript:void(0)">待审核</a></li>
<li className={status == "publiced" ? "active whitepanelysllisyt" : "whitepanelysllisyt"}><a
onClick={() => this.changeStatus("publiced")} className="w60">已公开</a></li>
onClick={() => this.changeStatus("publiced")} className="w60" href="javascript:void(0)">已公开</a></li>
<li className={status == "closed" ? "active whitepanelysllisyt" : "whitepanelysllisyt"}><a
onClick={() => this.changeStatus("closed")} className="w60">已关闭</a></li>
onClick={() => this.changeStatus("closed")} className="w60" href="javascript:void(0)">已关闭</a></li>
</div>
}
{
category && category == "study" && is_current &&
<div className="edu-back-white padding10-30 clearfix secondNavs bor-top-greyE">
<li className={status ? "whitepanelyslliss" : "active whitepanelyslliss"}><a
<li className={status ? "whitepanelyslliss" : "active whitepanelyslliss"}><a href="javascript:void(0)"
onClick={() => this.changeStatus()}
className="w32">全部</a></li>
<li className={status == "processing" ? "active whitepanelysllisyt" : "whitepanelysllisyt"}><a
onClick={() => this.changeStatus("processing")} className="w60">未通关</a></li>
onClick={() => this.changeStatus("processing")} className="w60" href="javascript:void(0)">未通关</a></li>
<li className={status == "passed" ? "active whitepanelysllisyt" : "whitepanelysllisyt"}><a
onClick={() => this.changeStatus("passed")} className="w60">已通关</a></li>
onClick={() => this.changeStatus("passed")} className="w60" href="javascript:void(0)">已通关</a></li>
</div>
}
<div className=" clearfix font-12 " style={{

@ -56,6 +56,7 @@ const types = {
CLEAR_OJ_FOR_USER_REDUCER: 'CLEAR_OJ_FOR_USER_REDUCER', // 退出时清空 ojForUserReducer保存内容
ADD_OJ_LIKE_COUNT: 'ADD_OJ_LIKE_COUNT', // 增加点赞数
CHANGE_RECORD_PAGINATION_PAGE: 'CHANGE_RECORD_PAGINATION_PAGE', // 改变提交分页
UPDATE_OJ_FOR_USER_COMMENT_COUNT: 'UPDATE_OJ_FOR_USER_COMMENT_COUNT', // 更新 hack 中的评论数
/*** jupyter */
GET_JUPYTER_DATA_SETS: 'GET_JUPYTER_DATA_SETS', // jupyter 数据集
GET_JUPYTER_TPI_URL: 'GET_JUPYTER_TPI_URL', // 获取 jupyter url

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-23 10:53:25
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-25 10:55:27
* @LastEditTime : 2019-12-25 17:06:57
*/
import types from "./actionTypes";
@ -24,6 +24,11 @@ export const addComment = (identifier, comments) => {
if (res.status === 200) {
// 重新加载评论列表
dispatch(getCommentLists(identifier));
// 成功后,评论加一条
dispatch({
type: types.UPDATE_OJ_FOR_USER_COMMENT_COUNT,
payload: 'add' //
});
}
});
}
@ -57,6 +62,11 @@ export const replayChildComment = (identifier, comment) => {
if (res.status === 200) {
// 重新加载评论列表
dispatch(getCommentLists(identifier));
// 成功后,评论加一条
dispatch({
type: types.UPDATE_OJ_FOR_USER_COMMENT_COUNT,
payload: 'add' //
});
}
});
}
@ -69,6 +79,11 @@ export const deleteComment = (identifier, delId) => {
if (res.status === 200) {
// 重新加载评论列表
dispatch(getCommentLists(identifier));
// 成功后,评论加一条
dispatch({
type: types.UPDATE_OJ_FOR_USER_COMMENT_COUNT,
payload: 'minus' //
});
}
});
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:41:48
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-25 14:45:47
* @LastEditTime : 2019-12-25 17:09:53
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';
@ -211,6 +211,13 @@ const ojForUserReducer = (state = initialState, action) => {
...state,
pages: Object.assign({}, state.pages, { page: action.payload})
}
case types.UPDATE_OJ_FOR_USER_COMMENT_COUNT:
const {comments_count} = state.hack;
const _comments_count = action.payload === 'add' ? comments_count + 1 : comments_count - 1;
return {
...state,
hack: Object.assign({}, state.hack, { comments_count: _comments_count })
}
default:
return state;
}

Loading…
Cancel
Save