From cbfa9a433a2e80e81fbec1e99b6f363209c27ea4 Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Fri, 27 Feb 2026 08:18:53 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AD=98=E5=82=A8=E5=88=97?= =?UTF-8?q?=E6=8B=96=E6=8B=BD=E4=BA=A7=E7=94=9F=E7=9A=84=E5=88=97=E5=AE=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/PcFundTable.jsx | 50 +++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/app/components/PcFundTable.jsx b/app/components/PcFundTable.jsx index 928e651..1d0ca6f 100644 --- a/app/components/PcFundTable.jsx +++ b/app/components/PcFundTable.jsx @@ -1,6 +1,6 @@ 'use client'; -import { useEffect, useMemo, useRef } from 'react'; +import { useEffect, useMemo, useRef, useState } from 'react'; import { AnimatePresence, motion } from 'framer-motion'; import { flexRender, @@ -45,6 +45,43 @@ export default function PcFundTable({ onHoldingProfitClick, refreshing = false, }) { + const getStoredColumnSizing = () => { + if (typeof window === 'undefined') return {}; + try { + const raw = window.localStorage.getItem('customSettings'); + if (!raw) return {}; + const parsed = JSON.parse(raw); + const sizing = parsed?.pcTableColumns; + if (!sizing || typeof sizing !== 'object') return {}; + return Object.fromEntries( + Object.entries(sizing).filter(([, value]) => Number.isFinite(value)), + ); + } catch { + return {}; + } + }; + + const persistColumnSizing = (nextSizing) => { + if (typeof window === 'undefined') return; + try { + const raw = window.localStorage.getItem('customSettings'); + const parsed = raw ? JSON.parse(raw) : {}; + const nextSettings = + parsed && typeof parsed === 'object' + ? { ...parsed, pcTableColumns: nextSizing } + : { pcTableColumns: nextSizing }; + window.localStorage.setItem('customSettings', JSON.stringify(nextSettings)); + } catch { } + }; + + const [columnSizing, setColumnSizing] = useState(() => { + const stored = getStoredColumnSizing(); + if (stored.actions) { + const { actions, ...rest } = stored; + return rest; + } + return stored; + }); const onRemoveFundRef = useRef(onRemoveFund); const onToggleFavoriteRef = useRef(onToggleFavorite); const onRemoveFromGroupRef = useRef(onRemoveFromGroup); @@ -343,6 +380,17 @@ export default function PcFundTable({ enableColumnPinning: true, enableColumnResizing: true, columnResizeMode: 'onChange', + onColumnSizingChange: (updater) => { + setColumnSizing((prev) => { + const next = typeof updater === 'function' ? updater(prev) : updater; + const { actions, ...rest } = next || {}; + persistColumnSizing(rest || {}); + return rest || {}; + }); + }, + state: { + columnSizing, + }, initialState: { columnPinning: { left: ['fundName'],