index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="flex flex-col">
  3. <div class="flex-auto flex overflow-hidden">
  4. <el-tabs v-model="currentType" class="flex-auto px-[var(--app-content-padding)]">
  5. <!-- 我的创作 -->
  6. <el-tab-pane v-loading="loading" label="我的创作" name="mine">
  7. <el-row v-if="mySongList.length" :gutter="12">
  8. <el-col v-for="song in mySongList" :key="song.id" :span="24">
  9. <songCard :songInfo="song" @click="setCurrentSong(song)"/>
  10. </el-col>
  11. </el-row>
  12. <el-empty v-else description="暂无音乐"/>
  13. </el-tab-pane>
  14. <!-- 试听广场 -->
  15. <el-tab-pane v-loading="loading" label="试听广场" name="square">
  16. <el-row v-if="squareSongList.length" v-loading="loading" :gutter="12">
  17. <el-col v-for="song in squareSongList" :key="song.id" :span="24">
  18. <songCard :songInfo="song" @click="setCurrentSong(song)"/>
  19. </el-col>
  20. </el-row>
  21. <el-empty v-else description="暂无音乐"/>
  22. </el-tab-pane>
  23. </el-tabs>
  24. <!-- songInfo -->
  25. <songInfo class="flex-none"/>
  26. </div>
  27. <audioBar class="flex-none"/>
  28. </div>
  29. </template>
  30. <script lang="ts" setup>
  31. import songCard from './songCard/index.vue'
  32. import songInfo from './songInfo/index.vue'
  33. import audioBar from './audioBar/index.vue'
  34. defineOptions({ name: 'Index' })
  35. const currentType = ref('mine')
  36. // loading 状态
  37. const loading = ref(false)
  38. // 当前音乐
  39. const currentSong = ref({})
  40. const mySongList = ref<Recordable[]>([])
  41. const squareSongList = ref<Recordable[]>([])
  42. provide('currentSong', currentSong)
  43. /*
  44. *@Description: 调接口生成音乐列表
  45. *@MethodAuthor: xiaohong
  46. *@Date: 2024-06-27 17:06:44
  47. */
  48. function generateMusic (formData: Recordable) {
  49. console.log(formData);
  50. loading.value = true
  51. setTimeout(() => {
  52. mySongList.value = Array.from({ length: 20 }, (_, index) => {
  53. return {
  54. id: index,
  55. audioUrl: '',
  56. videoUrl: '',
  57. title: '我走后' + index,
  58. imageUrl: 'https://www.carsmp3.com/data/attachment/forum/201909/19/091020q5kgre20fidreqyt.jpg',
  59. desc: 'Metal, symphony, film soundtrack, grand, majesticMetal, dtrack, grand, majestic',
  60. date: '2024年04月30日 14:02:57',
  61. lyric: `<div class="_words_17xen_66"><div>大江东去,浪淘尽,千古风流人物。
  62. </div><div>故垒西边,人道是,三国周郎赤壁。
  63. </div><div>乱石穿空,惊涛拍岸,卷起千堆雪。
  64. </div><div>江山如画,一时多少豪杰。
  65. </div><div>
  66. </div><div>遥想公瑾当年,小乔初嫁了,雄姿英发。
  67. </div><div>羽扇纶巾,谈笑间,樯橹灰飞烟灭。
  68. </div><div>故国神游,多情应笑我,早生华发。
  69. </div><div>人生如梦,一尊还酹江月。</div></div>`
  70. }
  71. })
  72. loading.value = false
  73. }, 3000)
  74. }
  75. /*
  76. *@Description: 设置当前播放的音乐
  77. *@MethodAuthor: xiaohong
  78. *@Date: 2024-07-19 11:22:33
  79. */
  80. function setCurrentSong (music: Recordable) {
  81. currentSong.value = music
  82. }
  83. defineExpose({
  84. generateMusic
  85. })
  86. </script>
  87. <style lang="scss" scoped>
  88. :deep(.el-tabs) {
  89. display: flex;
  90. flex-direction: column;
  91. .el-tabs__content {
  92. padding: 0 7px;
  93. overflow: auto;
  94. }
  95. }
  96. </style>