| | |
| | | NProgress.start(); |
| | | const userStore = useUserStore(); |
| | | next(); |
| | | if (isLogin()) { |
| | | if (userStore.role) { |
| | | next(); |
| | | } else { |
| | | try { |
| | | await userStore.info(); |
| | | next(); |
| | | } catch (error) { |
| | | await userStore.logout(); |
| | | next({ |
| | | name: 'login', |
| | | query: { |
| | | redirect: to.name, |
| | | ...to.query, |
| | | } as LocationQueryRaw, |
| | | }); |
| | | } |
| | | } |
| | | } else { |
| | | if (to.name === 'login') { |
| | | next(); |
| | | return; |
| | | } |
| | | next({ |
| | | name: 'login', |
| | | query: { |
| | | redirect: to.name, |
| | | ...to.query, |
| | | } as LocationQueryRaw, |
| | | }); |
| | | } |
| | | // if (isLogin()) { |
| | | // if (userStore.role) { |
| | | // next(); |
| | | // } else { |
| | | // try { |
| | | // await userStore.info(); |
| | | // next(); |
| | | // } catch (error) { |
| | | // await userStore.logout(); |
| | | // next({ |
| | | // name: 'login', |
| | | // query: { |
| | | // redirect: to.name, |
| | | // ...to.query, |
| | | // } as LocationQueryRaw, |
| | | // }); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // if (to.name === 'login') { |
| | | // next(); |
| | | // return; |
| | | // } |
| | | // next({ |
| | | // name: 'login', |
| | | // query: { |
| | | // redirect: to.name, |
| | | // ...to.query, |
| | | // } as LocationQueryRaw, |
| | | // }); |
| | | // } |
| | | }); |
| | | } |
| | |
| | | |
| | | <style lang="less" scoped> |
| | | .login-form { |
| | | |
| | | & |
| | | -wrapper { |
| | | &-wrapper { |
| | | width: 320px; |
| | | } |
| | | |
| | | & |
| | | -title { |
| | | &-title { |
| | | color: var(--color-text-1); |
| | | font-weight: 500; |
| | | font-size: 24px; |
| | | line-height: 32px; |
| | | } |
| | | |
| | | & |
| | | -sub-title { |
| | | &-sub-title { |
| | | color: var(--color-text-3); |
| | | font-size: 16px; |
| | | line-height: 24px; |
| | | } |
| | | |
| | | & |
| | | -error-msg { |
| | | &-error-msg { |
| | | height: 32px; |
| | | color: rgb(var(--red-6)); |
| | | line-height: 32px; |
| | | } |
| | | |
| | | & |
| | | -password-actions { |
| | | &-password-actions { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | } |
| | | |
| | | & |
| | | -register-btn { |
| | | &-register-btn { |
| | | color: var(--color-text-3) !important; |
| | | } |
| | | |
| | | } |
| | | </style> |