We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我这两天写自动登录,在路由中,让这个next搞的焦头烂额各种警告
最后看文档,已经移除但还支持,所以改了写法,完全不用next,世界清净了,我擦;好用的一B。
https://router.vuejs.org/zh/guide/advanced/navigation-guards.html https://github.com/vuejs/rfcs/blob/master/active-rfcs/0037-router-return-guards.md#motivation
// 下面如果去除我自动登录的代码,GeekAdmin的也可以更简洁 router.beforeEach(async (to: toRouteType, from) => { const userStore = useUserStore(); // 1.NProgress 开始 NProgress.start(); // 2.动态设置标题 const title = import.meta.env.VITE_GLOB_APP_TITLE; document.title = to.meta.title ? `${to.meta.title} - ${title}` : title; // 3.判断是访问登陆页,有 Token 就在当前页面,没有 Token 重置路由到登陆页 if (to.path.toLocaleLowerCase() === LOGIN_URL) { if (userStore.token) return { path: from.fullPath, replace: true }; } // 4.判断访问页面是否在路由白名单地址(静态路由)中,如果存在直接放行 if (!ROUTER_WHITE_LIST.includes(to.path)) { // 5.判断是否有 Token,没有重定向到 login 页面 if (!userStore.token && to.path.toLocaleLowerCase() !== LOGIN_URL) { // 6.企业微信自动OAuth登录 if (isWeWork()) { return await userStore.loginWeWork(); } return { path: LOGIN_URL, replace: true }; } } });
The text was updated successfully, but these errors were encountered:
No branches or pull requests
我这两天写自动登录,在路由中,让这个next搞的焦头烂额各种警告
最后看文档,已经移除但还支持,所以改了写法,完全不用next,世界清净了,我擦;好用的一B。
https://router.vuejs.org/zh/guide/advanced/navigation-guards.html
https://github.com/vuejs/rfcs/blob/master/active-rfcs/0037-router-return-guards.md#motivation
The text was updated successfully, but these errors were encountered: