From 13a9028c6641e8e7dad18d48dc3ad4dad32b7e87 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Sat, 19 Sep 2026 14:23:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(worker-platform):=20=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=AF=84=E5=8D=96=E4=B8=8E=E6=88=91=E7=9A=84=E5=AF=84=E5=8D=96?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=94=AF=E6=8C=81=E5=81=9C=E7=95=99=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=B8=8E=E7=AD=9B=E9=80=89=E6=8C=81=E4=B9=85=E5=8C=96?= =?UTF-8?q?=E8=AE=B0=E5=BF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 在 WorkerConsignmentPage 中通过 localStorage 与 URL 查询参数实时双向同步 activeTab 与 recordFilter; 2. 打手在切换发布寄卖/我的寄卖或筛选状态后,刷新页面或切换路由返回时自动恢复上次停留界面; 3. 提交寄卖成功后自动切换并记住跳转到我的寄卖-待审核列表。 --- .../pages/worker/WorkerConsignmentPage.tsx | 67 ++++++++++++++++++- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/apps/frontend/src/pages/worker/WorkerConsignmentPage.tsx b/apps/frontend/src/pages/worker/WorkerConsignmentPage.tsx index a6d4c69f..c3649d93 100644 --- a/apps/frontend/src/pages/worker/WorkerConsignmentPage.tsx +++ b/apps/frontend/src/pages/worker/WorkerConsignmentPage.tsx @@ -74,6 +74,41 @@ const BRILLIANCE_OPTIONS = [ type RecordFilter = 'all' | 'reviewing' | 'active' | 'finished' const DEPOSIT_TIP_KEY = 'worker-consignment-deposit-tip-seen' +const ACTIVE_TAB_STORAGE_KEY = 'worker_consignment_active_tab' +const RECORD_FILTER_STORAGE_KEY = 'worker_consignment_record_filter' + +function getInitialActiveTab(): 'publish' | 'records' { + if (typeof window === 'undefined') return 'publish' + try { + const params = new URLSearchParams(window.location.search) + const tabParam = params.get('tab') + if (tabParam === 'records' || tabParam === 'publish') { + return tabParam + } + const saved = window.localStorage.getItem(ACTIVE_TAB_STORAGE_KEY) + return saved === 'records' ? 'records' : 'publish' + } catch { + return 'publish' + } +} + +function getInitialRecordFilter(): RecordFilter { + if (typeof window === 'undefined') return 'all' + try { + const params = new URLSearchParams(window.location.search) + const filterParam = params.get('filter') as RecordFilter | null + if (filterParam && ['all', 'reviewing', 'active', 'finished'].includes(filterParam)) { + return filterParam + } + const saved = window.localStorage.getItem(RECORD_FILTER_STORAGE_KEY) as RecordFilter | null + if (saved && ['all', 'reviewing', 'active', 'finished'].includes(saved)) { + return saved + } + } catch { + // ignore + } + return 'all' +} /** 赠送冷却倒计时刷新间隔:30 秒足够展示,不需要秒级跳动 */ const COOLDOWN_TICK_MS = 30_000 @@ -81,8 +116,36 @@ const COOLDOWN_TICK_MS = 30_000 export default function WorkerConsignmentPage() { const isMobile = useIsMobile() const { message, modal } = App.useApp() - const [activeTab, setActiveTab] = useState<'publish' | 'records'>('publish') - const [recordFilter, setRecordFilter] = useState('all') + const [activeTab, setActiveTabState] = useState<'publish' | 'records'>(getInitialActiveTab) + const [recordFilter, setRecordFilterState] = useState(getInitialRecordFilter) + + const setActiveTab = (tab: 'publish' | 'records') => { + setActiveTabState(tab) + if (typeof window !== 'undefined') { + try { + window.localStorage.setItem(ACTIVE_TAB_STORAGE_KEY, tab) + const url = new URL(window.location.href) + url.searchParams.set('tab', tab) + window.history.replaceState({}, '', url.toString()) + } catch { + // ignore + } + } + } + + const setRecordFilter = (filter: RecordFilter) => { + setRecordFilterState(filter) + if (typeof window !== 'undefined') { + try { + window.localStorage.setItem(RECORD_FILTER_STORAGE_KEY, filter) + const url = new URL(window.location.href) + url.searchParams.set('filter', filter) + window.history.replaceState({}, '', url.toString()) + } catch { + // ignore + } + } + } const [screenshots, setScreenshots] = useState([]) const [submitting, setSubmitting] = useState(false) const [evidenceItem, setEvidenceItem] = useState(null)