feat: add VITE_REDUX_STORAGE environment variable and update storage configuration

This commit is contained in:
2026-03-21 03:37:30 +08:00
parent 3735e902b0
commit 945d9dd2eb
4 changed files with 7 additions and 4 deletions
+2
View File
@@ -0,0 +1,2 @@
# Redux Persistence Location
VITE_REDUX_STORAGE=local
+1 -1
View File
@@ -45,7 +45,7 @@ export default function HeroLayout() {
</header> </header>
{/* Main Content Area */} {/* Main Content Area */}
<main className="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8 flex-grow"> <main className="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8 grow">
<div className="px-4 py-6 sm:px-0"> <div className="px-4 py-6 sm:px-0">
<Outlet /> <Outlet />
</div> </div>
+3 -2
View File
@@ -10,10 +10,11 @@ import {
PURGE, PURGE,
REGISTER, REGISTER,
} from "redux-persist" } from "redux-persist"
import storage from "redux-persist/lib/storage/session" // use session storage import createWebStorage from "redux-persist/es/storage/createWebStorage"
// import storage from "redux-persist/lib/storage" // use local storage
import authReducer from "./auth-slice" import authReducer from "./auth-slice"
const storage = createWebStorage(import.meta.env.VITE_REDUX_STORAGE ?? "local")
const persistConfig = { const persistConfig = {
key: "root", key: "root",
storage, storage,
+1 -1
View File
@@ -1,6 +1,6 @@
/// <reference types="vite/client" /> /// <reference types="vite/client" />
interface ImportMetaEnv { interface ImportMetaEnv {
// todo add env properties here readonly VITE_REDUX_STORAGE: "local" | "session"
} }
interface ImportMeta { interface ImportMeta {