From 26294c47af784b26cd3f29d91bd43e96bdfa60f7 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 6 Dec 2019 15:18:01 +0800 Subject: [PATCH 1/3] add user reduder --- public/react/src/redux/actions/actionTypes.js | 3 +- public/react/src/redux/actions/user.js | 16 ++++++++++ public/react/src/redux/reducers/index.js | 5 ++- .../react/src/redux/reducers/userReducer.js | 31 +++++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 public/react/src/redux/actions/user.js create mode 100644 public/react/src/redux/reducers/userReducer.js diff --git a/public/react/src/redux/actions/actionTypes.js b/public/react/src/redux/actions/actionTypes.js index f6bc7f3b9..4850fc794 100644 --- a/public/react/src/redux/actions/actionTypes.js +++ b/public/react/src/redux/actions/actionTypes.js @@ -46,7 +46,8 @@ const types = { UPDATE_TEST_AND_VALIDATE: 'UPDATE_TEST_AND_VALIDATE', // 更新测试用例及验证值 UPDATE_OPEN_TESTCASE_INDEX: 'UPDATE_OPEN_TESTCASE_INDEX', // 更新测试用例索引 GET_COMMIT_RECORD_DETAIL_BY_ID: 'GET_COMMIT_RECORD_DETAIL_BY_ID', // 根据id号获取提交记录详情 - RESTORE_INITIAL_CODE: 'RESTORE_INITIAL_CODE' // 恢复初始代码 + RESTORE_INITIAL_CODE: 'RESTORE_INITIAL_CODE', // 恢复初始代码 + SAVE_USER_INFO: 'SAVE_USER_INFO', // 只在用户信息 } export default types; diff --git a/public/react/src/redux/actions/user.js b/public/react/src/redux/actions/user.js new file mode 100644 index 000000000..1b7c331c6 --- /dev/null +++ b/public/react/src/redux/actions/user.js @@ -0,0 +1,16 @@ +/* + * @Description: + * @Author: tangjiang + * @Github: + * @Date: 2019-12-06 15:09:22 + * @LastEditors: tangjiang + * @LastEditTime: 2019-12-06 15:15:00 + */ +import types from './actionTypes'; + +// 获取用户信息 +export default function getUserInfo () { + return (dispatch) => { + // 调用获取用户信息, 如果没有登录直接调用登录,成功后保存当前用户信息 + } +} \ No newline at end of file diff --git a/public/react/src/redux/reducers/index.js b/public/react/src/redux/reducers/index.js index 2f60bf8e3..620905459 100644 --- a/public/react/src/redux/reducers/index.js +++ b/public/react/src/redux/reducers/index.js @@ -12,10 +12,13 @@ import ojFormReducer from './ojFormReducer'; import ojListReducer from './ojListReducer'; import ojForUserReducer from './ojForUserReducer'; import commonReducer from './commonReducer'; +import userReducer from './userReducer'; + export default combineReducers({ testReducer, ojFormReducer, ojListReducer, ojForUserReducer, - commonReducer + commonReducer, + userReducer }); diff --git a/public/react/src/redux/reducers/userReducer.js b/public/react/src/redux/reducers/userReducer.js new file mode 100644 index 000000000..0e2718be9 --- /dev/null +++ b/public/react/src/redux/reducers/userReducer.js @@ -0,0 +1,31 @@ +/* + * @Description: 保存信息数据 + * @Author: tangjiang + * @Github: + * @Date: 2019-12-06 15:09:29 + * @LastEditors: tangjiang + * @LastEditTime: 2019-12-06 15:16:15 + */ +import types from "../actions/actionTypes"; + +const initialState = { + userInfo: {} // 当前登录用户信息 +}; + +const userReducer = (state = initialState, action) => { + switch (action.type) { + case types.SAVE_USER_INFO: + return { + userInfo: action.payload + } + default: + return { + ...state + } + } +} + +export default userReducer; +export { + userReducer +}; From 33c4ca049b1dc2037eeca64ce6b5b5361d80add3 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 6 Dec 2019 17:18:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/constants/index.js | 21 +++++- .../components/controlSetting/index.scss | 8 +++ .../components/monacoSetting/index.js | 66 ++++++++++++++----- .../components/myMonacoEditor/index.js | 24 +++++-- .../newOrEditTask/leftpane/editorTab/index.js | 6 +- .../modules/developer/studentStudy/index.js | 4 +- .../developer/studentStudy/rightpane/index.js | 16 ++++- public/react/src/redux/actions/ojForUser.js | 16 ++++- 8 files changed, 128 insertions(+), 33 deletions(-) diff --git a/public/react/src/constants/index.js b/public/react/src/constants/index.js index abae13db0..3e7aceab0 100644 --- a/public/react/src/constants/index.js +++ b/public/react/src/constants/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-20 23:10:48 * @LastEditors: tangjiang - * @LastEditTime: 2019-11-28 14:41:42 + * @LastEditTime: 2019-12-06 15:53:27 */ const CONST = { jcLabel: { @@ -20,8 +20,25 @@ const CONST = { title: '代码格式', type: 'select', content: [ + { + text: '显示风格', + type: 'style', + value: [ + { + key: 'dark', + text: '黑色背景', + value: 'dark' + }, + { + key: 'light', + text: '白色背景', + value: 'light' + } + ] + }, { - text: '字体大小', + text: '字体大小', + type: 'font', value: [ { key: 1, diff --git a/public/react/src/modules/developer/components/controlSetting/index.scss b/public/react/src/modules/developer/components/controlSetting/index.scss index 0c7f726f5..4a2c221c1 100644 --- a/public/react/src/modules/developer/components/controlSetting/index.scss +++ b/public/react/src/modules/developer/components/controlSetting/index.scss @@ -67,6 +67,14 @@ font-size: 12px; } } + + .ant-drawer-body{ + height: calc(100vh - 120px); + overflow-y: auto; + } + .ant-drawer-content{ + top: 120px; + } } diff --git a/public/react/src/modules/developer/components/monacoSetting/index.js b/public/react/src/modules/developer/components/monacoSetting/index.js index ea8448fa0..a101819e0 100644 --- a/public/react/src/modules/developer/components/monacoSetting/index.js +++ b/public/react/src/modules/developer/components/monacoSetting/index.js @@ -4,26 +4,54 @@ * @Github: * @Date: 2019-11-25 17:50:33 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-04 11:26:02 + * @LastEditTime: 2019-12-06 16:51:48 */ -import React from 'react'; -import { Select } from 'antd'; - -const { Option } = Select; +import React, { useState } from 'react'; +import { fromStore, toStore } from 'educoder'; +// import { Select } from 'antd'; +// const { Option } = Select; const SettingDrawer = (props) => { /** * title: '', // 一级标题 * type: '', // 类型: 目录 select 和 文本 * content: [] // 显示的内容 { text: '' , value: string | [{ key: 1, value: '', text: '' }] } */ + + const [fontSize, setFontSize] = useState(() => { + return +fromStore('oj_fontSize') || 14; + }); + const [theme, setTheme] = useState(() => { + return fromStore('oj_theme') || 'dark'; + }); + const {title, type = 'label', content = [] } = props; - const handleFontSize = (e) => { - const {onChangeFontSize} = props; - const value = e.target.value; - console.log('fong size change: ', value); + // 字体改变时, 方法全名: handleChangeXX, XX 为指定的类型; + const { + onChangeFontSize, + onChangeTheme + } = props; + const handleChangeFont = (value) => { + setFontSize(value); + toStore('oj_fontSize', value); onChangeFontSize && onChangeFontSize(value); } + // 风格改变时 + const handleChangeStyle = (value) => { + setTheme(value); + toStore('oj_theme', value); + onChangeTheme && onChangeTheme(value); + } + + const handleSelectChange = (e, type) => { + const value = e.target.value; + if (type === 'font') { + handleChangeFont(value); + } + if (type === 'style') { + handleChangeStyle(value); + } + } const renderCtx = (title, content = [], type = 'label') => { const result = content.map((ctx, index) => { @@ -38,19 +66,25 @@ const SettingDrawer = (props) => { ); } else if (Array.isArray(value)) { + const defaultValue = ctx.type === 'font' ? fontSize : theme; + console.log('++', defaultValue); if (type === 'select') { - const child = ctx.value.map((opt, i) => ( - - )); + const child = ctx.value.map((opt, i) => { + return ( + + )}); renderResult = (