feat: 完善AI音频播放
parent
bfddd674c1
commit
7f7c508bb2
Binary file not shown.
|
@ -57,7 +57,8 @@ provide('reload', reload)
|
||||||
|
|
||||||
'!min-h-[calc(100%-var(--top-tool-height)-var(--app-content-padding)-var(--app-content-padding)-var(--tags-view-height))]':
|
'!min-h-[calc(100%-var(--top-tool-height)-var(--app-content-padding)-var(--app-content-padding)-var(--tags-view-height))]':
|
||||||
!fixedHeader && layout === 'cutMenu' && footer
|
!fixedHeader && layout === 'cutMenu' && footer
|
||||||
}
|
},
|
||||||
|
'h-0'
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<router-view v-if="routerAlive">
|
<router-view v-if="routerAlive">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex ">
|
<div class="flex h-full items-stretch">
|
||||||
<!-- 模式 -->
|
<!-- 模式 -->
|
||||||
<Mode class="flex-none" @generate-music="generateMusic"/>
|
<Mode class="flex-none" @generate-music="generateMusic"/>
|
||||||
<!-- 音频列表 -->
|
<!-- 音频列表 -->
|
||||||
|
@ -15,6 +15,11 @@ defineOptions({ name: 'Index' })
|
||||||
|
|
||||||
const listRef = ref<Nullable<{generateMusic: (...args) => void}>>(null)
|
const listRef = ref<Nullable<{generateMusic: (...args) => void}>>(null)
|
||||||
|
|
||||||
|
/*
|
||||||
|
*@Description: 拿到左侧配置信息调用右侧音乐生成的方法
|
||||||
|
*@MethodAuthor: xiaohong
|
||||||
|
*@Date: 2024-07-19 11:13:38
|
||||||
|
*/
|
||||||
function generateMusic (args: {formData: Recordable}) {
|
function generateMusic (args: {formData: Recordable}) {
|
||||||
unref(listRef)?.generateMusic(args.formData)
|
unref(listRef)?.generateMusic(args.formData)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
<div class="flex gap-[10px]">
|
<div class="flex gap-[10px]">
|
||||||
<el-image src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" class="w-[45px]"/>
|
<el-image src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" class="w-[45px]"/>
|
||||||
<div>
|
<div>
|
||||||
<div>我很好</div>
|
<div>{{currentSong.name}}</div>
|
||||||
<div class="text-[12px] text-gray-400">刘大壮</div>
|
<div class="text-[12px] text-gray-400">{{currentSong.singer}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- 音频 -->
|
<!-- 音频 -->
|
||||||
<audio v-bind="audioProps" ref="audioRef" controls v-show="!audioProps" @timeupdate="audioTimeUpdate">
|
<audio v-bind="audioProps" ref="audioRef" controls v-show="!audioProps" @timeupdate="audioTimeUpdate">
|
||||||
<source :src="response"/>
|
<source :src="audioUrl"/>
|
||||||
</audio>
|
</audio>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -35,34 +35,36 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { formatPast } from '@/utils/formatTime'
|
import { formatPast } from '@/utils/formatTime'
|
||||||
import response from '@/assets/audio/response.mp3'
|
import audioUrl from '@/assets/audio/response.mp3'
|
||||||
|
|
||||||
defineOptions({ name: 'Index' })
|
defineOptions({ name: 'Index' })
|
||||||
|
|
||||||
const audioRef = ref<Nullable<HTMLElement>>(null)
|
const currentSong = inject('currentSong', {})
|
||||||
// 音频相关属性https://www.runoob.com/tags/ref-av-dom.html
|
|
||||||
const audioProps = reactive({
|
|
||||||
autoplay: true,
|
|
||||||
paused: false,
|
|
||||||
currentTime: '00:00',
|
|
||||||
duration: '00:00',
|
|
||||||
muted: false,
|
|
||||||
volume: 50,
|
|
||||||
})
|
|
||||||
|
|
||||||
function toggleStatus (type: string) {
|
const audioRef = ref<Nullable<HTMLElement>>(null)
|
||||||
audioProps[type] = !audioProps[type]
|
// 音频相关属性https://www.runoob.com/tags/ref-av-dom.html
|
||||||
if (type === 'paused' && audioRef.value) {
|
const audioProps = reactive({
|
||||||
if (audioProps[type]) {
|
autoplay: true,
|
||||||
audioRef.value.pause()
|
paused: false,
|
||||||
} else {
|
currentTime: '00:00',
|
||||||
audioRef.value.play()
|
duration: '00:00',
|
||||||
}
|
muted: false,
|
||||||
|
volume: 50,
|
||||||
|
})
|
||||||
|
|
||||||
|
function toggleStatus (type: string) {
|
||||||
|
audioProps[type] = !audioProps[type]
|
||||||
|
if (type === 'paused' && audioRef.value) {
|
||||||
|
if (audioProps[type]) {
|
||||||
|
audioRef.value.pause()
|
||||||
|
} else {
|
||||||
|
audioRef.value.play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 更新播放位置
|
// 更新播放位置
|
||||||
function audioTimeUpdate (args) {
|
function audioTimeUpdate (args) {
|
||||||
audioProps.currentTime = formatPast(new Date(args.timeStamp), 'mm:ss')
|
audioProps.currentTime = formatPast(new Date(args.timeStamp), 'mm:ss')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col h-[600px]">
|
<div class="flex flex-col">
|
||||||
<div class="flex-auto flex overflow-hidden">
|
<div class="flex-auto flex overflow-hidden">
|
||||||
<el-tabs v-model="currentType" class="flex-auto px-[var(--app-content-padding)]">
|
<el-tabs v-model="currentType" class="flex-auto px-[var(--app-content-padding)]">
|
||||||
<!-- 我的创作 -->
|
<!-- 我的创作 -->
|
||||||
<el-tab-pane label="我的创作" v-loading="loading" name="mine">
|
<el-tab-pane v-loading="loading" label="我的创作" name="mine">
|
||||||
<el-row v-if="mySongList.length" :gutter="12">
|
<el-row v-if="mySongList.length" :gutter="12">
|
||||||
<el-col v-for="song in mySongList" :key="song.id" :span="24">
|
<el-col v-for="song in mySongList" :key="song.id" :span="24">
|
||||||
<songCard v-bind="song"/>
|
<songCard :songInfo="song" @click="setCurrentSong(song)"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-empty v-else description="暂无音乐"/>
|
<el-empty v-else description="暂无音乐"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
<!-- 试听广场 -->
|
<!-- 试听广场 -->
|
||||||
<el-tab-pane label="试听广场" v-loading="loading" name="square">
|
<el-tab-pane v-loading="loading" label="试听广场" name="square">
|
||||||
<el-row v-if="squareSongList.length" v-loading="loading" :gutter="12">
|
<el-row v-if="squareSongList.length" v-loading="loading" :gutter="12">
|
||||||
<el-col v-for="song in squareSongList" :key="song.id" :span="24">
|
<el-col v-for="song in squareSongList" :key="song.id" :span="24">
|
||||||
<songCard v-bind="song"/>
|
<songCard :songInfo="song" @click="setCurrentSong(song)"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-empty v-else description="暂无音乐"/>
|
<el-empty v-else description="暂无音乐"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
<!-- songInfo -->
|
<!-- songInfo -->
|
||||||
<songInfo v-bind="squareSongList[0]" class="flex-none"/>
|
<songInfo class="flex-none"/>
|
||||||
</div>
|
</div>
|
||||||
<audioBar class="flex-none"/>
|
<audioBar class="flex-none"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -36,13 +36,18 @@ import audioBar from './audioBar/index.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'Index' })
|
defineOptions({ name: 'Index' })
|
||||||
|
|
||||||
|
|
||||||
const currentType = ref('mine')
|
const currentType = ref('mine')
|
||||||
// loading 状态
|
// loading 状态
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
// 当前音乐
|
||||||
|
const currentSong = ref({})
|
||||||
|
|
||||||
const mySongList = ref<Recordable[]>([])
|
const mySongList = ref<Recordable[]>([])
|
||||||
const squareSongList = ref<Recordable[]>([])
|
const squareSongList = ref<Recordable[]>([])
|
||||||
|
|
||||||
|
provide('currentSong', currentSong)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*@Description: 调接口生成音乐列表
|
*@Description: 调接口生成音乐列表
|
||||||
*@MethodAuthor: xiaohong
|
*@MethodAuthor: xiaohong
|
||||||
|
@ -57,7 +62,7 @@ function generateMusic (formData: Recordable) {
|
||||||
id: index,
|
id: index,
|
||||||
audioUrl: '',
|
audioUrl: '',
|
||||||
videoUrl: '',
|
videoUrl: '',
|
||||||
title: '我走后',
|
title: '我走后' + index,
|
||||||
imageUrl: 'https://www.carsmp3.com/data/attachment/forum/201909/19/091020q5kgre20fidreqyt.jpg',
|
imageUrl: 'https://www.carsmp3.com/data/attachment/forum/201909/19/091020q5kgre20fidreqyt.jpg',
|
||||||
desc: 'Metal, symphony, film soundtrack, grand, majesticMetal, dtrack, grand, majestic',
|
desc: 'Metal, symphony, film soundtrack, grand, majesticMetal, dtrack, grand, majestic',
|
||||||
date: '2024年04月30日 14:02:57',
|
date: '2024年04月30日 14:02:57',
|
||||||
|
@ -76,6 +81,15 @@ function generateMusic (formData: Recordable) {
|
||||||
}, 3000)
|
}, 3000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*@Description: 设置当前播放的音乐
|
||||||
|
*@MethodAuthor: xiaohong
|
||||||
|
*@Date: 2024-07-19 11:22:33
|
||||||
|
*/
|
||||||
|
function setCurrentSong (music: Recordable) {
|
||||||
|
currentSong.value = music
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
generateMusic
|
generateMusic
|
||||||
})
|
})
|
||||||
|
@ -86,9 +100,9 @@ defineExpose({
|
||||||
:deep(.el-tabs) {
|
:deep(.el-tabs) {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
.el-tabs__content{
|
.el-tabs__content {
|
||||||
padding: 0 7px;
|
padding: 0 7px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex bg-[var(--el-bg-color-overlay)] p-12px mb-12px rounded-1">
|
<div class="flex bg-[var(--el-bg-color-overlay)] p-12px mb-12px rounded-1">
|
||||||
<el-image :src="imageUrl" class="flex-none w-80px"/>
|
<el-image :src="songInfo.imageUrl" class="flex-none w-80px"/>
|
||||||
<div class="ml-8px">
|
<div class="ml-8px">
|
||||||
<div>{{ title }}</div>
|
<div>{{ songInfo.title }}</div>
|
||||||
<div class="mt-8px text-12px text-[var(--el-text-color-secondary)] line-clamp-2">
|
<div class="mt-8px text-12px text-[var(--el-text-color-secondary)] line-clamp-2">
|
||||||
{{ desc }}
|
{{ songInfo.desc }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,15 +15,9 @@
|
||||||
defineOptions({ name: 'Index' })
|
defineOptions({ name: 'Index' })
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
imageUrl: {
|
songInfo: {
|
||||||
type: String
|
type: Object,
|
||||||
},
|
default: () => ({})
|
||||||
title: {
|
|
||||||
type: String
|
|
||||||
},
|
|
||||||
desc: {
|
|
||||||
type: String
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<ContentWrap class="w-300px mb-[0!important] line-height-24px">
|
<ContentWrap class="w-300px mb-[0!important] line-height-24px">
|
||||||
<el-image :src="imageUrl"/>
|
<el-image :src="currentSong.imageUrl"/>
|
||||||
<div class="">{{ title }}</div>
|
<div class="">{{ currentSong.title }}</div>
|
||||||
<div class="text-[var(--el-text-color-secondary)] text-12px line-clamp-1">{{ desc }}</div>
|
<div class="text-[var(--el-text-color-secondary)] text-12px line-clamp-1">
|
||||||
<div class="text-[var(--el-text-color-secondary)] text-12px">{{ date }}</div>
|
{{ currentSong.desc }}
|
||||||
|
</div>
|
||||||
|
<div class="text-[var(--el-text-color-secondary)] text-12px">
|
||||||
|
{{ currentSong.date }}
|
||||||
|
</div>
|
||||||
<el-button size="small" round class="my-6px">信息复用</el-button>
|
<el-button size="small" round class="my-6px">信息复用</el-button>
|
||||||
<div class="text-[var(--el-text-color-secondary)] text-12px" v-html="lyric"></div>
|
<div class="text-[var(--el-text-color-secondary)] text-12px" v-html="currentSong.lyric"></div>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -13,21 +17,6 @@
|
||||||
|
|
||||||
defineOptions({ name: 'Index' })
|
defineOptions({ name: 'Index' })
|
||||||
|
|
||||||
defineProps({
|
const currentSong = inject('currentSong', {})
|
||||||
imageUrl: {
|
|
||||||
type: String
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
type: String
|
|
||||||
},
|
|
||||||
desc: {
|
|
||||||
type: String
|
|
||||||
},
|
|
||||||
date: {
|
|
||||||
type: String
|
|
||||||
},
|
|
||||||
lyric: {
|
|
||||||
type: String
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -36,6 +36,6 @@ const modeRef = ref<Nullable<{ formData: Recordable }>>(null)
|
||||||
*@Date: 2024-06-27 16:40:16
|
*@Date: 2024-06-27 16:40:16
|
||||||
*/
|
*/
|
||||||
function generateMusic () {
|
function generateMusic () {
|
||||||
emits('generate-music', {formData: unref(modeRef)?.formData.value})
|
emits('generate-music', {formData: unref(modeRef)?.formData})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue