Laravel Nova - 将 Nova 路径指向资源页面
Laravel Nova - Point Nova path to resource page
我需要将 Nova 路径指向资源。这样当用户登录时,他将定向到该特定资源。
我已在 /config/nova.php
中更新此路径:
'path' => '/crm/resources/clients'
现在登录后,我可以看到 URL 已更新。但该页面仍然是 Welcome Nova 页面。
对此有什么想法吗?
您可以创建自定义 Asset or Tool 以挂接到 Vue 路由器。在我们的特定案例中,我们希望重定向到我们的自定义工具而不是资源或仪表板。创建工具会生成一个 tool.js
文件,您可以在其中挂钩到 vue-router.
从仪表板重定向到命名路由
router.beforeEach((to, from, next) => {
if (to.name == "dashboard.custom") {
next({
name: "reports" // Route added by our tool
});
} else {
next();
}
});
从仪表板重定向到 资源索引
router.beforeEach((to, from, next) => {
if (to.name == "dashboard.custom") {
next({
name: "index",
params: {
resourceName: 'model' // replace with resource name
}
});
} else {
next();
}
});
注意resourceName
是索引路由中定义的动态段的名称。
我需要将 Nova 路径指向资源。这样当用户登录时,他将定向到该特定资源。
我已在 /config/nova.php
中更新此路径:
'path' => '/crm/resources/clients'
现在登录后,我可以看到 URL 已更新。但该页面仍然是 Welcome Nova 页面。
对此有什么想法吗?
您可以创建自定义 Asset or Tool 以挂接到 Vue 路由器。在我们的特定案例中,我们希望重定向到我们的自定义工具而不是资源或仪表板。创建工具会生成一个 tool.js
文件,您可以在其中挂钩到 vue-router.
从仪表板重定向到命名路由
router.beforeEach((to, from, next) => {
if (to.name == "dashboard.custom") {
next({
name: "reports" // Route added by our tool
});
} else {
next();
}
});
从仪表板重定向到 资源索引
router.beforeEach((to, from, next) => {
if (to.name == "dashboard.custom") {
next({
name: "index",
params: {
resourceName: 'model' // replace with resource name
}
});
} else {
next();
}
});
注意resourceName
是索引路由中定义的动态段的名称。