Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix suno use #148

Merged
merged 5 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix suno use",
"packageName": "@acedatacloud/nexior",
"email": "[email protected]",
"dependentChangeType": "patch"
}
5 changes: 5 additions & 0 deletions src/components/common/TopHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
<el-menu-item v-if="site?.features?.qrart?.enabled" v-t="'index.title.qrart'" index="/qrart"></el-menu-item>
<el-menu-item v-if="site?.features?.suno?.enabled" v-t="'index.title.suno'" index="/suno"></el-menu-item>
<el-menu-item v-if="site?.features?.luma?.enabled" v-t="'index.title.luma'" index="/luma"></el-menu-item>
<el-menu-item
v-if="site?.features?.headshots?.enabled"
v-t="'index.title.headshots'"
index="/headshots"
></el-menu-item>
</el-sub-menu>
<el-menu-item
v-t="'common.nav.apiPlatform'"
Expand Down
56 changes: 43 additions & 13 deletions src/components/suno/task/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@
<el-button v-if="audio?.audio_url && audio?.video_url" size="small" round @click="onExtend($event, audio)">{{
$t('suno.button.extend')
}}</el-button>
<el-tooltip effect="dark" :content="$t('suno.button.download')" placement="top">
<font-awesome-icon
v-if="audio?.audio_url"
icon="fa-solid fa-download"
class="icon icon-download"
@click="onDownload($event, audio?.audio_url)"
/>
</el-tooltip>
<el-tooltip effect="dark" :content="$t('suno.button.video')" placement="top">
<font-awesome-icon
v-if="audio?.video_url"
Expand All @@ -53,6 +45,27 @@
@click="onPreview($event, audio?.video_url)"
/>
</el-tooltip>
<el-dropdown>
<span class="el-dropdown-link">
<el-tooltip effect="dark" :content="$t('suno.button.download')" placement="top">
<font-awesome-icon
v-if="audio?.audio_url || audio?.video_url"
icon="fa-solid fa-download"
class="icon icon-download"
/>
</el-tooltip>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item v-if="audio?.video_url" @click="onDownload($event, audio?.video_url)">
{{ $t('suno.button.download_video') }}
</el-dropdown-item>
<el-dropdown-item v-if="audio?.audio_url" @click="onDownload($event, audio?.audio_url)">
{{ $t('suno.button.download_audio') }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
</div>
Expand All @@ -62,9 +75,10 @@
import { defineComponent } from 'vue';
import { useFormatDuring } from '@/utils/number';
import { ISunoAudio, ISunoTask } from '@/models';
import { ElImage, ElIcon, ElTooltip, ElButton } from 'element-plus';
import { ElImage, ElIcon, ElTooltip, ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem } from 'element-plus';
import { VideoPlay, VideoPause } from '@element-plus/icons-vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { saveAs } from 'file-saver';

export default defineComponent({
name: 'TaskPreview',
Expand All @@ -75,7 +89,10 @@ export default defineComponent({
ElButton,
FontAwesomeIcon,
VideoPlay,
VideoPause
VideoPause,
ElDropdown,
ElDropdownMenu,
ElDropdownItem
},
props: {
modelValue: {
Expand Down Expand Up @@ -153,13 +170,26 @@ export default defineComponent({
},
onDownload(event: MouseEvent, audioUrl: string) {
event.stopPropagation();
console.log('on download');
console.log('on download', audioUrl);
// 使用 URL 对象解析
const parsedUrl = new URL(audioUrl);

// 获取路径名
const pathname = parsedUrl.pathname;
// 提取文件名
const filename = pathname.substring(pathname.lastIndexOf('/') + 1);
console.log('on preview', filename);
fetch(audioUrl)
.then((response) => response.blob())
.then((blob) => {
saveAs(blob, filename);
});
// download url here
window.open(audioUrl, '_blank');
// window.open(audioUrl, '_blank');
},
onPreview(event: MouseEvent, videoUrl: string) {
event.stopPropagation();
console.log('on preview');
console.log('on preview', videoUrl);
// preview url here
window.open(videoUrl, '_blank');
}
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/zh-CN/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"message": "AI 视频",
"description": "AI 视频章节标题"
},
"title.headshots": {
"message": "AI 证件照",
"description": "AI 证件照章节标题"
},
"title.comments": {
"message": "客户评价",
"description": "客户评价章节标题"
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/zh-CN/suno.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
"message": "视频",
"description": "视频按钮文本"
},
"button.download_video": {
"message": "下载视频",
"description": "下载视频按钮文本"
},
"button.download_audio": {
"message": "下载音乐",
"description": "下载音乐按钮文本"
},
"model.model1": {
"message": "v2",
"description": "用于生成音乐的模型"
Expand Down
Loading