diff --git a/src/container/listContainer/index.tsx b/src/container/listContainer/index.tsx
index 2970af0..db54b4c 100644
--- a/src/container/listContainer/index.tsx
+++ b/src/container/listContainer/index.tsx
@@ -13,6 +13,7 @@ import { useRef, useEffect } from "react";
const ListContainer = (props) => {
const {
loading,
+ isShowNoData,
data = [],
error,
reload,
@@ -84,7 +85,7 @@ const ListContainer = (props) => {
// 渲染列表
const renderList = (list) => {
// 请求数据为空
- if (!loading && (!list || list?.length === 0)) {
+ if (isShowNoData) {
return ;
}
diff --git a/src/game_pages/list/index.tsx b/src/game_pages/list/index.tsx
index f18492c..36b2bbc 100644
--- a/src/game_pages/list/index.tsx
+++ b/src/game_pages/list/index.tsx
@@ -58,6 +58,7 @@ const ListPage = () => {
distanceQuickFilter,
isShowInputCustomerNavBar,
pageOption,
+ isShowNoData,
} = listPageState || {};
// 防抖的滚动处理函数
@@ -376,6 +377,7 @@ const ListPage = () => {
data={matches}
recommendList={recommendList}
loading={loading}
+ isShowNoData={isShowNoData}
error={error}
reload={refreshMatches}
loadMoreMatches={loadMoreMatches}
diff --git a/src/game_pages/searchResult/index.tsx b/src/game_pages/searchResult/index.tsx
index da342fe..fcbbfd0 100644
--- a/src/game_pages/searchResult/index.tsx
+++ b/src/game_pages/searchResult/index.tsx
@@ -35,6 +35,7 @@ const SearchResult = () => {
recommendList,
filterCount,
filterOptions,
+ isShowNoData,
} = searchPageState || {};
const { statusNavbarHeightInfo } = useGlobalState() || {};
const { totalHeight } = statusNavbarHeightInfo || {};
@@ -166,6 +167,7 @@ const SearchResult = () => {
data={data}
recommendList={recommendList}
loading={loading}
+ isShowNoData={isShowNoData}
error={error}
reload={refreshMatches}
loadMoreMatches={loadMoreMatches}
diff --git a/src/store/listStore.ts b/src/store/listStore.ts
index 6cd3dd1..58675e9 100644
--- a/src/store/listStore.ts
+++ b/src/store/listStore.ts
@@ -60,6 +60,8 @@ const pageStateDefaultValue = {
gamesNum: 0,
// 是否还有更多数据
isHasMoreData: true,
+ // 是否展示无数据
+ isShowNoData: false,
}
// 列表页状态
@@ -187,40 +189,13 @@ export const useListStore = create()((set, get) => ({
state.updateCurrentPageState({
data: newData,
isHasMoreData,
+ isShowNoData: newData?.length === 0,
});
set({
error,
loading,
});
-
- if (state.isSearchResult) {
- // 更新搜索页状态
- // const currentData = state.searchPageState?.data || [];
- // const newData = isAppend ? [...currentData, ...(data || [])] : (data || []);
- // set({
- // searchPageState: {
- // ...state.searchPageState,
- // data: newData,
- // isHasMoreData,
- // },
- // error,
- // loading,
- // });
- } else {
- // 更新列表页状态
- // const currentData = state.listPageState?.data || [];
- // const newData = isAppend ? [...currentData, ...(data || [])] : (data || []);
- // set({
- // listPageState: {
- // ...state.listPageState,
- // data: newData,
- // isHasMoreData,
- // },
- // error,
- // loading,
- // });
- }
},
// 获取列表数据(常规搜索)
@@ -241,7 +216,6 @@ export const useListStore = create()((set, get) => ({
// 获取当前页面的距离筛选
const state = get();
const currentPageState = state.isSearchResult ? state.searchPageState : state.listPageState;
- console.log("===获取列表数据=当前页面状态:", state.isSearchResult, currentPageState);
const distanceQuickFilter = currentPageState?.distanceQuickFilter || {};
// 是否选择了智能排序
@@ -258,7 +232,6 @@ export const useListStore = create()((set, get) => ({
}
}
- console.log("===获取列表数据参数:", reqParams);
const resData = (await fetchFn(reqParams)) || {};
const { data = {}, code } = resData;
if (code !== 0) {
diff --git a/types/list/types.ts b/types/list/types.ts
index 67e924f..e647e61 100644
--- a/types/list/types.ts
+++ b/types/list/types.ts
@@ -38,6 +38,7 @@ export interface PageState {
}
gamesNum: number
isHasMoreData: boolean
+ isShowNoData: boolean
}
// 列表页状态