feat(selection): 支持选股结果服务端分页
This commit is contained in:
@@ -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,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user