summaryrefslogtreecommitdiff
path: root/packages/client
diff options
context:
space:
mode:
Diffstat (limited to 'packages/client')
-rw-r--r--packages/client/src/nirax.ts5
-rw-r--r--packages/client/src/ui/deck.vue7
2 files changed, 12 insertions, 0 deletions
diff --git a/packages/client/src/nirax.ts b/packages/client/src/nirax.ts
index cae4edaf18..6db6335669 100644
--- a/packages/client/src/nirax.ts
+++ b/packages/client/src/nirax.ts
@@ -66,6 +66,7 @@ export class Router extends EventEmitter<{
private currentKey = Date.now().toString();
public currentRoute: ShallowRef<RouteDef | null> = shallowRef(null);
+ public navHook: ((path: string) => boolean) | null = null;
constructor(routes: Router['routes'], currentPath: Router['currentPath']) {
super();
@@ -192,6 +193,10 @@ export class Router extends EventEmitter<{
}
public push(path: string) {
+ if (this.navHook) {
+ const cancel = this.navHook(path);
+ if (cancel) return;
+ }
const beforePath = this.currentPath;
this.navigate(path, null);
this.emit('push', {
diff --git a/packages/client/src/ui/deck.vue b/packages/client/src/ui/deck.vue
index 7433264794..b3b9ddd556 100644
--- a/packages/client/src/ui/deck.vue
+++ b/packages/client/src/ui/deck.vue
@@ -65,6 +65,13 @@ import { $i } from '@/account';
import { i18n } from '@/i18n';
import { mainRouter } from '@/router';
+if (deckStore.state.navWindow) {
+ mainRouter.navHook = (path) => {
+ os.pageWindow(path);
+ return true;
+ };
+}
+
const isMobile = ref(window.innerWidth <= 500);
window.addEventListener('resize', () => {
isMobile.value = window.innerWidth <= 500;