54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import { atom } from "recoil";
|
|
|
|
export const atomThemeMode = atom<"light" | "dark">({
|
|
key: "atomThemeMode",
|
|
default: "light",
|
|
});
|
|
|
|
export const atomClashPort = atom<number>({
|
|
key: "atomClashPort",
|
|
default: 0,
|
|
});
|
|
|
|
export const atomLogData = atom<ApiType.LogItem[]>({
|
|
key: "atomLogData",
|
|
default: [],
|
|
});
|
|
|
|
export const atomEnableLog = atom<boolean>({
|
|
key: "atomEnableLog",
|
|
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
|
|
export const atomLoadingCache = atom<Record<string, boolean>>({
|
|
key: "atomLoadingCache",
|
|
default: {},
|
|
});
|
|
|
|
// save update state
|
|
export const atomUpdateState = atom<boolean>({
|
|
key: "atomUpdateState",
|
|
default: false,
|
|
});
|
|
|
|
// current profile uid
|
|
export const atomCurrentProfile = atom<string>({
|
|
key: "atomCurrentProfile",
|
|
default: "",
|
|
});
|