@simonbackx/vue-app-navigation 2.14.1 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13 -3
- package/dist/src/utils/navigationHooks.d.ts +4 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1850,13 +1850,21 @@ function addCheckRoutesMountedHandler() {
|
|
|
1850
1850
|
return;
|
|
1851
1851
|
}
|
|
1852
1852
|
instance._didAddCheckRoutesMountedHandler = true;
|
|
1853
|
+
let doDeactivate = false;
|
|
1854
|
+
onBeforeUnmount(() => {
|
|
1855
|
+
if (component && doDeactivate) {
|
|
1856
|
+
component.checkRoutes = false;
|
|
1857
|
+
}
|
|
1858
|
+
});
|
|
1853
1859
|
onMounted(async () => {
|
|
1854
1860
|
if (component && component.checkRoutes) {
|
|
1855
|
-
|
|
1861
|
+
doDeactivate = true;
|
|
1856
1862
|
if ("_navigationCheckRoutesHandlers" in instance && Array.isArray(instance._navigationCheckRoutesHandlers)) {
|
|
1857
1863
|
for (const handler of instance._navigationCheckRoutesHandlers) {
|
|
1858
1864
|
if (typeof handler === "function") {
|
|
1859
|
-
await handler()
|
|
1865
|
+
if (await handler() === true) {
|
|
1866
|
+
return;
|
|
1867
|
+
}
|
|
1860
1868
|
} else {
|
|
1861
1869
|
console.error("Invalid checkRoutes handler", handler);
|
|
1862
1870
|
}
|
|
@@ -1866,7 +1874,9 @@ function addCheckRoutesMountedHandler() {
|
|
|
1866
1874
|
if ("_navigationNotCheckRoutesHandlers" in instance && Array.isArray(instance._navigationNotCheckRoutesHandlers)) {
|
|
1867
1875
|
for (const handler of instance._navigationNotCheckRoutesHandlers) {
|
|
1868
1876
|
if (typeof handler === "function") {
|
|
1869
|
-
await handler()
|
|
1877
|
+
if (await handler() === true) {
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1870
1880
|
} else {
|
|
1871
1881
|
console.error("Invalid not checkRoutes handler", handler);
|
|
1872
1882
|
}
|
|
@@ -67,7 +67,10 @@ export type NavigationOptions<T> = {
|
|
|
67
67
|
export declare function usePop(): (options?: PopOptions) => Promise<void> | undefined;
|
|
68
68
|
export declare function useNavigate(): <Params extends Record<string, unknown>>(prop1: string | Route<Params>, prop2?: RouteNavigationOptions<Params>) => Promise<void>;
|
|
69
69
|
export type DefaultRouteHandler = () => Promise<boolean>;
|
|
70
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Return true when the route has been handled and other route checks should not be executed.
|
|
72
|
+
*/
|
|
73
|
+
export type OnCheckRoutesHandler = () => Promise<void | boolean> | void | boolean;
|
|
71
74
|
export declare function onCheckRoutes(handler: OnCheckRoutesHandler): void;
|
|
72
75
|
export declare function onNotCheckRoutes(handler: OnCheckRoutesHandler): void;
|
|
73
76
|
export declare function defineRoutes(routes: (Route<any>[]) | (() => Promise<boolean | (Route<any>[])>)): void;
|