Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
806888cc
authored
Jul 16, 2024
by
xiaohong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增音频播放器
parent
93362805
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
9 deletions
+65
-9
src/views/ai/music/components/index.vue
+2
-2
src/views/ai/music/components/list/audioBar/index.vue
+60
-1
src/views/ai/music/components/list/index.vue
+1
-1
src/views/ai/music/components/mode/index.vue
+2
-5
No files found.
src/views/ai/music/components/index.vue
View file @
806888cc
<
template
>
<
template
>
<div
class=
"flex
h-1/1
"
>
<div
class=
"flex "
>
<!-- 模式 -->
<!-- 模式 -->
<Mode
class=
"flex-none"
@
generate-music=
"generateMusic"
/>
<Mode
class=
"flex-none"
@
generate-music=
"generateMusic"
/>
<!-- 音频列表 -->
<!-- 音频列表 -->
...
@@ -13,7 +13,7 @@ import List from './list/index.vue'
...
@@ -13,7 +13,7 @@ import List from './list/index.vue'
defineOptions
({
name
:
'Index'
})
defineOptions
({
name
:
'Index'
})
const
listRef
=
ref
<
{
generateMusic
:
(...
args
)
=>
void
}
|
null
>
(
null
)
const
listRef
=
ref
<
Nullable
<
{
generateMusic
:
(...
args
)
=>
void
}
>
>
(
null
)
function
generateMusic
(
args
:
{
formData
:
Recordable
})
{
function
generateMusic
(
args
:
{
formData
:
Recordable
})
{
unref
(
listRef
)?.
generateMusic
(
args
.
formData
)
unref
(
listRef
)?.
generateMusic
(
args
.
formData
)
...
...
src/views/ai/music/components/list/audioBar/index.vue
View file @
806888cc
<
template
>
<
template
>
<div
class=
"h-72px bg-[var(--el-bg-color-overlay)] b-solid b-1 b-[var(--el-border-color)] b-l-none"
>
播放器
</div>
<div
class=
"flex items-center justify-between px-2 h-72px bg-[var(--el-bg-color-overlay)] b-solid b-1 b-[var(--el-border-color)] b-l-none"
>
<!-- 歌曲信息 -->
<div
class=
"flex gap-[10px]"
>
<el-image
src=
"https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
class=
"w-[45px]"
/>
<div>
<div>
我很好
</div>
<div
class=
"text-[12px] text-gray-400"
>
刘大壮
</div>
</div>
</div>
<!-- 音频controls -->
<div
class=
"flex gap-[12px] items-center"
>
<Icon
icon=
"majesticons:back-circle"
:size=
"20"
class=
"text-gray-300 cursor-pointer"
/>
<Icon
:icon=
"audioProps.paused ? 'mdi:arrow-right-drop-circle' : 'solar:pause-circle-bold'"
:size=
"30"
class=
" cursor-pointer"
@
click=
"toggleStatus('paused')"
/>
<Icon
icon=
"majesticons:next-circle"
:size=
"20"
class=
"text-gray-300 cursor-pointer"
/>
<div
class=
"flex gap-[16px] items-center"
>
<span>
{{
audioProps
.
currentTime
}}
</span>
<el-slider
v-model=
"audioProps.duration"
color=
"#409eff"
class=
"w-[160px!important] "
/>
<span>
{{
audioProps
.
duration
}}
</span>
</div>
<!-- 音频 -->
<audio
v-bind=
"audioProps"
ref=
"audioRef"
controls
v-show=
"!audioProps"
@
timeupdate=
"audioTimeUpdate"
>
<source
:src=
"response"
/>
</audio>
</div>
<!-- 音量控制器 -->
<div
class=
"flex gap-[16px] items-center"
>
<Icon
:icon=
"audioProps.muted ? 'tabler:volume-off' : 'tabler:volume'"
:size=
"20"
class=
"cursor-pointer"
@
click=
"toggleStatus('muted')"
/>
<el-slider
v-model=
"audioProps.volume"
color=
"#409eff"
class=
"w-[160px!important] "
/>
</div>
</div>
</
template
>
</
template
>
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
formatPast
}
from
'@/utils/formatTime'
import
response
from
'@/assets/audio/response.mp3'
defineOptions
({
name
:
'Index'
})
defineOptions
({
name
:
'Index'
})
const
audioRef
=
ref
<
Nullable
<
HTMLElement
>>
(
null
)
// 音频相关属性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
)
{
audioProps
[
type
]
=
!
audioProps
[
type
]
if
(
type
===
'paused'
&&
audioRef
.
value
)
{
if
(
audioProps
[
type
])
{
audioRef
.
value
.
pause
()
}
else
{
audioRef
.
value
.
play
()
}
}
}
// 更新播放位置
function
audioTimeUpdate
(
args
)
{
audioProps
.
currentTime
=
formatPast
(
new
Date
(
args
.
timeStamp
),
'mm:ss'
)
}
</
script
>
</
script
>
src/views/ai/music/components/list/index.vue
View file @
806888cc
<
template
>
<
template
>
<div
class=
"flex flex-col h-
full
"
>
<div
class=
"flex flex-col h-
[600px]
"
>
<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)]"
>
<!-- 我的创作 -->
<!-- 我的创作 -->
...
...
src/views/ai/music/components/mode/index.vue
View file @
806888cc
<
template
>
<
template
>
<ContentWrap
class=
"w-300px h-full"
>
<ContentWrap
class=
"w-300px h-full
mb-[0!important]
"
>
<el-radio-group
v-model=
"generateMode"
class=
"mb-15px"
>
<el-radio-group
v-model=
"generateMode"
class=
"mb-15px"
>
<el-radio-button
label=
"desc"
>
<el-radio-button
label=
"desc"
>
描述模式
描述模式
...
@@ -28,10 +28,7 @@ const emits = defineEmits(['generate-music'])
...
@@ -28,10 +28,7 @@ const emits = defineEmits(['generate-music'])
const
generateMode
=
ref
(
'lyric'
)
const
generateMode
=
ref
(
'lyric'
)
interface
ModeRef
{
const
modeRef
=
ref
<
Nullable
<
{
formData
:
Recordable
}
>>
(
null
)
formData
:
Recordable
}
const
modeRef
=
ref
<
ModeRef
|
null
>
(
null
)
/*
/*
*@Description: 根据信息生成音乐
*@Description: 根据信息生成音乐
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment