feat: 优化体验

This commit is contained in:
539943419 committed 2024-09-27 17:15:40 +08:00
1 parent c6b20b5b64
commit cdc0bce108
1 file changed
+34 -2
@@ -1,5 +1,5 @@
<template> <template>
<ol :style="{ maxHeight: ap.options.listMaxHeight }" :key="refreshKey"> <ol :style="{ maxHeight: ap.options.listMaxHeight }" :key="refreshKey" ref="ol">
<VueDraggable v-model="ap.list.audios" @start="onDragStart" @end="onDragEnd" item-key="id" <VueDraggable v-model="ap.list.audios" @start="onDragStart" @end="onDragEnd" item-key="id"
handle=".aplayer-list-control-btn-reorder" ghostClass="iSDragging" :animation="150"> handle=".aplayer-list-control-btn-reorder" ghostClass="iSDragging" :animation="150">
<li v-for="(element, index) in ap.list.audios" <li v-for="(element, index) in ap.list.audios"
@@ -39,7 +39,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref } from 'vue'; import { computed, nextTick, onMounted, ref } from 'vue';
import { ChevronUpOutline, ChevronDownOutline, CloseOutline, ReorderFourOutline, PlayOutline, HeartOutline } from '@vicons/ionicons5'; import { ChevronUpOutline, ChevronDownOutline, CloseOutline, ReorderFourOutline, PlayOutline, HeartOutline } from '@vicons/ionicons5';
import { VueDraggable } from 'vue-draggable-plus' import { VueDraggable } from 'vue-draggable-plus'
import apType, { audioType } from '../types/ap'; import apType, { audioType } from '../types/ap';
@@ -50,8 +50,12 @@ const props = defineProps<{
onDragItemEnd: () => void onDragItemEnd: () => void
}>() }>()
const ol = ref<HTMLOListElement>()
const refreshKey = ref(Math.random()) const refreshKey = ref(Math.random())
const isDragging = ref(false)
const apTheme = computed(() => props.ap.list.audios[activeAudioIndex.value].theme ?? props.ap.options.theme) const apTheme = computed(() => props.ap.list.audios[activeAudioIndex.value].theme ?? props.ap.options.theme)
const activeAudioIndex = computed(() => props.ap.list.index) const activeAudioIndex = computed(() => props.ap.list.index)
@@ -62,7 +66,13 @@ props.ap.on('listswitch', (...args: any) => {
}) })
const refresh = () => { const refresh = () => {
const top = ol.value?.scrollTop
refreshKey.value = Math.random() refreshKey.value = Math.random()
nextTick(() => {
ol.value?.scrollTo({
top,
})
})
} }
props.ap.on('listremove', refresh) props.ap.on('listremove', refresh)
@@ -121,10 +131,14 @@ const { onDragStart, onDragEnd } = (() => {
let curr: audioType let curr: audioType
return { return {
onDragStart: () => { onDragStart: () => {
isDragging.value = true
curr = props.ap.list.audios[props.ap.list.index] curr = props.ap.list.audios[props.ap.list.index]
}, },
onDragEnd: () => { onDragEnd: () => {
listRefreshIndex(curr) listRefreshIndex(curr)
nextTick(() => {
isDragging.value = false
})
} }
} }
})() })()
@@ -142,6 +156,7 @@ onMounted(() => {
.aplayer-list-new { .aplayer-list-new {
height: fit-content !important; height: fit-content !important;
cursor: default !important; cursor: default !important;
.aplayer-list-cur { .aplayer-list-cur {
height: calc(100% - 8px) !important; height: calc(100% - 8px) !important;
} }
@@ -207,4 +222,21 @@ onMounted(() => {
.aplayer .aplayer-list ol li:hover { .aplayer .aplayer-list ol li:hover {
background: #efefef !important; background: #efefef !important;
} }
.miaoMusicDrag-move,
.miaoMusicDrag-enter-active,
.miaoMusicDrag-leave-active {
transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);
}
.miaoMusicDrag-enter-from,
.miaoMusicDrag-leave-to {
opacity: 0;
transform: scaleY(0.01) translate(30px, 0);
}
.miaoMusicDrag-leave-active {
position: absolute;
}
</style> </style>