Skip to content

Commit

Permalink
修复zip细节问题
Browse files Browse the repository at this point in the history
  • Loading branch information
cweijan committed Mar 29, 2024
1 parent 0d986f2 commit e958698
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
out/test/**
src/**
packages/**
template/**
.gitignore
vsc-extension-quickstart.md
**/tsconfig.json
Expand Down
2 changes: 1 addition & 1 deletion src/react/view/compress/Zip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 4 additions & 10 deletions src/react/view/compress/components/FileItems.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -25,7 +26,6 @@ const columns: TableProps<FileInfo>['columns'] = [
width: 60,
render: (_, entry) => (
<>
{/* 需要上色 */}
<Popconfirm
title="Delete the file"
description="Are you sure to delete this file?"
Expand All @@ -35,7 +35,6 @@ const columns: TableProps<FileInfo>['columns'] = [
okText="Yes"
cancelText="No"
>

<Button type="primary" danger>
<DeleteOutlined />
</Button>
Expand All @@ -46,18 +45,13 @@ const columns: TableProps<FileInfo>['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 (
<Spin spinning={loading.current}>
<Table columns={columns} rowKey="entryName" dataSource={items}
style={{ height, overflow: 'auto' }} pagination={false} expandable={{ showExpandColumn: false }}
style={{ height: height - 50, overflow: 'auto' }} pagination={false} expandable={{ showExpandColumn: false }}
/>
</Spin>
)
Expand Down
5 changes: 4 additions & 1 deletion src/react/view/compress/components/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -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<React.Key[]>([rootKey.current]);
const [_, height] = useWindowSize();
const onExpand = (newExpandedKeys: React.Key[]) => {
setExpandedKeys(newExpandedKeys);
};
Expand Down Expand Up @@ -40,6 +42,7 @@ export default function Sidebar({ name = '', items, currentDir, OnClickFolder })
return (
<div>
<Tree
style={{ height: height - 50, overflow: 'auto' }}
onExpand={onExpand}
expandedKeys={expandedKeys}
autoExpandParent={true}
Expand Down

0 comments on commit e958698

Please sign in to comment.