feat(layout): 重构页面布局与音乐播放组件
将 PlayMusic 组件迁移至 layout/RightButton 并重构成通用右下角按钮组件, 提取音乐播放逻辑到独立 hook `usePlayMusic`,优化模态框提示逻辑并统一滚动行为。
This commit is contained in:
63
src/layout/RightButton/index.vue
Normal file
63
src/layout/RightButton/index.vue
Normal file
@@ -0,0 +1,63 @@
|
||||
<script setup lang='ts'>
|
||||
import { ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { usePlayMusic } from './usePlayMusic'
|
||||
|
||||
const { playMusic, currentMusic, nextPlay } = usePlayMusic()
|
||||
|
||||
const { t } = useI18n()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const settingRef = ref()
|
||||
// const audio = ref(new Audio())
|
||||
// const localMusicListValue = ref(localMusicList)
|
||||
|
||||
function enterConfig() {
|
||||
router.push('/log-lottery/config')
|
||||
}
|
||||
function enterHome() {
|
||||
router.push('/log-lottery')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div ref="settingRef" class="flex flex-col gap-3">
|
||||
<div v-if="route.path.includes('/config')" class="tooltip tooltip-left" :data-tip="t('tooltip.toHome')">
|
||||
<div
|
||||
class="flex items-center justify-center w-10 h-10 p-0 m-0 cursor-pointer setting-container bg-slate-500/50 rounded-l-xl hover:bg-slate-500/80 hover:text-blue-400/90"
|
||||
@click="enterHome"
|
||||
>
|
||||
<svg-icon name="home" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="tooltip tooltip-left" :data-tip="t('tooltip.settingConfiguration')">
|
||||
<div
|
||||
class="flex items-center justify-center w-10 h-10 p-0 m-0 cursor-pointer setting-container bg-slate-500/50 rounded-l-xl hover:bg-slate-500/80 hover:text-blue-400/90"
|
||||
@click="enterConfig"
|
||||
>
|
||||
<svg-icon name="setting" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tooltip tooltip-left" :data-tip="currentMusic.item ? `${currentMusic.item.name}\n\r ${t('tooltip.nextSong')}` : t('tooltip.noSongPlay')">
|
||||
<div
|
||||
class="flex items-center justify-center w-10 h-10 p-0 m-0 cursor-pointer setting-container bg-slate-500/50 rounded-l-xl hover:bg-slate-500/80 hover:text-blue-400/90"
|
||||
@click="playMusic(currentMusic.item)" @click.right.prevent="nextPlay"
|
||||
>
|
||||
<svg-icon :name="currentMusic.paused ? 'play' : 'pause'" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
details {
|
||||
|
||||
// display: none;
|
||||
summary {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user