| | |
| | | |
| | | // 路由加载前 |
| | | router.beforeEach(async (to, from, next) => { |
| | | console.log('to', to); |
| | | NProgress.configure({ showSpinner: false }); |
| | | if (to.meta.title) NProgress.start(); |
| | | const token = Session.get('token'); |
| | | if (to.path === '/login' && !token) { |
| | | next(); |
| | | NProgress.done(); |
| | | } else { |
| | | }else if ((to.path === '/register'||to.path==='/registerSuu') && !token) { |
| | | next(); |
| | | NProgress.done(); |
| | | } |
| | | else { |
| | | if (!token) { |
| | | next(`/login?redirect=${to.path}¶ms=${JSON.stringify(to.query ? to.query : to.params)}`); |
| | | Session.clear(); |