mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-09 12:37:22 +00:00
implement play from album card
This commit is contained in:
parent
cc8a8171b8
commit
5ebfd4df7f
@ -18,31 +18,45 @@
|
|||||||
}"
|
}"
|
||||||
></div>
|
></div>
|
||||||
<div class="with-img">
|
<div class="with-img">
|
||||||
<img class="rounded" :src="imguri + album.image" alt="" />
|
<img class="rounded-sm shadow-lg" :src="imguri + album.image" alt="" />
|
||||||
<PlayBtnVue />
|
<PlayBtn
|
||||||
|
:store="useAlbumStore"
|
||||||
|
:source="playSources.album"
|
||||||
|
:albumHash="album.albumhash"
|
||||||
|
:albumName="album.title"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4 class="title ellip" v-tooltip>
|
<h4 class="title ellip" v-tooltip>
|
||||||
{{ album.title }}
|
{{ album.title }}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="artist ellip">{{ album.albumartists[0].name }}</div>
|
<div class="artist ellip" @click.prevent.stop="() => {}">
|
||||||
|
<RouterLink
|
||||||
|
:to="{
|
||||||
|
name: Routes.artist,
|
||||||
|
params: { hash: album.albumartists[0].artisthash },
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ album.albumartists[0].name }}
|
||||||
|
</RouterLink>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</router-link>
|
</router-link>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
|
||||||
import { paths } from "../../config";
|
import { paths } from "../../config";
|
||||||
import { Album } from "../../interfaces";
|
import { Album } from "../../interfaces";
|
||||||
import { isLight } from "@/composables/colors/album";
|
import { isLight } from "@/composables/colors/album";
|
||||||
import PlayBtnVue from "./PlayBtn.vue";
|
import PlayBtn from "./PlayBtn.vue";
|
||||||
|
|
||||||
|
import useAlbumStore from "@/stores/pages/album";
|
||||||
|
import { playSources, Routes } from "@/composables/enums";
|
||||||
|
|
||||||
const imguri = paths.images.thumb.large;
|
const imguri = paths.images.thumb.large;
|
||||||
defineProps<{
|
defineProps<{
|
||||||
album: Album;
|
album: Album;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const isHovered = ref(false);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@ -64,15 +78,22 @@ const isHovered = ref(false);
|
|||||||
.with-img {
|
.with-img {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.play-btn {
|
||||||
|
transform: translateY(0);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.play-btn {
|
.play-btn {
|
||||||
$btn-width: 4rem;
|
$btn-width: 4rem;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 1rem;
|
bottom: 1rem;
|
||||||
right: calc((100% - $btn-width) / 2);
|
right: calc((100% - $btn-width) / 2);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(-1rem);
|
transform: translateY(1rem);
|
||||||
transition: all 0.25s;
|
transition: all 0.25s;
|
||||||
width: $btn-width;
|
width: $btn-width;
|
||||||
|
|
||||||
@ -86,7 +107,6 @@ const isHovered = ref(false);
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: -1;
|
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,12 +114,6 @@ const isHovered = ref(false);
|
|||||||
.bg {
|
.bg {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.play-btn {
|
|
||||||
// transition-delay: 0.25s;
|
|
||||||
transform: translateY(0);
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
@ -115,12 +129,21 @@ const isHovered = ref(false);
|
|||||||
margin-bottom: $smaller;
|
margin-bottom: $smaller;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.artist {
|
.artist {
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
opacity: 0.75;
|
opacity: 0.75;
|
||||||
|
|
||||||
|
a {
|
||||||
|
cursor: pointer !important;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<button
|
<button class="play-btn circular shadow-sm" @click.prevent.stop="handlePlay">
|
||||||
class="play-btn circular"
|
|
||||||
@click.prevent.stop="usePlayFrom(source, useQStore, store)"
|
|
||||||
>
|
|
||||||
<PlaySvg />
|
<PlaySvg />
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
@ -16,12 +13,29 @@ import { playSources } from "@/composables/enums";
|
|||||||
import usePlayFrom from "@/composables/usePlayFrom";
|
import usePlayFrom from "@/composables/usePlayFrom";
|
||||||
|
|
||||||
import PlaySvg from "../../assets/icons/play.svg";
|
import PlaySvg from "../../assets/icons/play.svg";
|
||||||
|
import { playFromAlbumCard } from "@/composables/usePlayFrom";
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
source: playSources;
|
source: playSources;
|
||||||
|
albumHash?: string;
|
||||||
|
albumName?: string;
|
||||||
store: typeof useAlbumStore | typeof usePlaylistStore;
|
store: typeof useAlbumStore | typeof usePlaylistStore;
|
||||||
color: string;
|
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
function handlePlay() {
|
||||||
|
switch (props.source) {
|
||||||
|
case playSources.album:
|
||||||
|
playFromAlbumCard(
|
||||||
|
useQStore,
|
||||||
|
props.albumHash || "",
|
||||||
|
props.albumName || ""
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@ -33,7 +47,5 @@ defineProps<{
|
|||||||
svg {
|
svg {
|
||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -15,8 +15,9 @@ export default function (queue: typeof useQStore) {
|
|||||||
const q = queue();
|
const q = queue();
|
||||||
window.addEventListener("keydown", (e: KeyboardEvent) => {
|
window.addEventListener("keydown", (e: KeyboardEvent) => {
|
||||||
const target = e.target as HTMLElement;
|
const target = e.target as HTMLElement;
|
||||||
// if alt is pressed, don't do anything
|
|
||||||
if (e.altKey) return;
|
if (e.altKey) return;
|
||||||
|
if (e.shiftKey) return;
|
||||||
|
|
||||||
let ctrlKey = e.ctrlKey;
|
let ctrlKey = e.ctrlKey;
|
||||||
|
|
||||||
function FocusedOnInput(target: HTMLElement) {
|
function FocusedOnInput(target: HTMLElement) {
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
import { playSources } from "@/composables/enums";
|
import { playSources } from "@/composables/enums";
|
||||||
|
|
||||||
import useAStore from "@/stores/pages/album";
|
import useAStore from "@/stores/pages/album";
|
||||||
import useArtistPageStore from "@/stores/pages/artist";
|
import useArtistPageStore from "@/stores/pages/artist";
|
||||||
import useFStore from "@/stores/pages/folder";
|
import useFStore from "@/stores/pages/folder";
|
||||||
import usePStore from "@/stores/pages/playlist";
|
import usePStore from "@/stores/pages/playlist";
|
||||||
import useQStore from "@/stores/queue";
|
import useQStore from "@/stores/queue";
|
||||||
import useSettingsStore from "@/stores/settings";
|
import useSettingsStore from "@/stores/settings";
|
||||||
|
import { useNotifStore } from "@/stores/notification";
|
||||||
|
|
||||||
import { getArtistTracks } from "./fetch/artists";
|
import { getArtistTracks } from "./fetch/artists";
|
||||||
|
import { getAlbumTracks } from "./fetch/album";
|
||||||
|
|
||||||
const queue = useQStore;
|
const queue = useQStore;
|
||||||
const folder = useFStore;
|
const folder = useFStore;
|
||||||
@ -86,4 +90,16 @@ async function utilPlayFromArtist(
|
|||||||
qu.play(index);
|
qu.play(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { utilPlayFromArtist };
|
async function playFromAlbumCard(
|
||||||
|
queue: typeof useQStore,
|
||||||
|
albumhash: string,
|
||||||
|
albumname: string
|
||||||
|
) {
|
||||||
|
const qu = queue();
|
||||||
|
|
||||||
|
const tracks = await getAlbumTracks(albumhash, useNotifStore);
|
||||||
|
qu.playFromAlbum(albumname, albumhash, tracks.tracks);
|
||||||
|
qu.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
export { utilPlayFromArtist, playFromAlbumCard };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user