diff --git a/src/components/Table/index.js b/src/components/Table/index.js index 7f6200e..00c440f 100644 --- a/src/components/Table/index.js +++ b/src/components/Table/index.js @@ -1,5 +1,4 @@ import { ProTable } from "@ant-design/pro-components"; -import dayjs from "dayjs"; import { useEffect, useMemo, useState } from "react"; import { throttle } from "throttle-debounce"; import { useAntdResizableHeader } from "use-antd-resizable-header"; @@ -7,38 +6,6 @@ import { getDataType, getIndexColumn } from "../../utils"; import "use-antd-resizable-header/dist/style.css"; import "./index.less"; -const CLEANUP_INTERVAL_DAYS = 10; // 清理间隔天数 -const LAST_CLEANUP_KEY = "tableLocalStorageLastCleanup"; // 最后清理时间存储key - -// 清理本地存储中特定后缀的key -function cleanupTableLocalStorage() { - const now = dayjs(); - const lastCleanupStr = localStorage.getItem(LAST_CLEANUP_KEY); - const lastCleanup = lastCleanupStr ? dayjs(lastCleanupStr) : null; - - // 如果没有上次清理时间或距离上次清理已超过10天 - if (!lastCleanup || now.diff(lastCleanup, "day") >= CLEANUP_INTERVAL_DAYS) { - // 查找并清理符合条件的key - const keysToRemove = []; - for (let i = 0; i < localStorage.length; i++) { - const key = localStorage.key(i); - if (key && (key.endsWith("#columnState") - || key.endsWith("#size") - || key.endsWith("#resizable"))) { - keysToRemove.push(key); - } - } - - // 删除匹配的key - keysToRemove.forEach((key) => { - localStorage.removeItem(key); - }); - - // 更新最后清理时间 - localStorage.setItem(LAST_CLEANUP_KEY, now.toISOString()); - } -} - function getPersistenceKey(index) { const basename = process.env?.app?.basename; const pathname = decodeURIComponent(window.location.pathname); @@ -52,11 +19,11 @@ function getPersistenceKey(index) { } function getTableSize(index) { - return window.localStorage.getItem(getPersistenceKey(index).size); + return window.sessionStorage.getItem(getPersistenceKey(index).size); } function setTableSize(value, index) { - return window.localStorage.setItem(getPersistenceKey(index).size, value); + return window.sessionStorage.setItem(getPersistenceKey(index).size, value); } function Table(props) { @@ -146,8 +113,6 @@ function Table(props) { }); } - cleanupTableLocalStorage(); - return () => { if (mutationObserver && resizeObserver && enabledResizer) { resizeObserver.unobserve(document.body);