mirror of
https://gitee.com/blackfox/geekai.git
synced 2024-12-01 19:57:37 +08:00
add close button for music player
This commit is contained in:
parent
cb0dacd5e0
commit
59824bffc5
@ -72,6 +72,7 @@
|
||||
.right-box {
|
||||
width 100%
|
||||
color rgb(250 247 245)
|
||||
overflow hidden
|
||||
|
||||
.list-box {
|
||||
padding 0 0 0 20px
|
||||
@ -230,7 +231,7 @@
|
||||
width 100%
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
left: 50px;
|
||||
padding 20px 0
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,8 @@
|
||||
<div class="progress" :style="{ width: `${progressPercent}%` }"></div>
|
||||
</div>
|
||||
<audio ref="audio" @timeupdate="updateProgress" @ended="nextSong"></audio>
|
||||
|
||||
<el-button class="close" type="info" :icon="Close" circle size="small" @click="emits('close')" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -39,6 +41,7 @@
|
||||
<script setup>
|
||||
import {ref, onMounted, watch} from 'vue';
|
||||
import {showMessageError} from "@/utils/dialog";
|
||||
import {Close} from "@element-plus/icons-vue";
|
||||
|
||||
const audio = ref(null);
|
||||
const isPlaying = ref(false);
|
||||
@ -58,6 +61,8 @@ const props = defineProps({
|
||||
default: () => []
|
||||
},
|
||||
});
|
||||
// eslint-disable-next-line no-undef
|
||||
const emits = defineEmits(['close']);
|
||||
|
||||
watch(() => props.songs, (newVal) => {
|
||||
console.log(newVal)
|
||||
@ -108,8 +113,12 @@ const nextSong = () => {
|
||||
};
|
||||
|
||||
const updateProgress = () => {
|
||||
currentTime.value = audio.value.currentTime;
|
||||
progressPercent.value = (currentTime.value / duration.value) * 100;
|
||||
try {
|
||||
currentTime.value = audio.value.currentTime;
|
||||
progressPercent.value = (currentTime.value / duration.value) * 100;
|
||||
} catch (e) {
|
||||
console.error(e.message)
|
||||
}
|
||||
};
|
||||
|
||||
const formatTime = (time) => {
|
||||
@ -125,6 +134,7 @@ const setProgress = (event) => {
|
||||
audio.value.currentTime = (clickX / totalWidth) * audioDuration;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
defineExpose({
|
||||
play
|
||||
});
|
||||
@ -237,6 +247,12 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.close {
|
||||
position absolute
|
||||
right 10px
|
||||
top 15px
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,8 +157,8 @@
|
||||
</div>
|
||||
<el-empty :image-size="100" description="没有任何作品,赶紧去创作吧!" v-else/>
|
||||
|
||||
<div class="music-player" v-if="playList.length > 0">
|
||||
<music-player :songs="playList" ref="playerRef" />
|
||||
<div class="music-player" v-if="showPlayer">
|
||||
<music-player :songs="playList" ref="playerRef" @close="showPlayer = false" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -173,7 +173,7 @@ import BlackInput from "@/components/ui/BlackInput.vue";
|
||||
import MusicPlayer from "@/components/MusicPlayer.vue";
|
||||
import {compact} from "lodash";
|
||||
|
||||
const winHeight = ref(window.innerHeight - 60)
|
||||
const winHeight = ref(window.innerHeight - 50)
|
||||
const custom = ref(false)
|
||||
const instrumental = ref(false)
|
||||
const models = ref([
|
||||
@ -191,6 +191,7 @@ const loading = ref(false)
|
||||
const noData = ref(false)
|
||||
const playList = ref([])
|
||||
const playerRef = ref(null)
|
||||
const showPlayer = ref(false)
|
||||
const list = ref([
|
||||
{
|
||||
id: 1,
|
||||
@ -240,6 +241,7 @@ const create = () => {
|
||||
|
||||
const play = (item) => {
|
||||
playList.value = [item]
|
||||
showPlayer.value = true
|
||||
nextTick(()=> playerRef.value.play())
|
||||
}
|
||||
// 格式化音频时长
|
||||
|
Loading…
Reference in New Issue
Block a user