From f49506f106a19595e5d97ec448ae24d5970e86c7 Mon Sep 17 00:00:00 2001 From: guanbinrui Date: Wed, 6 Mar 2024 14:59:25 +0800 Subject: [PATCH] chore: store --- lingui.config.js | 12 +++++++++++- src/store/useThemeModeStore.ts | 29 +++++++++++++++++++++++++++++ tailwind.config.ts | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/store/useThemeModeStore.ts diff --git a/lingui.config.js b/lingui.config.js index 6a2a206..f26c659 100644 --- a/lingui.config.js +++ b/lingui.config.js @@ -11,7 +11,17 @@ const config = { catalogs: [ { path: 'src/locales/{locale}/messages', - include: ['src/app/**'], + include: [ + 'src/app/**', + 'src/configs/**', + 'src/components/**', + 'src/constants/**', + 'src/helpers/**', + 'src/hooks/**', + 'src/modals/**', + 'src/store/**', + 'src/services/**', + ], }, ], fallbackLocales: { diff --git a/src/store/useThemeModeStore.ts b/src/store/useThemeModeStore.ts new file mode 100644 index 0000000..90348de --- /dev/null +++ b/src/store/useThemeModeStore.ts @@ -0,0 +1,29 @@ +import { create } from 'zustand'; +import { persist } from 'zustand/middleware'; +import { immer } from 'zustand/middleware/immer'; + +import { createSelectors } from '@/helpers/createSelector.js'; +import type { ThemeMode } from '@/types/index.js'; + +interface ThemeModeState { + themeMode: ThemeMode; + setThemeMode: (mode: ThemeMode) => void; +} + +const useThemeModeStateBase = create( + persist( + immer((set) => ({ + themeMode: 'default', + setThemeMode: (mode) => { + set((state) => { + state.themeMode = mode; + }); + }, + })), + { + name: 'global-theme-state', + }, + ), +); + +export const useThemeModeStore = createSelectors(useThemeModeStateBase); diff --git a/tailwind.config.ts b/tailwind.config.ts index f94251b..29b2a19 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -2,9 +2,9 @@ import type { Config } from 'tailwindcss'; const config: Config = { content: [ + './src/app/**/*.{js,ts,jsx,tsx,mdx}', './src/pages/**/*.{js,ts,jsx,tsx,mdx}', './src/components/**/*.{js,ts,jsx,tsx,mdx}', - './src/app/**/*.{js,ts,jsx,tsx,mdx}', ], theme: { extend: {