列表骨架屏

This commit is contained in:
juguohong
2025-08-24 19:58:00 +08:00
parent cda1a4b7cc
commit 58bacb3a47
13 changed files with 532 additions and 249 deletions

View File

@@ -2,12 +2,13 @@ import { Popup } from "@nutui/nutui-react-taro";
import Range from "../../components/Range";
import Bubble from "../../components/Bubble";
import styles from "./filterPopup.module.scss";
import TitleComponent from "src/components/Title";
import TitleComponent from "@/components/Title";
import { Button } from "@nutui/nutui-react-taro";
import { Image } from "@tarojs/components";
import img from "../../config/images";
import { useListStore } from "src/store/listStore";
import {FilterPopupProps} from '../../../types/list/types'
import { FilterPopupProps } from "../../../types/list/types";
import GamePlayType from "@/components/GamePlayType";
const FilterPopup = (props: FilterPopupProps) => {
const {
@@ -20,7 +21,7 @@ const FilterPopup = (props: FilterPopupProps) => {
visible,
onClose,
} = props;
const store = useListStore() || {};
const { timeBubbleData, locationOptions } = store;
@@ -82,6 +83,8 @@ const FilterPopup = (props: FilterPopupProps) => {
name="site"
/>
</div>
{/* 玩法 */}
<GamePlayType />
{/* 按钮 */}
<div className={styles.filterPopupBtnWrapper}>
<Button

View File

@@ -1,4 +1,5 @@
import ListItem from "../../components/ListItem";
import ListCard from "../../components/ListCard";
import ListCardSkeleton from "../../components/ListCardSkeleton";
import List from "../../components/List";
import Menu from "../../components/Menu";
import CityFilter from "../../components/CityFilter";
@@ -9,7 +10,6 @@ import { useEffect } from "react";
import Taro from "@tarojs/taro";
import { useListStore } from "../../store/listStore";
import { View } from "@tarojs/components";
import "./index.scss";
const ListPage = () => {
// 从 store 获取数据和方法
@@ -82,21 +82,6 @@ const ListPage = () => {
}
}, [error, clearError]);
// 格式化时间显示
const formatRefreshTime = (timeString: string | null) => {
if (!timeString) return "";
const date = new Date(timeString);
const now = new Date();
const diff = now.getTime() - date.getTime();
const minutes = Math.floor(diff / 60000);
if (minutes < 1) return "刚刚";
if (minutes < 60) return `${minutes}分钟前`;
const hours = Math.floor(minutes / 60);
if (hours < 24) return `${hours}小时前`;
return date.toLocaleDateString();
};
// 加载状态显示
if (loading && matches.length === 0) {
return (
@@ -230,40 +215,18 @@ const ListPage = () => {
<View className={styles.listContentWrapper}>
{/* 列表内容 */}
<List>
{matches.map((match, index) => (
<ListItem key={match.id || index} {...match} />
))}
{!loading &&
matches.length > 0 &&
matches.map((match, index) => (
<ListCard key={match.id || index} {...match} />
))}
</List>
{/* 空状态 */}
{!loading && matches.length === 0 && (
<div
style={{
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
height: "200px",
fontSize: "14px",
color: "#999",
}}
>
<div style={{ marginBottom: "10px" }}></div>
<button
onClick={() => fetchMatches()}
style={{
padding: "8px 16px",
fontSize: "12px",
color: "#fff",
backgroundColor: "#007aff",
border: "none",
borderRadius: "4px",
}}
>
</button>
</div>
)}
{loading &&
new Array(10).fill(0).map(() => {
return <ListCardSkeleton />;
})}
</View>
</View>
);