diff --git a/src/components/FollowUserCard/index.tsx b/src/components/FollowUserCard/index.tsx index 22d3a49..864eb00 100644 --- a/src/components/FollowUserCard/index.tsx +++ b/src/components/FollowUserCard/index.tsx @@ -12,9 +12,10 @@ interface FollowUserCardProps { user: FollowUser; tabKey: TabType; onFollowChange?: (userId: number, isFollowing: boolean) => void; + onBlockSuccess?: (userId: number) => void; } -const FollowUserCard: React.FC = ({ user, tabKey, onFollowChange }) => { +const FollowUserCard: React.FC = ({ user, tabKey, onFollowChange, onBlockSuccess }) => { const [isProcessing, setIsProcessing] = useState(false); // 防御性检查 @@ -62,6 +63,8 @@ const FollowUserCard: React.FC = ({ user, tabKey, onFollowC title: '不会再为您推荐该用户', icon: 'none' }); + // 通知父组件屏蔽成功,需要刷新列表 + onBlockSuccess?.(user.id); } } catch (error) { console.error('删除推荐人员失败:', error); diff --git a/src/main_pages/components/ListPageContent.module.scss b/src/main_pages/components/ListPageContent.module.scss index 304023b..76cd39f 100644 --- a/src/main_pages/components/ListPageContent.module.scss +++ b/src/main_pages/components/ListPageContent.module.scss @@ -13,7 +13,7 @@ flex-direction: column; align-items: center; justify-content: center; - // gap: 24px; + gap: 24px; .tips { display: flex; @@ -56,7 +56,7 @@ // border-radius: 12px; // border: 1px solid rgba(0, 0, 0, 0.06); // background: lightgray 50% / cover no-repeat; - // box-shadow: 0 4px 36px 0 rgba(0, 0, 0, 0.16); + box-shadow: 0 4px 36px 0 rgba(0, 0, 0, 0.16); } .qrcodeTip { @@ -67,7 +67,7 @@ font-style: normal; font-weight: 400; line-height: normal; - margin-top: -30px; + margin-top: 0px; } } } @@ -94,7 +94,7 @@ // background-color: #fafafa; // 使用 margin-top 负值来控制可见性,保持元素高度不变,筛选项位置固定 transition: margin-top 0.25s cubic-bezier(0.4, 0, 0.2, 1), - opacity 0.2s ease-out; + opacity 0.2s ease-out; padding: 10px 15px 10px 15px; // 统一边距:上下10px 左右15px box-sizing: border-box; overflow: hidden; @@ -190,5 +190,4 @@ .guideBarHighZIndex { z-index: 900 !important; // 正常状态,保持较高层级 -} - +} \ No newline at end of file diff --git a/src/main_pages/components/ListPageContent.tsx b/src/main_pages/components/ListPageContent.tsx index a6d9ed5..cc97209 100644 --- a/src/main_pages/components/ListPageContent.tsx +++ b/src/main_pages/components/ListPageContent.tsx @@ -114,7 +114,7 @@ const ListPageContent: React.FC = ({ // 使用 ref 保存最新的状态值,避免依赖项变化导致函数重新创建 const showSearchBarRef = useRef(showSearchBar); const isShowInputCustomerNavBarRef = useRef(isShowInputCustomerNavBar); - + useEffect(() => { showSearchBarRef.current = showSearchBar; isShowInputCustomerNavBarRef.current = isShowInputCustomerNavBar; @@ -124,7 +124,7 @@ const ListPageContent: React.FC = ({ const handleScrollViewScroll = useCallback( (e: any) => { - + const currentScrollTop = e?.detail?.scrollTop || 0; const lastScrollTop = lastScrollTopRef.current; const currentTime = Date.now(); @@ -199,18 +199,11 @@ const ListPageContent: React.FC = ({ getCities(); getCityQrCode(); getDistricts(); // 新增:获取行政区列表 - - // 2. 移除 fetchUserInfo 调用,因为父组件 main_pages/index.tsx 已经在授权成功后调用了 - // 这里直接使用 store 中的用户信息即可 - - // 3. 延迟执行:获取位置信息(可能较慢,不阻塞首屏) - requestAnimationFrame(() => { - requestAnimationFrame(() => { - getLocation().catch((error) => { - console.error('获取位置信息失败:', error); - }); - }); + + getLocation().catch((error) => { + console.error('获取位置信息失败:', error); }); + }, []); useEffect(() => { @@ -268,7 +261,7 @@ const ListPageContent: React.FC = ({ } finally { // 使用 requestAnimationFrame 替代 setTimeout(0),性能更好 requestAnimationFrame(() => { - setRefreshing(false); + setRefreshing(false); }); } }; @@ -305,7 +298,7 @@ const ListPageContent: React.FC = ({ updateFilterOptions(params); }; - const handleSearchChange = () => {}; + const handleSearchChange = () => { }; const handleDistanceOrQuickChange = (name, value) => { updateDistanceQuickFilter({ @@ -354,6 +347,7 @@ const ListPageContent: React.FC = ({ className={styles.qrcode} src={item.qr_code_url} mode="widthFix" + showMenuByLongpress onClick={() => { saveImage(item.qr_code_url); }} @@ -374,7 +368,7 @@ const ListPageContent: React.FC = ({ // 判定是否显示"暂无球局"页面 // 条件:省份不是上海 或 (已加载完成且球局数量为0) - const shouldShowNoGames = province !== "上海" ; + const shouldShowNoGames = province !== "上海"; return ( <> @@ -400,9 +394,8 @@ const ListPageContent: React.FC = ({ )} = ({ - { } }; + // 处理屏蔽成功 + const handle_block_success = (user_id: number) => { + // 从当前列表中移除被屏蔽的用户 + set_user_lists(prev => { + const new_lists = { ...prev }; + if (new_lists[active_tab] && Array.isArray(new_lists[active_tab])) { + new_lists[active_tab] = new_lists[active_tab].filter(user => user.id !== user_id); + } + return new_lists; + }); + // 重新加载当前标签页的列表 + load_user_list(active_tab, true); + }; + // 初始化加载 useEffect(() => { try { @@ -293,6 +307,7 @@ const FollowPage: React.FC = () => { user={user} tabKey={active_tab} onFollowChange={handle_follow_change} + onBlockSuccess={handle_block_success} /> )) || []}