登录页面改成主页
Showing
3 changed files
with
24 additions
and
21 deletions
| ... | @@ -38,10 +38,11 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -38,10 +38,11 @@ router.beforeEach(async (to, from, next) => { |
| 38 | settingsStore.settings.menu.menuMode !== 'single' && menuStore.setActived(to.path) | 38 | settingsStore.settings.menu.menuMode !== 'single' && menuStore.setActived(to.path) |
| 39 | // 如果已登录状态下,进入登录页会强制跳转到主页 | 39 | // 如果已登录状态下,进入登录页会强制跳转到主页 |
| 40 | if (to.name === 'login') { | 40 | if (to.name === 'login') { |
| 41 | next({ | 41 | // next({ |
| 42 | name: 'login', | 42 | // name: 'login', |
| 43 | replace: true, | 43 | // replace: true, |
| 44 | }) | 44 | // }) |
| 45 | window.location.href = userStore.idassLoginUrl; | ||
| 45 | } | 46 | } |
| 46 | else if (to.name == 'scenes') { | 47 | else if (to.name == 'scenes') { |
| 47 | next({ | 48 | next({ |
| ... | @@ -130,12 +131,13 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -130,12 +131,13 @@ router.beforeEach(async (to, from, next) => { |
| 130 | next() | 131 | next() |
| 131 | } | 132 | } |
| 132 | else if (!to.query.code && to.name !== 'login') { | 133 | else if (!to.query.code && to.name !== 'login') { |
| 133 | next({ | 134 | window.location.href = userStore.idassLoginUrl; |
| 134 | name: 'login', | 135 | // next({ |
| 135 | query: { | 136 | // name: 'login', |
| 136 | redirect: to.fullPath !== '/' ? to.fullPath : undefined, | 137 | // query: { |
| 137 | }, | 138 | // redirect: to.fullPath !== '/' ? to.fullPath : undefined, |
| 138 | }) | 139 | // }, |
| 140 | // }) | ||
| 139 | } | 141 | } |
| 140 | else { | 142 | else { |
| 141 | next() | 143 | next() | ... | ... |
| ... | @@ -27,14 +27,14 @@ interface metaInfoRaw { | ... | @@ -27,14 +27,14 @@ interface metaInfoRaw { |
| 27 | 27 | ||
| 28 | // 固定路由(默认路由) | 28 | // 固定路由(默认路由) |
| 29 | const constantRoutes: RouteRecordRaw[] = [ | 29 | const constantRoutes: RouteRecordRaw[] = [ |
| 30 | { | 30 | // { |
| 31 | path: '/login', | 31 | // path: '/login', |
| 32 | name: 'login', | 32 | // name: 'login', |
| 33 | component: () => import('@/views/login.vue'), | 33 | // component: () => import('@/views/login.vue'), |
| 34 | meta: { | 34 | // meta: { |
| 35 | title: '登录', | 35 | // title: '登录', |
| 36 | }, | 36 | // }, |
| 37 | }, | 37 | // }, |
| 38 | { | 38 | { |
| 39 | path: '/register', | 39 | path: '/register', |
| 40 | name: 'register', | 40 | name: 'register', | ... | ... |
| ... | @@ -27,7 +27,7 @@ const useUserStore = defineStore( | ... | @@ -27,7 +27,7 @@ const useUserStore = defineStore( |
| 27 | const isLogin = ref(token.value ? true : false);//退出登录。 | 27 | const isLogin = ref(token.value ? true : false);//退出登录。 |
| 28 | const getTokenPromise: any = ref(null); | 28 | const getTokenPromise: any = ref(null); |
| 29 | /* idass的登录页面url,退出登录需要跳转到登录页。*/ | 29 | /* idass的登录页面url,退出登录需要跳转到登录页。*/ |
| 30 | const idassLoginUrl = 'https://idaas-test.csbr.cn/login'; | 30 | const idassLoginUrl = ref('https://idaas-test.csbr.cn/login'); |
| 31 | const timer: any = ref(null); | 31 | const timer: any = ref(null); |
| 32 | //获取token. | 32 | //获取token. |
| 33 | function getToken(data, state) { | 33 | function getToken(data, state) { |
| ... | @@ -175,7 +175,7 @@ const useUserStore = defineStore( | ... | @@ -175,7 +175,7 @@ const useUserStore = defineStore( |
| 175 | menuStore.setActived(0) | 175 | menuStore.setActived(0) |
| 176 | tabbar.value = [] | 176 | tabbar.value = [] |
| 177 | tabbarMap.value = {} | 177 | tabbarMap.value = {} |
| 178 | window.location.href = idassLoginUrl + '?logout=1'; | 178 | window.location.href = idassLoginUrl.value + '?logout=1'; |
| 179 | }); | 179 | }); |
| 180 | } else { | 180 | } else { |
| 181 | let hasCode = localStorage.getItem('code'); | 181 | let hasCode = localStorage.getItem('code'); |
| ... | @@ -194,7 +194,7 @@ const useUserStore = defineStore( | ... | @@ -194,7 +194,7 @@ const useUserStore = defineStore( |
| 194 | tabbar.value = [] | 194 | tabbar.value = [] |
| 195 | tabbarMap.value = {} | 195 | tabbarMap.value = {} |
| 196 | if (hasCode) { | 196 | if (hasCode) { |
| 197 | window.location.href = idassLoginUrl + '?logout=1'; | 197 | window.location.href = idassLoginUrl.value + '?logout=1'; |
| 198 | } else { | 198 | } else { |
| 199 | router.push({ | 199 | router.push({ |
| 200 | name: 'login', | 200 | name: 'login', |
| ... | @@ -312,6 +312,7 @@ const useUserStore = defineStore( | ... | @@ -312,6 +312,7 @@ const useUserStore = defineStore( |
| 312 | permissions, | 312 | permissions, |
| 313 | isLogin, | 313 | isLogin, |
| 314 | isLoginOut, | 314 | isLoginOut, |
| 315 | idassLoginUrl, | ||
| 315 | getTokenPromise, | 316 | getTokenPromise, |
| 316 | getToken, | 317 | getToken, |
| 317 | login, | 318 | login, | ... | ... |
-
Please register or sign in to post a comment