重定向逻辑优化

main
xuechunyuan 3 years ago
parent 939307af33
commit 5297f086b6
  1. 12
      src/page/login/index.vue
  2. 4
      src/permission.js
  3. 7
      src/router/page/index.js

@ -4,14 +4,14 @@
</template>
<script>
import { mapGetters } from "vuex";
import {getToken} from '@/util/auth'
// import {getToken} from '@/util/auth'
export default {
name: "login",
components: {},
data() {
return {
loading: false
loading: true
};
},
watch: {
@ -31,20 +31,20 @@ export default {
methods: {
handleLogin() {
const ssotoken = this.$route.query.SSOToken;
const token = getToken();
const token = "";//getToken();
console.log('ssotken',ssotoken, '=======')
if (token) {
this.$router.push({ path: this.tagWel.value });
}else{
this.loading = true;
// this.loading = true;
this.$store
.dispatch("LoginBySso", {SSOToken: ssotoken,grantType:'yawei',fallbackUrl: ssotoken ? '' : window.location.href})
.then(() => {
this.loading = false;
// this.loading = false;
console.log('=============登录成功')
this.$router.replace({ path: this.tagWel.value });
},err => {
this.loading = false;
// this.loading = false;
console.log('err=======res',err)
if(err.error == 'invalid_request') {
// let url = err.error_description+'?SSOToken=' + encodeURIComponent(window.location);

@ -18,7 +18,7 @@ router.beforeEach((to, from, next) => {
if (store.getters.isLock && to.path !== lockPage) { //如果系统激活锁屏,全部跳转到锁屏页
next({path: lockPage})
} else if (to.path === '/newlogin') { //如果登录成功访问登录页跳转到主页
next({path: '/'})
next({path: '/wel/index'})
} else {
//如果用户信息为空则获取用户信息,获取用户信息失败,跳转到登录页
if (store.getters.token.length === 0) {
@ -57,8 +57,6 @@ router.beforeEach((to, from, next) => {
//判断是否需要认证,没有登录访问去登录页
if (meta.isAuth === false) {
next()
} else if(to.path == '/wel/index') {
next('/login')
} else {
next('/newlogin')
}

@ -69,8 +69,13 @@ export default [{
{
path: '/',
name: '主页',
redirect: '/wel'
redirect: '/login'
},
// {
// path: '/',
// name: '主页',
// redirect: '/wel'
// },
{
path: '/myiframe',
component: Layout,

Loading…
Cancel
Save