diff --git a/src/pages/Devtools/StoragePanel/index.less b/src/pages/Devtools/StoragePanel/index.less index febd98b2..7bb81e5a 100644 --- a/src/pages/Devtools/StoragePanel/index.less +++ b/src/pages/Devtools/StoragePanel/index.less @@ -1,7 +1,11 @@ .storage-panel { position: relative; + display: flex; + flex-direction: column; + justify-content: flex-end; + gap: 8px; &__layout { - height: 100%; + flex: 1; } &__sider { position: absolute; diff --git a/src/pages/Devtools/StoragePanel/index.tsx b/src/pages/Devtools/StoragePanel/index.tsx index fc2b8c22..3537bae0 100644 --- a/src/pages/Devtools/StoragePanel/index.tsx +++ b/src/pages/Devtools/StoragePanel/index.tsx @@ -1,11 +1,11 @@ import type { SpyStorage } from '@huolala-tech/page-spy'; -import { Layout, Menu, Table, Tooltip } from 'antd'; -import { useMemo, useRef, useState } from 'react'; +import { Button, Col, Layout, Menu, Row, Table, Tooltip } from 'antd'; +import { useMemo, useState } from 'react'; import ReactJsonView from '@huolala-tech/react-json-view'; import './index.less'; import { useSocketMessageStore } from '@/store/socket-message'; import { Resizable } from 'react-resizable'; -import { HolderOutlined } from '@ant-design/icons'; +import { HolderOutlined, ReloadOutlined } from '@ant-design/icons'; import { useTranslation } from 'react-i18next'; import { capitalize } from 'lodash-es'; @@ -14,8 +14,12 @@ const { Column } = Table; export const StoragePanel = () => { const { t } = useTranslation(); - const storageMsg = useSocketMessageStore((state) => state.storageMsg); - const [activeTab, setActiveTab] = useState('local'); + const [storageMsg, refresh] = useSocketMessageStore((state) => [ + state.storageMsg, + state.refresh, + ]); + const [activeTab, setActiveTab] = + useState('localStorage'); const data = useMemo(() => { return Object.values(storageMsg[activeTab]); }, [activeTab, storageMsg]); @@ -28,6 +32,19 @@ export const StoragePanel = () => { const [detailInfo, setDetailInfo] = useState(''); return (
+ + + + + + + { selectedKeys={[activeTab]} onSelect={({ key }) => setActiveTab(key as SpyStorage.DataType)} items={[ - { key: 'local', label: 'Local Storage' }, - { key: 'session', label: 'Session Storage' }, + { key: 'localStorage', label: 'Local Storage' }, + { key: 'sessionStorage', label: 'Session Storage' }, { key: 'cookie', label: 'Cookie' }, ]} /> @@ -45,6 +62,7 @@ export const StoragePanel = () => { > >; initSocket: (url: string) => void; - clearRecord: (key: SpyMessage.MessageType) => void; - refresh: (key: SpyMessage.MessageType) => void; + clearRecord: (key: string) => void; + refresh: (key: string) => void; } export const useSocketMessageStore = create((set, get) => ({ @@ -49,8 +49,8 @@ export const useSocketMessageStore = create((set, get) => ({ location: null, }, storageMsg: { - local: {}, - session: {}, + localStorage: {}, + sessionStorage: {}, cookie: {}, }, initSocket: (room: string) => { @@ -161,7 +161,7 @@ export const useSocketMessageStore = create((set, get) => ({ } }); }, - clearRecord: (key: SpyMessage.MessageType) => { + clearRecord: (key: string) => { switch (key) { case 'console': set({ consoleMsg: [] }); @@ -173,7 +173,7 @@ export const useSocketMessageStore = create((set, get) => ({ break; } }, - refresh: (key: SpyMessage.MessageType) => { + refresh: (key: string) => { const socket = get().socket; if (!socket) return; socket.unicastMessage({