diff --git a/CLAUDE.md b/CLAUDE.md index 7d92072..d5a966d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -26,7 +26,7 @@ This is a Chinese-language SPA for browsing and managing Delta Force guide ("《 - `EmptyLayout` (minimal) for `/login` All page components are lazy-loaded via `createBrowserRouter` + `lazy()`. -**State** (`src/store/`): Redux Toolkit with two slices — `auth` (current user) and `firearms` (paginated firearm list). State is persisted to `localStorage` or `sessionStorage` based on the `VITE_REDUX_STORAGE` env var. Use typed hooks from `src/store/hooks.ts` (`useAppDispatch`, `useAppSelector`). +**State** (`src/store/`): Redux Toolkit with two slices — `auth` (current user) and `firearms` (paginated firearm list). State is persisted to `localStorage` or `sessionStorage` based on the `VITE_REDUX_STORAGE` env var. Use typed hooks from `src/hooks/store.ts` (`useAppDispatch`, `useAppSelector`). **API layer** (`src/api/`): Axios instance (`src/shared/web-client/`) with base URL from `VITE_API_BASE_URL`, 10s timeout, and credentials. API modules: `FirearmApi`, `ModificationApi`, `TagApi`, `AuthApi`. diff --git a/src/store/hooks.ts b/src/hooks/store.ts similarity index 77% rename from src/store/hooks.ts rename to src/hooks/store.ts index 42426c6..f9a3047 100644 --- a/src/store/hooks.ts +++ b/src/hooks/store.ts @@ -1,6 +1,5 @@ import { useDispatch, useSelector } from "react-redux" -import type { AppDispatch, RootState } from "./index" +import type { AppDispatch, RootState } from "@/store" export const useAppDispatch = useDispatch.withTypes() export const useAppSelector = useSelector.withTypes() - diff --git a/src/layout/hero-layout/index.tsx b/src/layout/hero-layout/index.tsx index 8c73d7c..5d66202 100644 --- a/src/layout/hero-layout/index.tsx +++ b/src/layout/hero-layout/index.tsx @@ -9,7 +9,7 @@ import { LoginOutlined, } from "@ant-design/icons" import { AuthApi } from "@/api" -import { useAppDispatch, useAppSelector } from "@/store/hooks" +import { useAppDispatch, useAppSelector } from "@/hooks/store" import { clearCurrentUser } from "@/store/auth-slice" import { useState } from "react" diff --git a/src/page/login/index.tsx b/src/page/login/index.tsx index 7ede3bf..c077fe5 100644 --- a/src/page/login/index.tsx +++ b/src/page/login/index.tsx @@ -2,7 +2,7 @@ import { useState } from "react" import { useNavigate } from "react-router-dom" import { App, Button, Card, Form, Input, Typography } from "antd" import { AuthApi } from "@/api" -import { useAppDispatch } from "@/store/hooks" +import { useAppDispatch } from "@/hooks/store" import { setCurrentUser } from "@/store/auth-slice" import { LoginRequest } from "@/types"