π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
β¨ Adds missing newwindow target for nav links (#2146)
Alicia Sykese7084ac04943
diff --git a/docs/configuring.md b/docs/configuring.mdindex 0697a85a..6acefec9 100644--- a/docs/configuring.md+++ b/docs/configuring.md@@ -86,7 +86,7 @@ The following file provides a reference of all supported configuration options.--- | --- | --- | ---**`title`** | `string` | Required | The text to display on the link button**`path`** | `string` | Required | The URL to navigate to when clicked. Can be relative (e.g. `/about`) or absolute (e.g. `https://example.com` or `http://192.168.1.1`)-**`target`** | `string` | _Optional_ | The opening method (external links only). Can be either `newtab`, `sametab`, `top` or `parent`. Defaults to `newtab`+**`target`** | `string` | _Optional_ | The opening method (external links only). Can be either `newtab`, `sametab`, `newwindow`, `top` or `parent`. Defaults to `newtab`**[β¬οΈ Back to Top](#configuring)**diff --git a/src/components/PageStrcture/Nav.vue b/src/components/PageStrcture/Nav.vueindex c76adae6..677a082c 100644--- a/src/components/PageStrcture/Nav.vue+++ b/src/components/PageStrcture/Nav.vue@@ -27,7 +27,7 @@:title="link.title"class="nav-item"rel="noopener noreferrer"- @click="closeIfBurger"+ @click="onLinkClick(link, $event)">{{ link.title }}</a></template></nav>@@ -36,7 +36,9 @@<script>import IconBurger from '@/assets/interface-icons/burger-menu.svg';-import { buildAllLinks, isHttpUrl, resolveLinkTarget } from '@/utils/NavLinks';+import {+ buildAllLinks, isHttpUrl, openLink, resolveLinkTarget,+} from '@/utils/NavLinks';const MOBILE_QUERY = '(max-width: 599px)';@@ -87,6 +89,7 @@ export default {if (!this.$el.contains(e.target)) this.isOpen = false;},closeIfBurger() { if (this.showBurger) this.isOpen = false; },+ onLinkClick(link, e) { openLink(link, e); this.closeIfBurger(); },isHttpUrl,resolveLinkTarget,},diff --git a/src/components/Settings/NavLinksSwitcher.vue b/src/components/Settings/NavLinksSwitcher.vueindex d91e411b..85c9a177 100644--- a/src/components/Settings/NavLinksSwitcher.vue+++ b/src/components/Settings/NavLinksSwitcher.vue@@ -10,7 +10,7 @@:href="link.path" :target="resolveLinkTarget(link)"class="nav-link" role="menuitem"rel="noopener noreferrer"- @click="$emit('close')">+ @click="onLinkClick(link, $event)">{{ link.title }}</a></template>@@ -18,7 +18,9 @@</template><script>-import { buildAllLinks, isHttpUrl, resolveLinkTarget } from '@/utils/NavLinks';+import {+ buildAllLinks, isHttpUrl, openLink, resolveLinkTarget,+} from '@/utils/NavLinks';export default {name: 'NavLinksSwitcher',@@ -30,7 +32,11 @@ export default {return buildAllLinks(this.$store, this.$route, nav);},},- methods: { isHttpUrl, resolveLinkTarget },+ methods: {+ isHttpUrl,+ resolveLinkTarget,+ onLinkClick(link, e) { openLink(link, e); this.$emit('close'); },+ },};</script>diff --git a/src/utils/NavLinks.js b/src/utils/NavLinks.jsindex 0591fb43..7101ae04 100644--- a/src/utils/NavLinks.js+++ b/src/utils/NavLinks.js@@ -13,6 +13,15 @@ export const resolveLinkTarget = (link) => {return '_blank';};+/* Intercept click to open the link in a separate popup window when configured */+export const openLink = (link, event) => {+ if (link && link.target === 'newwindow') {+ event.preventDefault();+ const { width, height } = window.screen;+ window.open(link.path, '_blank', `width=${width},height=${height},noopener,noreferrer`);+ }+};+/* Combined list of user-defined nav links + visible sub-pages for the current* view. Each entry: { path, title, target? }. Empty list means nothing to show. */export const buildAllLinks = (store, route, extraLinks = []) => {