diff --git a/.vscodeignore b/.vscodeignore index 9c8c300..fdc05fd 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -3,6 +3,7 @@ out/test/** src/** packages/** +template/** .gitignore vsc-extension-quickstart.md **/tsconfig.json diff --git a/src/react/view/compress/Zip.tsx b/src/react/view/compress/Zip.tsx index 8dec1f1..e24f796 100644 --- a/src/react/view/compress/Zip.tsx +++ b/src/react/view/compress/Zip.tsx @@ -17,7 +17,7 @@ export default function Zip() { { name: '..', isDirectory: true, - entryName: dirPath.includes('/') ? dirPath.replace(/\/.+$/, '') : null, + entryName: dirPath.includes('/') ? dirPath.replace(/\/[^\/]+$/, '') : null, }, ...info.folderMap[dirPath].children ] : info.files) diff --git a/src/react/view/compress/components/FileItems.tsx b/src/react/view/compress/components/FileItems.tsx index 185ea69..be20399 100644 --- a/src/react/view/compress/components/FileItems.tsx +++ b/src/react/view/compress/components/FileItems.tsx @@ -1,7 +1,8 @@ import { DeleteOutlined, FileTextOutlined, FolderOutlined } from '@ant-design/icons'; import type { TableProps } from 'antd'; import { Button, Popconfirm, Spin, Table } from 'antd'; -import { useEffect, useRef, useState } from 'react'; +import { useRef } from 'react'; +import { useWindowSize } from '../../../util/reactUtils'; import { handler } from '../../../util/vscode'; import { FileInfo } from '../zipTypes'; @@ -25,7 +26,6 @@ const columns: TableProps['columns'] = [ width: 60, render: (_, entry) => ( <> - {/* 需要上色 */} ['columns'] = [ okText="Yes" cancelText="No" > - @@ -46,18 +45,13 @@ const columns: TableProps['columns'] = [ ]; export default function FileItems({ items }) { - const [height, setHeight] = useState(window.innerHeight - 100) + const [_, height] = useWindowSize(); const loading = useRef(null) loading.current = loading.current == null - useEffect(() => { - window.addEventListener('resize', () => { - setHeight(window.innerHeight - 100) - }) - }, []) return ( ) diff --git a/src/react/view/compress/components/Sidebar.tsx b/src/react/view/compress/components/Sidebar.tsx index 889431b..8d40274 100644 --- a/src/react/view/compress/components/Sidebar.tsx +++ b/src/react/view/compress/components/Sidebar.tsx @@ -1,12 +1,14 @@ +import { FileTextOutlined, FolderOutlined } from '@ant-design/icons'; import type { TreeDataNode } from 'antd'; import { Tree } from 'antd'; import React, { useEffect, useMemo, useRef, useState } from 'react'; +import { useWindowSize } from '../../../util/reactUtils'; import { FileInfo } from '../zipTypes'; -import { FileTextOutlined, FolderOutlined } from '@ant-design/icons'; export default function Sidebar({ name = '', items, currentDir, OnClickFolder }) { const rootKey = useRef('dbclient_zip_sidebar_root') const [expandedKeys, setExpandedKeys] = useState([rootKey.current]); + const [_, height] = useWindowSize(); const onExpand = (newExpandedKeys: React.Key[]) => { setExpandedKeys(newExpandedKeys); }; @@ -40,6 +42,7 @@ export default function Sidebar({ name = '', items, currentDir, OnClickFolder }) return (