[英]Laravel Nova - Point Nova path to resource page
I need to point Nova path to a resouce.我需要将 Nova 路径指向资源。 So that when a user login, he`ll directed to that particular resource.
这样当用户登录时,他将定向到该特定资源。
I have updated this path in /config/nova.php
:我已经在
/config/nova.php
更新了这个路径:
'path' => '/crm/resources/clients'
Now after login, I can see the URL updated.现在登录后,我可以看到更新的 URL。 But the page is still Welcome Nova page.
但该页面仍然是 Welcome Nova 页面。
Any idea on this?对此有什么想法吗?
You can create a custom Asset or Tool to hook into the Vue Router.您可以创建自定义资产或工具以连接到 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.创建一个工具会生成一个
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();
}
});
Note resourceName
is the name of the dynamic segment defined in the index route.注意
resourceName
是索引路由中定义的动态段的名称。
The path
settings in config/nova.php
is the URI path where Nova will be accessible from. config/nova.php
的path
设置是可从其中访问Nova的URI路径。 For example if you set path' => '/crm
, then client resource index URL will be /crm/resources/clients
instead of /nova/resources/clients
. 例如,如果您设置
path' => '/crm
,那么客户端资源索引URL将是/crm/resources/clients
而不是/nova/resources/clients
。 It doesn't control the login redirect path. 它不控制登录重定向路径。
You can edit the redirectPath()
function in nova/src/Http/Controllers/LoginController.php
. 您可以在
nova/src/Http/Controllers/LoginController.php
编辑redirectPath()
函数。
public function redirectPath()
{
return Nova::path() . '/resources/clients';
}
Important : I'm not sure whether editing file under nova
folder is a good practice. 重要提示 :我不确定在
nova
文件夹下编辑文件是否是一个好习惯。 In future when update the version the changes may override. 将来在更新版本时,更改可能会被覆盖。 So please be aware of it.
因此,请注意这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.