mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
use @vueuse/useClickOutside to hide context menu
This commit is contained in:
committed by
Mungai Njoroge
parent
a496d68439
commit
4e0837a627
@@ -53,19 +53,11 @@ import LeftSidebar from "./components/LeftSidebar/index.vue";
|
|||||||
const queue = useQStore();
|
const queue = useQStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const modal = useModalStore();
|
const modal = useModalStore();
|
||||||
const context_store = useContextStore();
|
|
||||||
const settings = useSettingsStore();
|
const settings = useSettingsStore();
|
||||||
const app_dom = document.getElementById("app") as HTMLElement;
|
|
||||||
|
|
||||||
queue.readQueue();
|
queue.readQueue();
|
||||||
handleShortcuts(useQStore);
|
handleShortcuts(useQStore);
|
||||||
|
|
||||||
app_dom.addEventListener("click", (e) => {
|
|
||||||
if (context_store.visible) {
|
|
||||||
context_store.hideContextMenu();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
(document.getElementById("acontent") as HTMLElement).scrollTo(0, 0);
|
(document.getElementById("acontent") as HTMLElement).scrollTo(0, 0);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ import { paths } from "@/config";
|
|||||||
import { formatSeconds } from "@/utils";
|
import { formatSeconds } from "@/utils";
|
||||||
import { Routes } from "@/composables/enums";
|
import { Routes } from "@/composables/enums";
|
||||||
|
|
||||||
|
|
||||||
import useQStore from "@/stores/queue";
|
import useQStore from "@/stores/queue";
|
||||||
import ArtistName from "@/components/shared/ArtistName.vue";
|
import ArtistName from "@/components/shared/ArtistName.vue";
|
||||||
import HotKeys from "@/components/LeftSidebar/NP/HotKeys.vue";
|
import HotKeys from "@/components/LeftSidebar/NP/HotKeys.vue";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="context-menu rounded shadow-lg"
|
class="context-menu rounded shadow-lg"
|
||||||
|
ref="contextMenu"
|
||||||
:class="[
|
:class="[
|
||||||
{ 'context-menu-visible': context.visible },
|
{ 'context-menu-visible': context.visible },
|
||||||
{ 'context-normalizedX': context.normalizedX },
|
{ 'context-normalizedX': context.normalizedX },
|
||||||
@@ -29,10 +30,30 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { onClickOutside } from "@vueuse/core";
|
||||||
|
|
||||||
import useContextStore from "../stores/context";
|
import useContextStore from "../stores/context";
|
||||||
import ContextItem from "./Contextmenu/ContextItem.vue";
|
import ContextItem from "./Contextmenu/ContextItem.vue";
|
||||||
|
|
||||||
const context = useContextStore();
|
const context = useContextStore();
|
||||||
|
|
||||||
|
const contextMenu = ref<HTMLElement>();
|
||||||
|
|
||||||
|
let clickCount = 0;
|
||||||
|
|
||||||
|
onClickOutside(contextMenu, (e) => {
|
||||||
|
if (!context.visible) {
|
||||||
|
clickCount = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clickCount++;
|
||||||
|
|
||||||
|
if (context.visible && clickCount == 2) {
|
||||||
|
context.hideContextMenu();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
clickCount = 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
<SongItem
|
<SongItem
|
||||||
:track="item.track"
|
:track="item.track"
|
||||||
:index="index + 1"
|
:index="index + 1"
|
||||||
:isCurrent="queue.currentid === item.trackid"
|
:isCurrent="queue.currentid === item.track.trackid"
|
||||||
:isCurrentPlaying="
|
:isCurrentPlaying="
|
||||||
queue.currentid === item.trackid && queue.playing
|
queue.currentid === item.track.trackid && queue.playing
|
||||||
"
|
"
|
||||||
@playThis="playFromQueue(index)"
|
@playThis="playFromQueue(index)"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user