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