mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
enable album nav play button
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
{{ formatSeconds(album.duration, true) }} • {{ album.date }} •
|
{{ formatSeconds(album.duration, true) }} • {{ album.date }} •
|
||||||
{{ album.artist }}
|
{{ album.artist }}
|
||||||
</div>
|
</div>
|
||||||
<PlayBtnRect :source="playSources.album" />
|
<PlayBtnRect :source="playSources.album" :store="useAlbumStore" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -41,6 +41,7 @@ import { AlbumInfo } from "../../interfaces";
|
|||||||
import PlayBtnRect from "../shared/PlayBtnRect.vue";
|
import PlayBtnRect from "../shared/PlayBtnRect.vue";
|
||||||
import useVisibility from "@/composables/useVisibility";
|
import useVisibility from "@/composables/useVisibility";
|
||||||
import useNavStore from "@/stores/nav";
|
import useNavStore from "@/stores/nav";
|
||||||
|
import useAlbumStore from "@/stores/album";
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
album: AlbumInfo;
|
album: AlbumInfo;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<Album v-show="$route.name == Routes.album && nav.showPlay" />
|
<Album v-show="$route.name == Routes.album && !nav.showPlay" />
|
||||||
<Playlists v-show="$route.name == Routes.playlists" />
|
<Playlists v-show="$route.name == Routes.playlists" />
|
||||||
<Folder v-show="$route.name == Routes.folder" :subPaths="subPaths" />
|
<Folder v-show="$route.name == Routes.folder" :subPaths="subPaths" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="title albumnavtitle" v-motion-slide-from-left-100>
|
<div class="title albumnavtitle" v-motion-slide-from-left-100>
|
||||||
<PlayBtn />
|
<PlayBtn :source="playSources.album" :store="useAlbumStore" />
|
||||||
<div class="ellip">
|
<div class="ellip">
|
||||||
{{ store.info.title }}
|
{{ store.info.title }}
|
||||||
</div>
|
</div>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import useAlbumStore from "@/stores/album";
|
import useAlbumStore from "@/stores/album";
|
||||||
import PlayBtn from "@/components/shared/PlayBtn.vue";
|
import PlayBtn from "@/components/shared/PlayBtn.vue";
|
||||||
|
import { playSources } from "@/composables/enums";
|
||||||
const store = useAlbumStore();
|
const store = useAlbumStore();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="play-btn rounded shadow-sm" @click="playThis"></div>
|
<div
|
||||||
|
class="play-btn rounded shadow-sm"
|
||||||
|
@click="usePlayFrom(source, useQStore, store)"
|
||||||
|
></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
function playThis(e: Event) {
|
import { playSources } from "@/composables/enums";
|
||||||
e.preventDefault();
|
import useAlbumStore from "@/stores/album";
|
||||||
e.stopImmediatePropagation();
|
import usePlaylistStore from "@/stores/p.ptracks";
|
||||||
}
|
import usePlayFrom from "@/composables/usePlayFrom";
|
||||||
|
import useQStore from "@/stores/queue";
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
source: playSources;
|
||||||
|
store: typeof useAlbumStore | typeof usePlaylistStore;
|
||||||
|
}>();
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.play-btn {
|
.play-btn {
|
||||||
|
|||||||
@@ -1,48 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="playbtnrect rounded" @click="play">
|
<div
|
||||||
|
class="playbtnrect rounded"
|
||||||
|
@click="usePlayFrom(source, useQStore, store)"
|
||||||
|
>
|
||||||
<div class="icon image"></div>
|
<div class="icon image"></div>
|
||||||
<div class="text">Play</div>
|
<div class="text">Play</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { playSources } from "../../composables/enums";
|
import { playSources } from "@/composables/enums";
|
||||||
|
import usePlayFrom from "@/composables/usePlayFrom";
|
||||||
|
import useQStore from "@/stores/queue";
|
||||||
|
import useFStore from "@/stores/folder";
|
||||||
|
import useAStore from "@/stores/album";
|
||||||
|
import usePStore from "@/stores/p.ptracks";
|
||||||
|
|
||||||
import useQStore from "../../stores/queue";
|
defineProps<{
|
||||||
import useFStore from "../../stores/folder";
|
|
||||||
import useAStore from "../../stores/album";
|
|
||||||
import usePStore from "../../stores/p.ptracks";
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
source: playSources;
|
source: playSources;
|
||||||
|
store:
|
||||||
|
| typeof useQStore
|
||||||
|
| typeof useFStore
|
||||||
|
| typeof useAStore
|
||||||
|
| typeof usePStore;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const queue = useQStore();
|
|
||||||
const folder = useFStore();
|
|
||||||
const album = useAStore();
|
|
||||||
const playlist = usePStore();
|
|
||||||
|
|
||||||
function play() {
|
|
||||||
switch (props.source) {
|
|
||||||
// check which route the play request come from
|
|
||||||
case playSources.folder:
|
|
||||||
queue.playFromFolder(folder.path, folder.tracks);
|
|
||||||
queue.play(queue.tracks[0]);
|
|
||||||
break;
|
|
||||||
case playSources.album:
|
|
||||||
queue.playFromAlbum(album.info.title, album.info.artist, album.tracks);
|
|
||||||
queue.play(album.tracks[0]);
|
|
||||||
break;
|
|
||||||
case playSources.playlist:
|
|
||||||
queue.playFromPlaylist(
|
|
||||||
playlist.info.name,
|
|
||||||
playlist.info.playlistid,
|
|
||||||
playlist.tracks
|
|
||||||
);
|
|
||||||
queue.play(playlist.tracks[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { playSources } from "@/composables/enums";
|
||||||
|
|
||||||
|
import useQStore from "@/stores/queue";
|
||||||
|
import useFStore from "@/stores/folder";
|
||||||
|
import useAStore from "@/stores/album";
|
||||||
|
import usePStore from "@/stores/p.ptracks";
|
||||||
|
|
||||||
|
const queue = useQStore;
|
||||||
|
const folder = useFStore;
|
||||||
|
const album = useAStore;
|
||||||
|
const playlist = usePStore;
|
||||||
|
|
||||||
|
type store = typeof queue | typeof folder | typeof album | typeof playlist;
|
||||||
|
|
||||||
|
export default function play(
|
||||||
|
source: playSources,
|
||||||
|
aqueue: typeof queue,
|
||||||
|
store: store
|
||||||
|
) {
|
||||||
|
const useQueue = aqueue();
|
||||||
|
|
||||||
|
switch (source) {
|
||||||
|
// check which route the play request come from
|
||||||
|
case playSources.folder:
|
||||||
|
store = store as typeof folder;
|
||||||
|
|
||||||
|
useQueue.playFromFolder(store().path, store().tracks);
|
||||||
|
useQueue.play(store().tracks[0]);
|
||||||
|
break;
|
||||||
|
case playSources.album:
|
||||||
|
store = store as typeof album;
|
||||||
|
|
||||||
|
useQueue.playFromAlbum(
|
||||||
|
store().info.title,
|
||||||
|
store().info.artist,
|
||||||
|
store().tracks
|
||||||
|
);
|
||||||
|
useQueue.play(store().tracks[0]);
|
||||||
|
break;
|
||||||
|
case playSources.playlist:
|
||||||
|
store = store as typeof playlist;
|
||||||
|
|
||||||
|
useQueue.playFromPlaylist(
|
||||||
|
store().info.name,
|
||||||
|
store().info.playlistid,
|
||||||
|
store().tracks
|
||||||
|
);
|
||||||
|
useQueue.play(store().tracks[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import { Ref, watch } from "vue";
|
|||||||
|
|
||||||
export default function useVisibility(
|
export default function useVisibility(
|
||||||
elem: Ref<HTMLElement>,
|
elem: Ref<HTMLElement>,
|
||||||
callback: () => void
|
callback: (state: boolean) => void
|
||||||
) {
|
) {
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ export default function useVisibility(
|
|||||||
watch(
|
watch(
|
||||||
() => visible.value,
|
() => visible.value,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
callback();
|
callback(newVal);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -2,12 +2,11 @@ import { defineStore } from "pinia";
|
|||||||
|
|
||||||
export default defineStore("navmanagement", {
|
export default defineStore("navmanagement", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
showPlay: true,
|
showPlay: false,
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
toggleShowPlay() {
|
toggleShowPlay(state: boolean) {
|
||||||
this.showPlay = !this.showPlay;
|
this.showPlay = state;
|
||||||
console.log(this.showPlay);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user