diff --git a/miniprogram/src/pages/booking/index.jsx b/miniprogram/src/pages/booking/index.jsx index 79023cd..c5fbc77 100644 --- a/miniprogram/src/pages/booking/index.jsx +++ b/miniprogram/src/pages/booking/index.jsx @@ -66,7 +66,7 @@ export default function Booking() { goDetail(e.id)}> {}} /> + lazyLoad onError={() => {}} /> {e.category ? {e.category} diff --git a/miniprogram/src/pages/content/index.jsx b/miniprogram/src/pages/content/index.jsx index 0848292..efd551f 100644 --- a/miniprogram/src/pages/content/index.jsx +++ b/miniprogram/src/pages/content/index.jsx @@ -41,7 +41,7 @@ function CardRow({ it, go }) { const img = it.cover_small || it.cover || (it.video ? it.video_cover : ''); return ( go(it.id)}> - {}} /> + {}} /> {m.label} {it.title} diff --git a/miniprogram/src/pages/hall/index.jsx b/miniprogram/src/pages/hall/index.jsx index 0462f9a..f22a594 100644 --- a/miniprogram/src/pages/hall/index.jsx +++ b/miniprogram/src/pages/hall/index.jsx @@ -51,11 +51,19 @@ export default function Hall() { const [ttype, setTtype] = useState(''); // 人才筛选 const [wt, setWt] = useState(''); // 岗位筛选 const [topic, setTopic] = useState(''); // 社区筛选 + // 懒常驻:tab 首次进入后保持挂载(display 切换),切回不重新请求、不闪骨架 + const [visited, setVisited] = useState({ tasks: true }); useEffect(() => { hallOverview().then(setStat).catch(() => {}); }, []); + const switchTab = (k) => { + if (k === tab) return; + setTab(k); + setVisited((v) => (v[k] ? v : { ...v, [k]: true })); + }; + const goPublish = () => { if (!isAuthed()) { Taro.showToast({ title: '请先登录', icon: 'none' }); return; } const url = PUBLISH_URL[tab]; @@ -75,7 +83,7 @@ export default function Hall() { {TABS.map((t) => ( - setTab(t.k)}>{t.l} + switchTab(t.k)}>{t.l} ))} {PUBLISH_URL[tab] && ( @@ -90,13 +98,13 @@ export default function Hall() { )} - {/* 内容区独立滚动 */} + {/* 内容区独立滚动;Pane 懒常驻:首次进入挂载后保持 display 切换,避免切 tab 重请求/闪骨架 */} - {tab === 'tasks' && } - {tab === 'talents' && } - {tab === 'jobs' && } - {tab === 'services' && } - {tab === 'community' && } + {visited.tasks && } + {visited.talents && } + {visited.jobs && } + {visited.services && } + {visited.community && } diff --git a/miniprogram/src/pages/mine/index.jsx b/miniprogram/src/pages/mine/index.jsx index 39bca76..2060b21 100644 --- a/miniprogram/src/pages/mine/index.jsx +++ b/miniprogram/src/pages/mine/index.jsx @@ -1,6 +1,6 @@ import { View, Text, Button, Input, Image, ScrollView } from '@tarojs/components'; import Taro from '@tarojs/taro'; -import { useState, useEffect } from 'react'; +import { useState, useEffect, useRef } from 'react'; import { useTabIndex } from '@/utils/tab'; import { isAuthed, getUser, logout, wxLogin, phoneLogin, bindPhone, sendCode, wxPhoneBind, updateProfile, getMe } from '@/utils/auth'; import { getMyBookings, parseIso } from '@/utils/booking'; @@ -57,7 +57,15 @@ export default function Mine() { } catch { /* 保留上次列表,避免重进闪空 */ } finally { setLoaded(true); } }; - Taro.useDidShow(() => { refresh(); }); + // 切 tab 回来 30s 内不重复拉取(首次必刷),避免"我的"每次进入都转圈 + const lastRefreshAt = useRef(0); + Taro.useDidShow(() => { + const now = Date.now(); + if (now - lastRefreshAt.current > 30000) { + lastRefreshAt.current = now; + refresh(); + } + }); /* 微信一键登录 */ const onWxLogin = async () => {