2023-05-07 22:29:37 +00:00
|
|
|
import { Avatar, Box, Table, TableContainer, Tbody, Td, Text, Th, Thead, Tr, Wrap, WrapItem } from '@chakra-ui/react';
|
|
|
|
|
2023-05-08 15:07:47 +00:00
|
|
|
import { ProcessState, selectFiles } from './fileListingSlice';
|
2023-05-08 15:06:52 +00:00
|
|
|
import { useAppSelector } from '../../hooks';
|
2023-05-07 22:29:37 +00:00
|
|
|
|
|
|
|
export function FileListing() {
|
|
|
|
const files = useAppSelector(selectFiles);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<TableContainer>
|
|
|
|
<Table variant="striped">
|
|
|
|
<Thead>
|
|
|
|
<Tr>
|
|
|
|
<Th w="1%">封面</Th>
|
|
|
|
<Th>元信息</Th>
|
|
|
|
<Th>操作</Th>
|
|
|
|
</Tr>
|
|
|
|
</Thead>
|
|
|
|
<Tbody>
|
2023-05-08 14:54:00 +00:00
|
|
|
{Object.entries(files).map(([id, file]) => (
|
|
|
|
<Tr key={id}>
|
2023-05-07 22:29:37 +00:00
|
|
|
<Td>
|
|
|
|
{file.metadata.cover && <Avatar size="sm" name="专辑封面" src={file.metadata.cover} />}
|
|
|
|
{!file.metadata.cover && <Text>暂无封面</Text>}
|
|
|
|
</Td>
|
|
|
|
<Td>
|
|
|
|
<Box as="h4" fontWeight="semibold" mt="1">
|
|
|
|
{file.metadata.name || file.fileName}
|
|
|
|
</Box>
|
2023-05-08 15:07:47 +00:00
|
|
|
{file.state === ProcessState.COMPLETE && (
|
|
|
|
<>
|
|
|
|
<Text>专辑: {file.metadata.album}</Text>
|
|
|
|
<Text>艺术家: {file.metadata.artist}</Text>
|
|
|
|
<Text>专辑艺术家: {file.metadata.albumArtist}</Text>
|
|
|
|
</>
|
|
|
|
)}
|
2023-05-07 22:29:37 +00:00
|
|
|
</Td>
|
|
|
|
<Td>
|
|
|
|
<Wrap>
|
|
|
|
<WrapItem>播放</WrapItem>
|
|
|
|
<WrapItem>下载</WrapItem>
|
|
|
|
<WrapItem>删除</WrapItem>
|
|
|
|
</Wrap>
|
|
|
|
</Td>
|
|
|
|
</Tr>
|
|
|
|
))}
|
|
|
|
</Tbody>
|
|
|
|
</Table>
|
|
|
|
</TableContainer>
|
|
|
|
);
|
|
|
|
}
|