Skip to content

Commit

Permalink
add luma download
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf-github-user committed Sep 6, 2024
1 parent 438df9b commit 01fe82e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/components/luma/task/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
{{ $t('luma.button.extend') }}
</el-button>
</el-tooltip>
<el-tooltip class="box-item" effect="dark" :content="$t('luma.message.downloadVideo')" placement="top-start">
<el-button
type="info"
size="small"
class="btn-action"
@click="onDownload($event, modelValue?.response?.video_url)"
>
{{ $t('luma.button.download') }}
</el-button>
</el-tooltip>
</div>
<el-alert :closable="false" class="mt-2 success">
<p class="description">
Expand Down Expand Up @@ -144,6 +154,12 @@ export default defineComponent({
video_url: response.video_url
});
},
onDownload(event: MouseEvent, video_url: string) {
event.stopPropagation();
console.log('on download');
// download url here
window.open(video_url, '_blank');
},
onReload(event: Event) {
const target = event.target as HTMLImageElement;
// append a random url query to existing url query, to force reload the image
Expand All @@ -165,13 +181,6 @@ export default defineComponent({
},
onOpenVideo(url: string) {
window.open(url, '_blank');
},
onDownload(url: string) {
// download image using javascript
const link = document.createElement('a');
link.href = url;
link.download = url.split('/').pop() as string;
link.click();
}
}
});
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/zh-CN/luma.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@
"message": "扩展视频",
"description": "扩展视频按钮文本"
},
"button.download": {
"message": "下载视频",
"description": "下载视频按钮文本"
},
"button.uploadStartImageUrl": {
"message": "上传图片",
"description": "上传二维码的按钮文本"
Expand Down Expand Up @@ -371,6 +375,10 @@
"message": "生成中...",
"description": "图像正在生成时的消息"
},
"message.downloadVideo": {
"message": "下载此视频",
"description": "图像正在生成时的消息"
},
"message.extendVideo": {
"message": "继续生成此视频",
"description": "图像正在生成时的消息"
Expand Down

0 comments on commit 01fe82e

Please sign in to comment.