refactor: introducing use{Module}Store instead of service (#768)

* refactor: introducing `useEditorStore`

* refactor: update

* chore: update
This commit is contained in:
boojack
2022-12-18 15:25:18 +08:00
committed by GitHub
parent bd00fa798d
commit ef621a444f
63 changed files with 911 additions and 886 deletions

View File

@ -1,15 +1,16 @@
import { Option, Select } from "@mui/joy";
import { useTranslation } from "react-i18next";
import { globalService, userService } from "../services";
import { useAppSelector } from "../store";
import { useGlobalStore, useUserStore } from "../store/module";
import Icon from "./Icon";
const appearanceList = ["system", "light", "dark"];
const AppearanceSelect = () => {
const user = useAppSelector((state) => state.user.user);
const appearance = useAppSelector((state) => state.global.appearance);
const { t } = useTranslation();
const globalStore = useGlobalStore();
const userStore = useUserStore();
const { appearance } = globalStore.state;
const user = userStore.state.user;
const getPrefixIcon = (apperance: Appearance) => {
const className = "w-4 h-auto";
@ -24,9 +25,9 @@ const AppearanceSelect = () => {
const handleSelectChange = async (appearance: Appearance) => {
if (user) {
await userService.upsertUserSetting("appearance", appearance);
await userStore.upsertUserSetting("appearance", appearance);
}
globalService.setAppearance(appearance);
globalStore.setAppearance(appearance);
};
return (