"use client"; import React, { useEffect, useRef, useState } from "react"; import { Input, List, DotLoading, Toast, Image } from "antd-mobile"; import { useRouter } from "next/navigation"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleLeft } from "@fortawesome/free-solid-svg-icons"; import require from "@/utils/require"; import { debounce } from "@/utils/tools"; import Empty from "@/components/Empty"; const newDebounce = debounce(function (fn) { fn && fn(); }, 500); export default function Search() { const router = useRouter(); // 获取屏幕高度 // const scrollHeight = 600; const [searchValue, setSearchValue] = useState(""); const [loading, setLoading] = useState(false); const [streamers, setStreamers] = useState([]); // const [zones, setZones] = useState([]); useEffect(() => {}, []); const isNumeric = (str) => { return /^\d+$/.test(str); }; const getResult = async (value) => { console.log("searchValue", value); const isSearchInt = isNumeric(value); let api = ""; let querryParams = ""; if (isSearchInt) { api = "/api/streamer/list_ext_fuzzily_by_user_id"; querryParams = { user_id: parseInt(value, 10) }; } else { api = "/api/streamer/list_ext_fuzzily_by_name"; querryParams = { name: value }; } try { setLoading(true); const data = await require("POST", api, { body: { ...querryParams, offset: 0, limit: 20, }, }); if (data.ret === -1) { Toast.show({ icon: "fail", content: data.msg, position: "top", }); return; } // if (!ignore) { // const zonesData = data.data.list.filter((item) => item.zones.length > 0); setStreamers(data.data.list); // setZones(zonesData); // } setLoading(false); } catch (error) { console.error(error); } }; return (
{ setSearchValue(""); }} > 清空
)}空间
{(() => { let arr = streamers?.filter( (streamer) => streamer.zones.length > 0 ); return arr?.map((item) => (用户
{streamers.map((item) => ({data?.bio}
Ta的动态· {data?.zones[0].zone_moment_count > 99 ? "99+" : data?.zones[0].zone_moment_count} {data?.zones[0].image_count > 0 && ` | 图片·${ data?.zones[0].image_count > 99 ? "99+" : data?.zones[0].image_count }`} {data?.zones[0].video_count > 0 && ` | 视频·${ data?.zones[0].video_count > 99 ? "99+" : data?.zones[0].video_count }`}