diff --git a/amoro-web/src/main.ts b/amoro-web/src/main.ts index cc9d2047da..dd257eb2dc 100644 --- a/amoro-web/src/main.ts +++ b/amoro-web/src/main.ts @@ -71,16 +71,17 @@ RegisterComponents(app); finally { const store = useStore() router.beforeEach((to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => { - if (to.fullPath === '/login') { - if (store.userInfo.userName) { - return next('/') - } + // if no username in store and not go to login page, should redirect to login page + if (!store.userInfo.userName && to.path !== '/login') { store.setHistoryPath({ path: from.path, - query: { ...from.query }, + query: from.query, }) + next('/login') + } + else { + next() } - next() }) app.use(router) diff --git a/amoro-web/src/views/login/index.vue b/amoro-web/src/views/login/index.vue index 4818d09d9f..8092322d8f 100644 --- a/amoro-web/src/views/login/index.vue +++ b/amoro-web/src/views/login/index.vue @@ -18,7 +18,7 @@ limitations under the License.