refactor: move typed Redux hooks from src/store/hooks.ts to src/hooks/store.ts
Also update GitHub repository URLs and labels in hero layout.
This commit is contained in:
@@ -26,7 +26,7 @@ This is a Chinese-language SPA for browsing and managing Delta Force guide ("《
|
|||||||
- `EmptyLayout` (minimal) for `/login`
|
- `EmptyLayout` (minimal) for `/login`
|
||||||
All page components are lazy-loaded via `createBrowserRouter` + `lazy()`.
|
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`.
|
**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`.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useDispatch, useSelector } from "react-redux"
|
import { useDispatch, useSelector } from "react-redux"
|
||||||
import type { AppDispatch, RootState } from "./index"
|
import type { AppDispatch, RootState } from "@/store"
|
||||||
|
|
||||||
export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
|
export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
|
||||||
export const useAppSelector = useSelector.withTypes<RootState>()
|
export const useAppSelector = useSelector.withTypes<RootState>()
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
LoginOutlined,
|
LoginOutlined,
|
||||||
} from "@ant-design/icons"
|
} from "@ant-design/icons"
|
||||||
import { AuthApi } from "@/api"
|
import { AuthApi } from "@/api"
|
||||||
import { useAppDispatch, useAppSelector } from "@/store/hooks"
|
import { useAppDispatch, useAppSelector } from "@/hooks/store"
|
||||||
import { clearCurrentUser } from "@/store/auth-slice"
|
import { clearCurrentUser } from "@/store/auth-slice"
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useState } from "react"
|
|||||||
import { useNavigate } from "react-router-dom"
|
import { useNavigate } from "react-router-dom"
|
||||||
import { App, Button, Card, Form, Input, Typography } from "antd"
|
import { App, Button, Card, Form, Input, Typography } from "antd"
|
||||||
import { AuthApi } from "@/api"
|
import { AuthApi } from "@/api"
|
||||||
import { useAppDispatch } from "@/store/hooks"
|
import { useAppDispatch } from "@/hooks/store"
|
||||||
import { setCurrentUser } from "@/store/auth-slice"
|
import { setCurrentUser } from "@/store/auth-slice"
|
||||||
import { LoginRequest } from "@/types"
|
import { LoginRequest } from "@/types"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user