feat: 修改拖动有效判定条件。歌单添加播放mv按钮。歌单仅为1首时也能唤起。

This commit is contained in:
539943419 committed 2024-09-29 13:26:34 +08:00
1 parent baec1856c9
commit dcdb3a1ab8
7 files changed
+60 -28

No files matched your search

+14 -6
View File
@@ -1,5 +1,9 @@
<template> <template>
<div class="container" @dragover="handleDragOver" @dragleave="handleDragLeave" @drop="handleDrop"> <div
class="container"
@dragover="handleDragOver"
@dragleave="handleDragLeave"
@drop="handleDrop">
<slot></slot> <slot></slot>
<miao-mask v-model:show="showMask"></miao-mask> <miao-mask v-model:show="showMask"></miao-mask>
</div> </div>
@@ -64,11 +68,15 @@ const removeDirectory = async (files: File[]) => {
} }
} }
} }
const check = (event: DragEvent) => [ const check = (event: DragEvent) => {
...(event.dataTransfer?.files ?? []), return (
...(dataBus.get('dragData_vFiles') ?? []), [
...(dataBus.get('dragData_vDirectory') ?? []) ...(event.dataTransfer?.types?.filter(v=>v === 'Files') ?? []),
].length !== 0 ...(dataBus.get('dragData_vFiles') ?? []),
...(dataBus.get('dragData_vDirectory') ?? [])
].length !== 0
)
}
const handleDragOver = async (event: DragEvent) => { const handleDragOver = async (event: DragEvent) => {
if (props.disable || check(event) === false) { if (props.disable || check(event) === false) {
+6 -1
View File
@@ -53,7 +53,12 @@ export const renderIcon = (icon: any) => {
} }
} }
export const sleep = async (timeout: number) => {
await new Promise(_=>setTimeout(_, timeout))
}
export default { export default {
filePicker, filePicker,
renderIcon renderIcon,
sleep
} }
@@ -1,10 +1,11 @@
import { createApp, Reactive } from "vue"; import { createApp, Reactive } from "vue";
import aplayerListNew from "../src/aplayerListNew.vue"; import aplayerListNew from "../src/aplayerListNew.vue";
import apType from "../types/ap"; import apType, { audioType } from "../types/ap";
type aplayerMiaoOption = { type aplayerMiaoOption = {
onDragItemStart?: () => void, onDragItemStart?: () => void
onDragItemEnd?: () => void, onDragItemEnd?: () => void
onPlayVideo?: (element: audioType) => void
} }
/** /**
@@ -26,6 +26,9 @@ import config from '@/config';
import difference from 'lodash/difference'; import difference from 'lodash/difference';
import uniq from 'lodash/uniq' import uniq from 'lodash/uniq'
import apType from './types/ap'; import apType from './types/ap';
import usePluginCenter from '@/hooks/usePluginCenter';
const pluginCenter = usePluginCenter()
const miaoMessageRef = ref<InstanceType<typeof miaoAlertTipProvider>>() const miaoMessageRef = ref<InstanceType<typeof miaoAlertTipProvider>>()
@@ -49,7 +52,7 @@ const getMusicList = (mp3VFiles: VirtualFile[]) => mp3VFiles.map((v, index) => (
url: `${config.baseUrl}${v.url}`, url: `${config.baseUrl}${v.url}`,
name: v.name, name: v.name,
artist: ' ', artist: ' ',
index index,
})); }));
const handleDropVFiles = (files: VirtualFile[]) => { const handleDropVFiles = (files: VirtualFile[]) => {
@@ -58,8 +61,6 @@ const handleDropVFiles = (files: VirtualFile[]) => {
const aplayer = ref<any>(null); const aplayer = ref<any>(null);
const disableDropReceiver = ref(false)
let ap: apType let ap: apType
let vueApp: App<Element> let vueApp: App<Element>
@@ -77,11 +78,12 @@ onMounted(() => {
ap = reactive<apType>(new APlayer(aplayerOption)) ap = reactive<apType>(new APlayer(aplayerOption))
vueApp = useAplayerMiao(ap, { vueApp = useAplayerMiao(ap, {
onDragItemStart: () => { onDragItemStart: () => {
disableDropReceiver.value = true
}, },
onDragItemEnd: () => { onDragItemEnd: () => {
disableDropReceiver.value = false
}, },
onPlayVideo: element => {
pluginCenter.usePlugin('miaoVideoPlayer', [], [currentFiles.value.find(v=>v.name === element.name) as VirtualFile])
}
}) })
ap.on('listremove', (...args: any) => { ap.on('listremove', (...args: any) => {
const { index } = args[0] as { index: number } const { index } = args[0] as { index: number }
@@ -112,7 +114,7 @@ onUnmounted(() => {
.aplayer { .aplayer {
display: flex; display: flex;
flex-direction: column-reverse; flex-direction: column-reverse;
position: fixed; position: absolute;
bottom: 10px; bottom: 10px;
width: -webkit-fill-available; width: -webkit-fill-available;
} }
@@ -427,11 +427,11 @@
fill: #000 fill: #000
} }
.aplayer .aplayer-info .aplayer-controller .aplayer-time .aplayer-icon.aplayer-icon-menu, /* .aplayer .aplayer-info .aplayer-controller .aplayer-time .aplayer-icon.aplayer-icon-menu,
.aplayer .aplayer-info .aplayer-controller .aplayer-time.aplayer-time-narrow .aplayer-icon-menu, .aplayer .aplayer-info .aplayer-controller .aplayer-time.aplayer-time-narrow .aplayer-icon-menu,
.aplayer .aplayer-info .aplayer-controller .aplayer-time.aplayer-time-narrow .aplayer-icon-mode { .aplayer .aplayer-info .aplayer-controller .aplayer-time.aplayer-time-narrow .aplayer-icon-mode {
display: none display: none
} } */
.aplayer .aplayer-info .aplayer-controller .aplayer-volume-wrap { .aplayer .aplayer-info .aplayer-controller .aplayer-volume-wrap {
position: relative; position: relative;
@@ -556,9 +556,9 @@
.aplayer .aplayer-list { .aplayer .aplayer-list {
overflow: auto; overflow: auto;
transition: all .5s ease; transition: all .35s ease;
will-change: height; will-change: height;
display: none; /* display: none; */
overflow: hidden overflow: hidden
} }
@@ -1,7 +1,9 @@
<template> <template>
<ol <ol
:style="{ maxHeight: ap.options.listMaxHeight }" :style="{ maxHeight: ap.options.listMaxHeight }"
:class="[!isDragging ? 'miaoMusic-ol-isDragging' : 'miaoMusic-ol-notDragging']" :class="[
!isDragging ? 'miaoMusic-ol-isDragging' : 'miaoMusic-ol-notDragging'
]"
:key="refreshKey" :key="refreshKey"
ref="ol"> ref="ol">
<VueDraggable <VueDraggable
@@ -24,6 +26,12 @@
<span class="aplayer-list-index">{{ index + 1 }}</span> <span class="aplayer-list-index">{{ index + 1 }}</span>
<span class="aplayer-list-title">{{ element.name }}</span> <span class="aplayer-list-title">{{ element.name }}</span>
<div class="aplayer-list-control"> <div class="aplayer-list-control">
<div
v-if="isVideo(element)"
class="aplayer-list-control-btn aplayer-list-control-btn-hover aplayer-list-control-btn-play"
@click.stop="onPlayVideo(element)">
<VideocamOutline class="aplayer-list-control-btn-svg" />
</div>
<div <div
class="aplayer-list-control-btn aplayer-list-control-btn-hover aplayer-list-control-btn-play" class="aplayer-list-control-btn aplayer-list-control-btn-hover aplayer-list-control-btn-play"
@click.stop="switchAudio(index)"> @click.stop="switchAudio(index)">
@@ -79,7 +87,8 @@ import {
CloseOutline, CloseOutline,
ReorderFourOutline, ReorderFourOutline,
PlayOutline, PlayOutline,
HeartOutline HeartOutline,
VideocamOutline
} from '@vicons/ionicons5' } from '@vicons/ionicons5'
import { VueDraggable } from 'vue-draggable-plus' import { VueDraggable } from 'vue-draggable-plus'
// 与vue-draggable冲突 // 与vue-draggable冲突
@@ -90,6 +99,7 @@ const props = defineProps<{
ap: apType ap: apType
onDragItemStart: () => void onDragItemStart: () => void
onDragItemEnd: () => void onDragItemEnd: () => void
onPlayVideo: (element: audioType) => void
}>() }>()
const ol = ref<HTMLOListElement>() const ol = ref<HTMLOListElement>()
@@ -188,10 +198,15 @@ const { onDragStart, onDragEnd } = (() => {
} }
} }
})() })()
// const onDragEnd = (_e: any) => {
// const curr = props.ap.list.audios[props.ap.list.index] const isVideo = (element: audioType) => {
// listRefreshIndex(curr) for (let end of ['mp4']) {
// } if (element.name.endsWith(end)) {
return true
}
}
return false
}
onMounted(() => { onMounted(() => {
// console.log(props.ap) // console.log(props.ap)
+3 -2
View File
@@ -15,14 +15,15 @@ const pluginConfig: registerComponentOption = {
return false return false
} }
for (let i of vFiles) { for (let i of vFiles) {
for (let s of ['mp4', 'mp3']) { for (let s of ['mp4']) {
if (i.name.endsWith(s)) { if (i.name.endsWith(s)) {
return true return true
} }
} }
} }
return false return false
} },
priority: 6
} }
export default pluginConfig export default pluginConfig