forked from skyline523/NeteaseCloudMusicWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.vue
97 lines (89 loc) · 2.55 KB
/
home.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<script setup lang="ts">
import { storeToRefs } from 'pinia'
import {
OverlayScrollbarsComponent,
useOverlayScrollbars,
} from 'overlayscrollbars-vue'
import type { OverlayScrollbarsComponentRef } from 'overlayscrollbars-vue'
import { useOsObserver } from '~/hooks/useOsObserver'
const playerStore = usePlayerStore()
const { playlist } = storeToRefs(playerStore)
const elementHidden = ref(false)
const overlayScrollbarsApplied = ref(true)
const bodyOverlayScrollbarsApplied = ref<boolean | null>(null)
const osRef = ref<OverlayScrollbarsComponentRef | null>(null)
const [_, activateEvent] = useOsObserver()
const [initBodyOverlayScrollbars]
= useOverlayScrollbars({
defer: true,
events: {
initialized: () => {
bodyOverlayScrollbarsApplied.value = true
},
destroyed: () => {
bodyOverlayScrollbarsApplied.value = false
},
},
})
onMounted(() => initBodyOverlayScrollbars(document.body))
const hasPlaylist = computed(() => playlist.value && playlist.value.length > 0)
</script>
<template>
<main
class="drawerContainer"
flex="~"
text="center gray-700"
border="~ border-gray-50 rounded-lg"
position="relative"
h-780px min-w-1220px w-1220px overflow-hidden shadow-gray-200 shadow-lg
>
<Sidebar />
<div
z-0 w-0
flex="1"
bg="light-gray"
transition="padding duration-200"
:p="hasPlaylist ? 'b-20' : 'b-0'"
>
<Navbar />
<OverlayScrollbarsComponent
v-if="overlayScrollbarsApplied"
ref="osRef"
class="overlayscrollbars-vue"
:style="{ display: elementHidden ? 'none' : undefined }"
:options="{
scrollbars: {
theme: 'os-theme-light',
autoHide: 'leave',
autoHideDelay: 200,
autoHideSuspend: true,
clickScroll: true,
},
}"
:events="{
initialized: () => activateEvent('initialized'),
destroyed: () => activateEvent('destroyed'),
updated: () => activateEvent('updated'),
scroll: () => activateEvent('scroll'),
}"
defer
>
<RouterView v-slot="{ Component }">
<KeepAlive>
<component :is="Component" />
</KeepAlive>
</RouterView>
</OverlayScrollbarsComponent>
</div>
<div
position="absolute bottom-0 left-0"
transition="transform duration-200"
z-10 w-full
:style="{ transform: `translateY(${hasPlaylist ? 0 : '100%'})` }"
>
<LeVideoPlayer />
</div>
</main>
</template>
<style>
</style>