mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
ui: scratchpad sidebar
This commit is contained in:
1 parent
981f8a4b9d
commit
e3a5543d9f
14 files changed
+239
-65
No files matched your search
@@ -3,12 +3,14 @@ import ui from './ui';
|
||||
import editor from './editor';
|
||||
import pretest from './pretest';
|
||||
import records from './records';
|
||||
import state from './state';
|
||||
|
||||
const reducer = combineReducers({
|
||||
ui,
|
||||
editor,
|
||||
pretest,
|
||||
records,
|
||||
state,
|
||||
});
|
||||
|
||||
export default reducer;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
export default function reducer(state = {}, action) {
|
||||
if (action.type === 'SCRATCHPAD_STATE_UPDATE') {
|
||||
const { key, value } = action.payload;
|
||||
return {
|
||||
...state,
|
||||
[key]: value,
|
||||
};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
@@ -11,10 +11,6 @@ export default function reducer(state = {
|
||||
: false,
|
||||
size: 200,
|
||||
},
|
||||
sidebar: {
|
||||
visible: false,
|
||||
size: 100,
|
||||
},
|
||||
records: {
|
||||
visible: UiContext.canViewRecord && localStorage.getItem('scratchpad/records') === 'true',
|
||||
size: 100,
|
||||
@@ -23,6 +19,7 @@ export default function reducer(state = {
|
||||
isPosting: false,
|
||||
waitSec: 0,
|
||||
isWaiting: false,
|
||||
activePage: 'problem',
|
||||
}, action) {
|
||||
switch (action.type) {
|
||||
case 'SCRATCHPAD_UI_CHANGE_SIZE': {
|
||||
@@ -122,6 +119,12 @@ export default function reducer(state = {
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_SWITCH_TO_PAGE': {
|
||||
return {
|
||||
...state,
|
||||
activePage: action.payload,
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user