|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
import { createRouter, createWebHistory } from 'vue-router'; |
|
|
|
|
import Layout from '@/layout/index.vue'; |
|
|
|
|
import store from '@/store'; |
|
|
|
|
import { refreshToken, casLogin } from '@/api/auth'; |
|
|
|
|
import '@/utils/fineClubSDK'; |
|
|
|
|
import { refreshToken } from '@/api/auth'; |
|
|
|
|
// import '@/utils/fineClubSDK';
|
|
|
|
|
import { getUid, getExpiresTime } from '@/utils/cookie'; |
|
|
|
|
import { delUrlParams } from '@/utils/urlQuery'; |
|
|
|
|
|
|
|
|
@ -345,6 +345,7 @@ let getdate = parseInt(new Date().getTime() / 1000);
|
|
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
|
// const { title } = to.meta;
|
|
|
|
|
// document.title = getPageTitle(title);
|
|
|
|
|
// console.log('to====',to);
|
|
|
|
|
|
|
|
|
|
const get_ticket = to.query.ticket || 0; |
|
|
|
|
const get_type = to.query.type ? to.query.type : '0'; |
|
|
|
@ -365,7 +366,25 @@ router.beforeEach((to, from, next) => {
|
|
|
|
|
return getUid() || 0; |
|
|
|
|
} |
|
|
|
|
window.fineClub.config({ app, getLoginUid, debug: isDev, dev: isDev }); |
|
|
|
|
window.fineClub.autoReloadOnLoginChange({ loginUrl: process.env.VUE_APP_ID_URL + '/login/signin/?app=edu&protocol=cas&referrer=' + encodeURIComponent(window.location.href) }); |
|
|
|
|
|
|
|
|
|
// 监听登录
|
|
|
|
|
function callback(data) { |
|
|
|
|
console.log('callback_data', data); |
|
|
|
|
if (!get_ticket && data.uid > 0) { |
|
|
|
|
console.log('跳转到通行证登录'); |
|
|
|
|
let ticket_login_url = '/v1/user/cas/get/ticket/?redirect='+to.path+'&service='+process.env.VUE_APP_EDU_URL+'/v1/user/cas/edu/login/'; |
|
|
|
|
window.location.href = ticket_login_url; |
|
|
|
|
} |
|
|
|
|
if (!data.uid) { |
|
|
|
|
console.log('监听到登出', 'del_token'); |
|
|
|
|
store.commit('del_token'); |
|
|
|
|
window.location.reload(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
window.fineClub.onLoginChange(callback); |
|
|
|
|
// if(!getUid()){
|
|
|
|
|
// callback({uid:73851});
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (to.meta.title) { |
|
|
|
|
document.title = to.meta.title; |
|
|
|
@ -386,23 +405,6 @@ router.beforeEach((to, from, next) => {
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
next(); |
|
|
|
|
}, 500); |
|
|
|
|
} else if (get_ticket) { |
|
|
|
|
casLogin(get_ticket).then((res) => {
|
|
|
|
|
if (res.code === 200 && res.status != -1) { |
|
|
|
|
console.log('casLogin', res); |
|
|
|
|
store.commit('set_token', res.data); |
|
|
|
|
setTimeout(function () { |
|
|
|
|
// parent.window.location.replace(process.env.VUE_APP_EDU_URL + to.path);
|
|
|
|
|
// parent.location.reload();
|
|
|
|
|
let jumpUrl = delUrlParams(location.href,['ticket','sid']); |
|
|
|
|
console.log('jumpUrl',jumpUrl); |
|
|
|
|
parent.window.location.replace(jumpUrl); |
|
|
|
|
}, 250); |
|
|
|
|
} else { |
|
|
|
|
next(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}else if (get_type === 'logout') { |
|
|
|
|
console.log('logout', 'del_token'); |
|
|
|
|
store.commit('del_token'); |
|
|
|
|