Skip to content

Commit d3070b4

Browse files
viva-jinyiclaude
andcommitted
[refactor] Replace inline URL construction with getAssetUrl utility
Refactored downloadAsset and downloadMultipleAssets functions to use the shared getAssetUrl utility instead of duplicating URL construction logic. Changes: - Added getAssetUrl import from assetUrlUtil - Replaced inline api.apiURL construction in downloadAsset (lines 74-77) - Replaced inline api.apiURL construction in downloadMultipleAssets (lines 112-115) Benefits: - Removes code duplication (2 occurrences) - Centralizes URL construction logic - Improves maintainability - Ensures consistent asset type handling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 65c6e1e commit d3070b4

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/platform/assets/composables/useMediaAssetActions.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { getOutputAssetMetadata } from '../schemas/assetMetadataSchema'
1515
import { useAssetsStore } from '@/stores/assetsStore'
1616
import { useDialogStore } from '@/stores/dialogStore'
1717
import { getAssetType } from '../utils/assetTypeUtil'
18+
import { getAssetUrl } from '../utils/assetUrlUtil'
1819
import { createAnnotatedPath } from '@/utils/createAnnotatedPath'
1920
import { detectNodeTypeFromFilename } from '@/utils/loaderNodeUtil'
2021
import { isResultItemType } from '@/utils/typeGuardUtil'
@@ -67,13 +68,10 @@ export function useMediaAssetActions() {
6768

6869
// In cloud, use preview_url directly (from cloud storage)
6970
// In OSS/localhost, use the /view endpoint
70-
if (isCloud && asset.src) {
71-
downloadUrl = asset.src
71+
if (isCloud && asset.preview_url) {
72+
downloadUrl = asset.preview_url
7273
} else {
73-
const assetType = asset.tags?.[0] || 'output'
74-
downloadUrl = api.apiURL(
75-
`/view?filename=${encodeURIComponent(filename)}&type=${assetType}`
76-
)
74+
downloadUrl = getAssetUrl(asset)
7775
}
7876

7977
downloadFile(downloadUrl, filename)
@@ -111,10 +109,7 @@ export function useMediaAssetActions() {
111109
if (isCloud && asset.preview_url) {
112110
downloadUrl = asset.preview_url
113111
} else {
114-
const assetType = asset.tags?.[0] || 'output'
115-
downloadUrl = api.apiURL(
116-
`/view?filename=${encodeURIComponent(filename)}&type=${assetType}`
117-
)
112+
downloadUrl = getAssetUrl(asset)
118113
}
119114
downloadFile(downloadUrl, filename)
120115
})

0 commit comments

Comments
 (0)