自定列表导航栏

This commit is contained in:
juguohong
2025-08-24 23:56:03 +08:00
parent 58bacb3a47
commit 01d3acb6d9
20 changed files with 393 additions and 85 deletions

61
src/store/global.ts Normal file
View File

@@ -0,0 +1,61 @@
import { create } from 'zustand'
import { getNavbarHeight } from '@/utils/getNavbarHeight'
interface GlobalState {
location: Record<string, any>
getLocationLoading: boolean
getLocationText: string
statusNavbarHeightInfo: {
statusBarHeight: number
navbarHeight: number
totalHeight: number
}
}
interface GlobalActions {
updateState: (payload: Record<string, any>) => void
getNavbarHeightInfo: () => void
}
// 完整的 Store 类型
type GlobalStore = GlobalState & GlobalActions
// 创建 store
export const useGlobalStore = create<GlobalStore>()((set, get) => ({
// 位置信息
location: {},
// 正在获取位置信息
getLocationLoading: false,
// 获取位置信息文本
getLocationText: '定位中...',
// 状态栏和导航栏高度信息
statusNavbarHeightInfo: {
statusBarHeight: 0,
navbarHeight: 0,
totalHeight: 0
},
// 获取导航栏高度信息
getNavbarHeightInfo: () => {
const { statusBarHeight, navbarHeight } = getNavbarHeight();
set({
statusNavbarHeightInfo: {
statusBarHeight,
navbarHeight,
totalHeight: statusBarHeight + navbarHeight
}
})
},
// 更新store数据
updateState: (payload: Record<string, any>) => {
const state = get();
set({
...state,
...(payload || {})
})
}
}))
// 导出便捷的 hooks
export const useGlobalState = () => useGlobalStore((state) => state)

View File

@@ -9,8 +9,8 @@ const defaultFilterOptions: IFilterOptions = {
location: '', // 位置
time: '', // 时间
ntrp: [1.0, 5.0], // NTRP 水平区间
site: '', // 场地类型
wanfa: '', // 玩法
court_type: '', // 场地类型
game_play: '', // 玩法
};
const defaultDistance = 'all'; // 默认距离
@@ -65,6 +65,16 @@ export const useListStore = create<TennisStore>()((set, get) => ({
{ id: 2, label: "室外", value: "2" },
{ id: 3, label: "半室外", value: "3" },
],
// 玩法数据
gamePlayOptions: [
{ id: 1, label: "不限", value: "不限" },
{ id: 2, label: "单打", value: "单打" },
{ id: 3, label: "双打", value: "双打" },
{ id: 4, label: "娱乐", value: "娱乐" },
{ id: 5, label: "拉球", value: "拉球" },
],
// 球局数量
gamesNum: 124,
// 获取比赛数据
fetchMatches: async (params) => {
@@ -106,6 +116,7 @@ export const useListStore = create<TennisStore>()((set, get) => ({
// 更新综合筛选项
updateFilterOptions: (payload: Record<string, any>) => {
console.log('===更新综合筛选项', payload)
const preFilterOptions = get()?.filterOptions || {}
const filterOptions = { ...preFilterOptions, ...payload }
const filterCount = Object.values(filterOptions).filter(Boolean).length