feat: 即使不存在歌曲元数据,也展示默认的“暂无封面”占位图片

This commit is contained in:
HouKunLin 2023-05-17 09:39:33 +08:00
parent 4341203c08
commit aaefffbb8b

View File

@ -18,6 +18,7 @@ import {
import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice'; import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice';
import { useCallback, useRef } from 'react'; import { useCallback, useRef } from 'react';
import { useAppDispatch } from '~/hooks'; import { useAppDispatch } from '~/hooks';
import coverSvgUrl from '~/assets/no-cover.svg';
interface FileRowProps { interface FileRowProps {
id: string; id: string;
@ -83,14 +84,12 @@ export function FileRow({ id, file }: FileRowProps) {
> >
<GridItem area="cover"> <GridItem area="cover">
<Center w="160px" h="160px" m="auto"> <Center w="160px" h="160px" m="auto">
{metadata && (
<Image <Image
objectFit="cover" objectFit="cover"
src={metadata.cover} src={metadata?.cover}
alt={`"${metadata.album}" 的专辑封面`} alt={`${metadata?.album} 的专辑封面`}
fallbackSrc={'/assets/no-cover.svg'} fallbackSrc={coverSvgUrl}
/> />
)}
</Center> </Center>
</GridItem> </GridItem>
<GridItem area="title"> <GridItem area="title">