From 9c7b484b36ffaf4354036fae8e90aaaf7109fa21 Mon Sep 17 00:00:00 2001 From: zilong Date: Sun, 24 Oct 2021 20:10:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=BC=80=E4=B8=80=E4=B8=AA=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=86=8D=E5=86=99=E5=BD=93=E5=89=8D=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 +- src/assets/svgs/Dots.svg | 1 + src/components/ArtistsSpan.vue | 18 ++- src/store/index.js | 40 +++--- src/views/common/SongCtrl.vue | 24 +++- src/views/common/SongInfo.vue | 6 +- src/views/common/ZPlayingList.vue | 203 +++++++++++++++++++++--------- src/views/discover/Discover.vue | 4 +- src/views/discover/Recommend.vue | 11 +- 9 files changed, 213 insertions(+), 96 deletions(-) create mode 100644 src/assets/svgs/Dots.svg diff --git a/src/App.vue b/src/App.vue index 2d537f5..3bc0f9a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -215,7 +215,7 @@ body { bottom: 64px; // left: 0; width: 500px; - background-color: #f6f6f6; + background-color: #fff; z-index: 1000; border: #ddd solid 1px; // border-top-left-radius: 8px; diff --git a/src/assets/svgs/Dots.svg b/src/assets/svgs/Dots.svg new file mode 100644 index 0000000..07d3e70 --- /dev/null +++ b/src/assets/svgs/Dots.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/ArtistsSpan.vue b/src/components/ArtistsSpan.vue index ff4d770..f7aec72 100644 --- a/src/components/ArtistsSpan.vue +++ b/src/components/ArtistsSpan.vue @@ -1,10 +1,20 @@ - + diff --git a/src/views/common/SongInfo.vue b/src/views/common/SongInfo.vue index 560457c..f05011c 100644 --- a/src/views/common/SongInfo.vue +++ b/src/views/common/SongInfo.vue @@ -20,7 +20,7 @@ const store = useStore() const showInfo = ref(false); const info = reactive({ name: "", - artists: "", + artists: [], album: {}, duration: 0, mv: 0, @@ -44,7 +44,6 @@ const songInfo = (id, im) => { date: Date.now(), }, ...toRaw(info)} store.commit('savePlayed', p) - store.commit('addToPlayingList', p) console.log('savePlayed'); } @@ -67,6 +66,9 @@ const psToken = pubsub.subscribe("zp", (msg, data) => { case "zp.getSongInfo": songInfo(data.id, data.im); break; + case "zp.hideSongInfo": + showInfo.value = false + break; case "zp.progress": totalTime.value = zpTime(data.total * 1000) currTime.value = zpTime(data.progress * 1000) diff --git a/src/views/common/ZPlayingList.vue b/src/views/common/ZPlayingList.vue index 13b17f3..55baf5d 100644 --- a/src/views/common/ZPlayingList.vue +++ b/src/views/common/ZPlayingList.vue @@ -16,6 +16,7 @@ import { NButtonGroup, NSpace, NIcon, + NDropdown, NMenu, NLayout, NLayoutHeader, @@ -28,11 +29,12 @@ import { } from "naive-ui"; import Play from "@/assets/svgs/Play_.svg"; import Pause from "@/assets/svgs/Pause.svg"; +import svgDots from "@/assets/svgs/Dots.svg"; import dayjs from "dayjs"; import "dayjs/locale/zh-cn"; import duration from "dayjs/plugin/duration"; import pubsub from "pubsub-js"; -import ArtistsSpan from '@/components/ArtistsSpan.vue'; +import ArtistsSpan from "@/components/ArtistsSpan.vue"; const store = useStore(); const router = useRouter(); @@ -41,8 +43,6 @@ const playingList = ref([]); const wpTable = ref(""); const listHeight = ref(0); -// playingList.value = toRaw(store.state.settings.playingList); - const token = pubsub.subscribe("zp", (msg, data) => { switch (msg) { case "zp.togglePlaying": @@ -66,86 +66,143 @@ watch( } ); -let dragIdx = -1 +let dragIdx = -1; const dragstart = (idx) => { // console.log('start ',idx); - dragIdx=idx -} + dragIdx = idx; +}; const dragenter = (e, idx) => { // console.log('enter ',idx); e.preventDefault(); - if(dragIdx !== idx){ - let dragItem = toRaw(playingList.value)[dragIdx] - let item = toRaw(playingList.value)[idx] + if (dragIdx !== idx) { + let dragItem = toRaw(playingList.value)[dragIdx]; + let item = toRaw(playingList.value)[idx]; // console.log(playingList,dragItem); - playingList.value.splice(dragIdx,1) - playingList.value.splice(idx, 0, dragItem) - dragIdx=idx - store.commit('saveSettings', { - playingList: playingList.value - }) + playingList.value.splice(dragIdx, 1); + playingList.value.splice(idx, 0, dragItem); + dragIdx = idx; + store.commit("saveSettings", { + playingList: playingList.value, + }); } - -} +}; const dragover = (e, idx) => { // console.log('over ',idx); e.preventDefault(); -} +}; const drop = (e, idx) => { // console.log('drop ',idx); e.preventDefault(); +}; + +//菜单 +const options = [ + { + label: "播放", + key: "play", + }, + // { + // label: "下一首播放", + // key: "nextToPlay", + // }, + { + type: 'divider', + key: '' + }, + { + label: "从列表删除", + key: "remove", + }, +]; + +// 处理菜单选择 +const handleSelect = (key, id) => { + switch(key){ + case 'play': + pubsub.publish('zp.play',{ + id, im: true, + }) + break; + case 'nextToPlay': + break; + case 'remove': + store.commit('removePlayingList', {id}) + if(playingList.value.length>0) + pubsub.publish('zp.next') + else + pubsub.publish('zp.stop') + break; + } +}; +const handleClick = () => { + // showDropdownRef.value = !showDropdownRef.value; +}; + +const arLeave = ()=>{ + pubsub.publish('zp.togglePlaying',) }