feat(selection): 支持选股结果服务端分页

This commit is contained in:
yuxuanhui
2026-08-10 11:09:23 +08:00
parent ed7bdda515
commit 3af97bf65d
16 changed files with 431 additions and 63 deletions
+15 -2
View File
@@ -2,6 +2,10 @@ import { createRootRoute, createRoute, Outlet } from "@tanstack/react-router"
import { AppLayout } from "@/app/layout/app-layout"
import { HomePage } from "@/features/home/pages/home-page"
import {
selectionCategoryFilters,
type SelectionCategoryFilter,
} from "@/features/selection/api/selection.types"
import { SelectionResultsPage } from "@/features/selection/pages/selection-results-page"
const rootRoute = createRootRoute({
@@ -28,8 +32,17 @@ const selectionRoute = createRoute({
const rawPageSize = Number(search.pageSize)
const page =
Number.isFinite(rawPage) && rawPage >= 1 ? Math.floor(rawPage) : 1
const pageSize = [5, 10, 20].includes(rawPageSize) ? rawPageSize : 10
return { page, pageSize }
const pageSize = [5, 10, 15].includes(rawPageSize) ? rawPageSize : 10
const searchValue =
typeof search.search === "string" ? search.search.slice(0, 100) : ""
const rawCategory =
typeof search.category === "string" ? search.category : "all"
const category: SelectionCategoryFilter = selectionCategoryFilters.includes(
rawCategory as SelectionCategoryFilter,
)
? (rawCategory as SelectionCategoryFilter)
: "all"
return { page, pageSize, search: searchValue, category }
},
component: SelectionResultsPage,
})