fix: save enable log on localstorage

This commit is contained in:
GyDi
2022-09-24 19:03:14 +08:00
parent 37d8a563c0
commit 0cf89467e3
4 changed files with 28 additions and 40 deletions

View File

@@ -17,7 +17,21 @@ export const atomLogData = atom<ApiType.LogItem[]>({
export const atomEnableLog = atom<boolean>({
key: "atomEnableLog",
default: true,
effects: [
({ setSelf, onSet }) => {
const key = "enable-log";
setSelf(localStorage.getItem(key) !== "false");
onSet((newValue, _, isReset) => {
if (isReset) {
localStorage.removeItem(key);
} else {
localStorage.setItem(key, newValue.toString());
}
});
},
],
});
// save the state of each profile item loading