You can create a custom Asset or Tool to hook into the Vue Router. In our specific case, we wanted to redirect to our custom tool instead of a resource or the dashboard. Creating a tool generates a tool.js
file where it allows you to hook into the vue-router.
Redirect from the dashboard to a named route
router.beforeEach((to, from, next) => {
if (to.name == "dashboard.custom") {
next({
name: "reports" // Route added by our tool
});
} else {
next();
}
});
Redirect from the dashboard to a resource index
router.beforeEach((to, from, next) => {
if (to.name == "dashboard.custom") {
next({
name: "index",
params: {
resourceName: 'model' // replace with resource name
}
});
} else {
next();
}
});
Note resourceName
is the name of the dynamic segment defined in the index route.
