mirror of
https://git.um-react.app/um/um-react.git
synced 2026-11-28 16:16:59 +00:00
feat: integrate platform capabilities for enhanced download management
- Refactored `DownloadAll` component to utilize platform capabilities for download types, improving flexibility in handling various download methods. - Introduced `buildEnabledDownloadModes` function to determine available download modes based on user settings and platform capabilities. - Updated `FileRow` and `PanelGeneral` components to conditionally render download options based on platform capabilities. - Added tests for new functionalities in `DownloadAll`, `FileRow`, and `PanelGeneral` to ensure correct behavior under different platform conditions. - Enhanced error handling for unsupported download methods, providing clearer feedback to users.
This commit is contained in:
1 parent
b5fdc8ebbe
commit
d424837e66
17 files changed
+417
-178
No files matched your search
@@ -2,6 +2,7 @@ import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice
|
||||
import { useAppDispatch } from '~/hooks';
|
||||
import { FileError } from './FileError';
|
||||
import classNames from 'classnames';
|
||||
import { usePlatform } from '~/platform/PlatformContext';
|
||||
|
||||
interface FileRowProps {
|
||||
id: string;
|
||||
@@ -10,7 +11,9 @@ interface FileRowProps {
|
||||
|
||||
export function FileRow({ id, file }: FileRowProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const { capabilities } = usePlatform();
|
||||
const isDecrypted = file.state === ProcessState.COMPLETE;
|
||||
const showDownload = capabilities.downloadTypes.length > 0;
|
||||
|
||||
const decryptedName = file.cleanName + '.' + file.ext;
|
||||
|
||||
@@ -32,18 +35,20 @@ export function FileRow({ id, file }: FileRowProps) {
|
||||
</div>
|
||||
|
||||
<div className="card-actions justify-end">
|
||||
<a
|
||||
href={file.decrypted}
|
||||
download={decryptedName}
|
||||
title={`下载: ${decryptedName}`}
|
||||
className={classNames('btn', {
|
||||
'btn-primary': file.decrypted,
|
||||
'cursor-not-allowed pointer-events-none': !file.decrypted,
|
||||
})}
|
||||
data-testid="audio-download"
|
||||
>
|
||||
下载
|
||||
</a>
|
||||
{showDownload && (
|
||||
<a
|
||||
href={file.decrypted}
|
||||
download={decryptedName}
|
||||
title={`下载: ${decryptedName}`}
|
||||
className={classNames('btn', {
|
||||
'btn-primary': file.decrypted,
|
||||
'cursor-not-allowed pointer-events-none': !file.decrypted,
|
||||
})}
|
||||
data-testid="audio-download"
|
||||
>
|
||||
下载
|
||||
</a>
|
||||
)}
|
||||
<button type="button" className="btn btn-error" onClick={() => dispatch(deleteFile({ id }))}>
|
||||
删除
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user