@@ -125,10 +129,10 @@ const LeftPane = (props) => {
/>
-
+
{
出题者:
- {username}
+ {username}
diff --git a/public/react/src/redux/actions/actionTypes.js b/public/react/src/redux/actions/actionTypes.js
index deeb8fa93..0420a0af4 100644
--- a/public/react/src/redux/actions/actionTypes.js
+++ b/public/react/src/redux/actions/actionTypes.js
@@ -55,6 +55,7 @@ const types = {
CLICK_OPERATE_TYPE: 'CLICK_OPERATE_TYPE', // 点击类型
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', // 改变提交分页
/*** jupyter */
GET_JUPYTER_DATA_SETS: 'GET_JUPYTER_DATA_SETS', // jupyter 数据集
GET_JUPYTER_TPI_URL: 'GET_JUPYTER_TPI_URL', // 获取 jupyter url
@@ -74,7 +75,8 @@ const types = {
GET_COMMENT_LISTS: 'GET_COMMENT_LISTS', // 获取评论列表
REPLAY_CHILD_COMMENTS: 'REPLAY_CHILD_COMMENTS', // 子回复
DELETE_COMMENTS: 'DELETE_COMMENTS', // 删除评论
- SAVE_COMMENT_IDENTIFIER: 'SAVE_COMMENT_IDENTIFIER' // 评论时的identifier
+ SAVE_COMMENT_IDENTIFIER: 'SAVE_COMMENT_IDENTIFIER', // 评论时的identifier
+ CHANGE_COMMENT_PAGINATION_PARAMS: 'CHANGE_COMMENT_PAGINATION_PARAMS', // 改变分页
}
export default types;
diff --git a/public/react/src/redux/actions/comment.js b/public/react/src/redux/actions/comment.js
index 7927e3cd6..a247daf56 100644
--- a/public/react/src/redux/actions/comment.js
+++ b/public/react/src/redux/actions/comment.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-23 10:53:25
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-24 16:17:00
+ * @LastEditTime : 2019-12-25 10:55:27
*/
import types from "./actionTypes";
@@ -31,8 +31,12 @@ export const addComment = (identifier, comments) => {
// 获取评论列表
export const getCommentLists = (identifier) => {
- return (dispatch) => {
- fetchCommentLists(identifier).then(res => {
+ return (dispatch, getState) => {
+ const {pages: {limit, page}} = getState().commentReducer;
+ fetchCommentLists(identifier, {
+ limit,
+ page
+ }).then(res => {
console.log('获取评论列表: ====>>>>', res);
if (res.status === 200) {
const {data} = res;
@@ -112,3 +116,10 @@ export const showOrHideComment = (identifier, id, params) => {
}
}
+// 改变分页条件
+export const changePagination = (page) => {
+ return {
+ type: types.CHANGE_COMMENT_PAGINATION_PARAMS,
+ payload: page
+ };
+}
diff --git a/public/react/src/redux/actions/index.js b/public/react/src/redux/actions/index.js
index 197673f80..6086c2b32 100644
--- a/public/react/src/redux/actions/index.js
+++ b/public/react/src/redux/actions/index.js
@@ -49,7 +49,8 @@ import {
saveUserCodeForInterval,
saveEditorCodeForDetail,
saveOpacityType,
- clearOjForUserReducer
+ clearOjForUserReducer,
+ changeRecordPagination
// isUpdateCodeCtx
} from './ojForUser';
@@ -71,7 +72,8 @@ import {
replayChildComment,
deleteComment,
likeComment,
- showOrHideComment
+ showOrHideComment,
+ changePagination
} from './comment';
import {
@@ -134,6 +136,7 @@ export default {
saveEditorCodeForDetail,
saveOpacityType,
clearOjForUserReducer,
+ changeRecordPagination,
// jupyter
getJupyterTpiDataSet,
getJupyterTpiUrl,
@@ -155,4 +158,5 @@ export default {
deleteComment,
likeComment,
showOrHideComment,
+ changePagination
}
\ No newline at end of file
diff --git a/public/react/src/redux/actions/ojForUser.js b/public/react/src/redux/actions/ojForUser.js
index db2b7c300..783c41e6a 100644
--- a/public/react/src/redux/actions/ojForUser.js
+++ b/public/react/src/redux/actions/ojForUser.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:42:11
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-23 11:55:48
+ * @LastEditTime : 2019-12-25 14:27:58
*/
import types from "./actionTypes";
import { Base64 } from 'js-base64';
@@ -315,8 +315,12 @@ export const debuggerCode = (identifier,value, type) => {
// 获取提交记录
export const getUserCommitRecord = (identifier) => {
- return (dispatch) => {
- fetchUserCommitRecord(identifier).then(res => {
+ return (dispatch, getState) => {
+ const { pages: { limit, page } } = getState().ojForUserReducer;
+ fetchUserCommitRecord(identifier, {
+ limit,
+ page
+ }).then(res => {
const {status, data} = res;
if (status === 200) {
dispatch({
@@ -477,5 +481,10 @@ export const clearOjForUserReducer = () => {
};
}
+export const changeRecordPagination = (page) => {
+ return {
+ type: types.CHANGE_RECORD_PAGINATION_PAGE,
+ payload: page
+ }
+}
// 更新通知状态
-
diff --git a/public/react/src/redux/reducers/commentReducer.js b/public/react/src/redux/reducers/commentReducer.js
index cf56f1965..6fad98a55 100644
--- a/public/react/src/redux/reducers/commentReducer.js
+++ b/public/react/src/redux/reducers/commentReducer.js
@@ -6,7 +6,7 @@ import types from "../actions/actionTypes";
* @Github:
* @Date: 2019-12-23 10:35:31
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-23 14:51:42
+ * @LastEditTime : 2019-12-25 10:56:10
*/
const initialState = {
comments: {
@@ -14,8 +14,9 @@ const initialState = {
},
commentLists: {}, // 评论列表
pages: {
- limit: 20,
- page: 1
+ limit: 15,
+ page: 1,
+ total: 1
}
};
@@ -28,9 +29,17 @@ const commentReducer = (state = initialState, action) => {
...state
}
case types.GET_COMMENT_LISTS:
+ const {disscuss_count} = payload;
return {
...state,
- commentLists: Object.assign({}, payload)
+ commentLists: Object.assign({}, payload),
+ pages: Object.assign({}, state.pages, { total: disscuss_count })
+ }
+ case types.CHANGE_COMMENT_PAGINATION_PARAMS:
+ const _pages = Object.assign({}, state.pages, { page: payload });
+ return {
+ ...state,
+ pages: _pages
}
default:
return {
diff --git a/public/react/src/redux/reducers/ojForUserReducer.js b/public/react/src/redux/reducers/ojForUserReducer.js
index 0950d7442..8d82b8307 100644
--- a/public/react/src/redux/reducers/ojForUserReducer.js
+++ b/public/react/src/redux/reducers/ojForUserReducer.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:41:48
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-24 16:35:09
+ * @LastEditTime : 2019-12-25 14:45:47
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';
@@ -27,7 +27,12 @@ const initialState = {
notice: false, // 通知
hadCodeUpdate: false, // 更新代码
operateType: '', // 点击类型: 调度或提交
- comment_identifier: '' // 用户评论时使用的 identifier
+ comment_identifier: '', // 用户评论时使用的 identifier
+ pages: {
+ limit: 15,
+ page: 1,
+ total: 1
+ }
};
const ojForUserReducer = (state = initialState, action) => {
@@ -81,9 +86,11 @@ const ojForUserReducer = (state = initialState, action) => {
}
case types.COMMIT_RECORD:
+ const {records, records_count} = action.payload;
return {
...state,
- commitRecord: [...action.payload]
+ commitRecord: records,
+ pages: Object.assign({}, state.pages, { total: records_count })
}
case types.SAVE_USER_CODE:
let curCode = Base64.encode(action.payload);
@@ -199,6 +206,11 @@ const ojForUserReducer = (state = initialState, action) => {
...state,
hack: _hack
}
+ case types.CHANGE_RECORD_PAGINATION_PAGE:
+ return {
+ ...state,
+ pages: Object.assign({}, state.pages, { page: action.payload})
+ }
default:
return state;
}
diff --git a/public/react/src/services/commentService.js b/public/react/src/services/commentService.js
index 47eb347d2..2860a5b60 100644
--- a/public/react/src/services/commentService.js
+++ b/public/react/src/services/commentService.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-23 10:43:27
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-24 17:10:49
+ * @LastEditTime : 2019-12-25 10:50:24
*/
import axios from 'axios';
@@ -15,9 +15,9 @@ export async function fetchAddComment (identifier, params) {
}
// 获取评论列表
-export async function fetchCommentLists (identifier) {
+export async function fetchCommentLists (identifier, params) {
const url = `/problems/${identifier}/comments.json`;
- return axios.get(url);
+ return axios.get(url, {params});
}
// 添加子评论
diff --git a/public/react/src/services/ojService.js b/public/react/src/services/ojService.js
index aeeb212a2..8831f8c11 100644
--- a/public/react/src/services/ojService.js
+++ b/public/react/src/services/ojService.js
@@ -3,8 +3,8 @@
* @Author: tangjiang
* @Github:
* @Date: 2019-11-20 10:55:38
- * @LastEditors: tangjiang
- * @LastEditTime: 2019-12-20 10:10:53
+ * @LastEditors : tangjiang
+ * @LastEditTime : 2019-12-25 14:27:30
*/
import axios from 'axios';
@@ -70,10 +70,10 @@ export async function fetchUserProgramDetail (identifier) {
}
// 获取提交记录
-export async function fetchUserCommitRecord (identifier) {
+export async function fetchUserCommitRecord (identifier, params) {
console.log('identifier=====', identifier);
const url = `/myproblems/${identifier}/submit_records.json`;
- return axios.get(url);
+ return axios.get(url, { params });
}
// 获取提交记录详情