mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: add editor setting (#622)
This commit is contained in:
1 parent
3615d13ce2
commit
2dabe3194e
4 files changed
+100
-1
No files matched your search
@@ -11,11 +11,16 @@ export default function reducer(state = {
|
||||
visible: UiContext.canViewRecord && localStorage.getItem('scratchpad/records') === 'true',
|
||||
isLoading: false,
|
||||
},
|
||||
settings: {
|
||||
visible: false,
|
||||
config: JSON.parse(localStorage.getItem('editor.config') || '{}'),
|
||||
},
|
||||
isPosting: false,
|
||||
pretestWaitSec: 0,
|
||||
submitWaitSec: 0,
|
||||
lastTick: 0,
|
||||
activePage: 'problem',
|
||||
pendingCommand: '',
|
||||
}, action: any = {}) {
|
||||
switch (action.type) {
|
||||
case 'SCRATCHPAD_UI_SET_VISIBILITY': {
|
||||
@@ -40,6 +45,27 @@ export default function reducer(state = {
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_SETTING_UPDATE': {
|
||||
const { setting, value } = action.payload;
|
||||
const config = {
|
||||
...state.settings.config,
|
||||
[setting]: value,
|
||||
};
|
||||
localStorage.setItem('editor.config', JSON.stringify(config));
|
||||
return {
|
||||
...state,
|
||||
settings: {
|
||||
...state.settings,
|
||||
config,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_TRIGGER_EDITOR_COMMAND': {
|
||||
return {
|
||||
...state,
|
||||
pendingCommand: action.payload.command,
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_POST_PRETEST_PENDING':
|
||||
case 'SCRATCHPAD_POST_SUBMIT_PENDING': {
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user