mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
23 lines
604 B
JavaScript
23 lines
604 B
JavaScript
export default function reducer(state = {
|
|
lang: UiContext.codeLang,
|
|
code: localStorage.getItem(`${UserContext._id}/${UiContext.pdoc.domainId}/${UiContext.pdoc.docId}`) || UiContext.codeTemplate,
|
|
}, action) {
|
|
switch (action.type) {
|
|
case 'SCRATCHPAD_EDITOR_UPDATE_CODE': {
|
|
localStorage.setItem(`${UserContext._id}/${UiContext.pdoc.domainId}/${UiContext.pdoc.docId}`, action.payload);
|
|
return {
|
|
...state,
|
|
code: action.payload,
|
|
};
|
|
}
|
|
case 'SCRATCHPAD_EDITOR_SET_LANG': {
|
|
return {
|
|
...state,
|
|
lang: action.payload,
|
|
};
|
|
}
|
|
default:
|
|
return state;
|
|
}
|
|
}
|