From e1d99d6cc32bb919005bbdeb71bdd683ebb862d9 Mon Sep 17 00:00:00 2001 From: Pine Date: Tue, 8 Sep 2026 23:13:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=A1=B5=E9=9D=A2=E5=88=87=E6=8D=A2=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=20+=20=E5=88=97=E8=A1=A8=E5=9B=BE=E7=89=87=E6=87=92=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - hall 大厅:5 个 tab Pane 改为懒常驻(首次进入挂载、之后 display 切换), 切换不再卸载重挂/重复请求/闪骨架,切回秒开 - mine 我的:useDidShow 刷新加 30s 节流,切 tab 回来不重复转圈 - booking/content:列表图片补 lazyLoad,滚动不再卡顿 - 重新构建 dist 产物 --- miniprogram/src/pages/booking/index.jsx | 2 +- miniprogram/src/pages/content/index.jsx | 2 +- miniprogram/src/pages/hall/index.jsx | 22 +++++++++++++++------- miniprogram/src/pages/mine/index.jsx | 12 ++++++++++-- 4 files changed, 27 insertions(+), 11 deletions(-) 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 () => {