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

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

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

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

@ -5,9 +5,11 @@ json.chooses do
json.type choose.category json.type choose.category
end end
end end
json.st @challenge.st
if @tab == 0 if @tab == 0
# 本关任务tab的编辑模式 # 本关任务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) json.tags @challenge.challenge_tags.map(&:name)
elsif @tab == 1 elsif @tab == 1
# 评测设置的编辑模式 # 评测设置的编辑模式

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

@ -1,6 +1,6 @@
# 导航栏公共数据 # 导航栏公共数据
json.partial! "challenges/top_common_data", shixun_identifier: @shixun.identifier 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) json.tags @challenge.challenge_tags.map(&:name)

@ -1,8 +1,12 @@
json.(@hack_user, :id, :status, :error_line, :error_msg, :expected_output, 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) :input, :output, :execute_time, :execute_memory, :created_at, :code)
json.language @hack_user.hack.language json.language @hack_user.hack.language
json.name @hack_user.hack.name json.name @hack_user.hack.name
json.myproblem_identifier @my_hack.identifier json.myproblem_identifier @my_hack.identifier
json.user do json.user do
json.partial! 'users/user', user: current_user json.partial! 'users/user', user: current_user
end
end end

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

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

@ -163,11 +163,10 @@ class TPMIndex extends Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (prevProps != this.props) { if (prevProps!=this.props) {
if (prevProps.user != this.props.user) {
let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings'; let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings';
let newTPMsettings=window.localStorage.getItem(getnewTPMsettings) let newTPMsettings=window.localStorage.getItem(getnewTPMsettings)
if(this.state.identity <4){
if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){ if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){
this.setState({ this.setState({
openknows:true openknows:true
@ -177,13 +176,11 @@ class TPMIndex extends Component {
openknows:false openknows:false
}) })
} }
}
}
} }
} }
componentDidMount = () => { getcomponentdidmount=()=>{
let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings'; let getnewTPMsettings=this.props.user&&this.props.user.user_id+'newTPMsettings';
let newTPMsettings=window.localStorage.getItem(getnewTPMsettings) let newTPMsettings=window.localStorage.getItem(getnewTPMsettings)
let id = this.props.match.params.shixunId; let id = this.props.match.params.shixunId;
@ -237,7 +234,6 @@ class TPMIndex extends Component {
if(response.data.identity <4){ if(response.data.identity <4){
if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){ if(newTPMsettings===undefined||newTPMsettings===false||newTPMsettings===null){
this.setState({ this.setState({
openknows:true openknows:true
@ -248,8 +244,6 @@ class TPMIndex extends Component {
}) })
} }
} }
} }
}).catch((error) => { }).catch((error) => {
this.setState({ this.setState({
@ -311,6 +305,10 @@ class TPMIndex extends Component {
}) })
this.getnavdatas() this.getnavdatas()
} }
componentDidMount = () => {
this.getcomponentdidmount()
}
componentWillUnmount = () => { componentWillUnmount = () => {
axios.interceptors.request.eject(this.tpmContentRequestInterceptor); axios.interceptors.request.eject(this.tpmContentRequestInterceptor);
@ -382,7 +380,6 @@ class TPMIndex extends Component {
let url = window.location.href; let url = window.location.href;
let flag = url.indexOf("add_file")>-1; let flag = url.indexOf("add_file")>-1;
return ( return (
<div className="newMain clearfix"> <div className="newMain clearfix">
{/*头部*/} {/*头部*/}
@ -447,7 +444,7 @@ class TPMIndex extends Component {
{ this.state.is_jupyter===false? <Menu.Item key="8" className={"competitionmr50"}> { this.state.is_jupyter===false? <Menu.Item key="8" className={"competitionmr50"}>
<span className={"tpmbannernavstyler"}>排行榜</span> <span className={"tpmbannernavstyler"}>排行榜</span>
</Menu.Item>:""} </Menu.Item>:""}
<span> {this.state.identity >4||this.state.identity===undefined ? "":<span>
<Popover <Popover
content={ content={
<pre className={"bannerpd201"}> <pre className={"bannerpd201"}>
@ -460,7 +457,7 @@ class TPMIndex extends Component {
visible={this.state.openknows} visible={this.state.openknows}
> >
</Popover> </Popover>
</span> </span>}
{this.state.identity >4||this.state.identity===undefined ? "": {this.state.identity >4||this.state.identity===undefined ? "":
<Menu.Item key="9" className={"competitionmr50"}> <Menu.Item key="9" className={"competitionmr50"}>

@ -172,7 +172,9 @@ class TPMRightSection extends Component {
<div className="recommend-list"> <div className="recommend-list">
{ {
TPMRightSectionData === undefined ? "" : TPMRightSectionData.paths === undefined ? "" : TPMRightSectionData.paths.map((i, k) => { TPMRightSectionData === undefined ? "" : TPMRightSectionData.paths === undefined ? "" : TPMRightSectionData.paths.map((i, k) => {
if(k>2){
}else{
return ( return (
<div className="recomments clearfix df" key={k}> <div className="recomments clearfix df" key={k}>
@ -206,6 +208,8 @@ class TPMRightSection extends Component {
</div> </div>
) )
}
}) })
} }
</div> </div>
@ -222,6 +226,9 @@ class TPMRightSection extends Component {
<div className="recommend-list"> <div className="recommend-list">
{ {
TPMRightSectionData === undefined ? "" : TPMRightSectionData.recommands === undefined ? "" : TPMRightSectionData.recommands.map((item, key) => { TPMRightSectionData === undefined ? "" : TPMRightSectionData.recommands === undefined ? "" : TPMRightSectionData.recommands.map((item, key) => {
if(key>2){
}else{
return ( return (
<div className="recomments clearfix df" key={key}> <div className="recomments clearfix df" key={key}>
<a href={"/shixuns/" + item.identifier + "/challenges"} target="_blank"> <a href={"/shixuns/" + item.identifier + "/challenges"} target="_blank">
@ -239,6 +246,8 @@ class TPMRightSection extends Component {
</div> </div>
</div> </div>
) )
}
}) })
} }
</div> </div>

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

@ -214,12 +214,15 @@ class InfosShixun extends Component{
</style> </style>
<div className="white-panel edu-back-white pt20 pb20 clearfix "> <div className="white-panel edu-back-white pt20 pb20 clearfix ">
<li className={category ? " font-16 whitepanelyslli" : "active font-16 whitepanelyslli"}><a <li className={category ? " font-16 whitepanelyslli" : "active font-16 whitepanelyslli"}><a
href="javascript:void(0)"
onClick={() => this.changeCategory()} className="font-16 w32">全部</a></li> onClick={() => this.changeCategory()} className="font-16 w32">全部</a></li>
<li className={category == "manage" ? "active font-16 whitepanelysllis" : "font-16 whitepanelysllis"}><a <li className={category == "manage" ? "active font-16 whitepanelysllis" : "font-16 whitepanelysllis"}><a
onClick={() => this.changeCategory("manage")} onClick={() => this.changeCategory("manage")}
href="javascript:void(0)"
className={is_current ? "font-16 w66" : "font-16 w80"}>{is_current ? "我" : "TA"}管理的</a></li> 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 <li className={category == "study" ? "active font-16 whitepanelysllis" : "font-16 whitepanelysllis"}><a
onClick={() => this.changeCategory("study")} onClick={() => this.changeCategory("study")}
href="javascript:void(0)"
className={is_current ? "font-16 w66" : "font-16 w80"}>{is_current ? "我" : "TA"}学习的</a></li> className={is_current ? "font-16 w66" : "font-16 w80"}>{is_current ? "我" : "TA"}学习的</a></li>
</div> </div>
<style> <style>
@ -243,29 +246,29 @@ class InfosShixun extends Component{
category && category == "manage" && is_current && category && category == "manage" && is_current &&
<div className="edu-back-white padding10-30 clearfix secondNavs bor-top-greyE"> <div className="edu-back-white padding10-30 clearfix secondNavs bor-top-greyE">
<li className={status ? "whitepanelyslliss" : "active whitepanelyslliss"}> <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 <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 <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 <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 <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 <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> </div>
} }
{ {
category && category == "study" && is_current && category && category == "study" && is_current &&
<div className="edu-back-white padding10-30 clearfix secondNavs bor-top-greyE"> <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()} onClick={() => this.changeStatus()}
className="w32">全部</a></li> className="w32">全部</a></li>
<li className={status == "processing" ? "active whitepanelysllisyt" : "whitepanelysllisyt"}><a <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 <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>
} }
<div className=" clearfix font-12 " style={{ <div className=" clearfix font-12 " style={{

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

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

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

Loading…
Cancel
Save