From ba41e99dba8874fabd6430e02f7820f34a32b11e Mon Sep 17 00:00:00 2001 From: zurdi Date: Sat, 31 Aug 2024 20:56:44 +0000 Subject: [PATCH 1/3] fix open game in a new tab in gallery/collection --- .../src/components/common/Game/AdminMenu.vue | 18 +++++++++- .../components/common/Game/Card/ActionBar.vue | 35 +++++++++++-------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/common/Game/AdminMenu.vue b/frontend/src/components/common/Game/AdminMenu.vue index bf04f389f..634f994bd 100644 --- a/frontend/src/components/common/Game/AdminMenu.vue +++ b/frontend/src/components/common/Game/AdminMenu.vue @@ -11,6 +11,7 @@ import type { Events } from "@/types/emitter"; import type { Emitter } from "mitt"; import { storeToRefs } from "pinia"; import { inject } from "vue"; +import { useRouter } from "vue-router"; // Props const props = defineProps<{ rom: SimpleRom }>(); @@ -20,8 +21,17 @@ const auth = storeAuth(); const collectionsStore = storeCollections(); const romsStore = storeRoms(); const { favCollection } = storeToRefs(collectionsStore); +const router = useRouter(); // Functions +function openInNewTab() { + const link = router.resolve({ + name: "rom", + params: { rom: props.rom.id }, + }); + window.open(link.href, "_blank"); +} + async function switchFromFavourites() { if (!favCollection.value) { await collectionApi @@ -53,7 +63,7 @@ async function switchFromFavourites() { } else { if (favCollection.value) { favCollection.value.roms = favCollection.value.roms.filter( - (id) => id !== props.rom.id + (id) => id !== props.rom.id, ); if (romsStore.currentCollection?.name.toLowerCase() == "favourites") { romsStore.remove([props.rom]); @@ -89,6 +99,12 @@ async function switchFromFavourites() {