You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.0 KiB
59 lines
2.0 KiB
var isMobile = /(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent);
|
|
|
|
var loading = {
|
|
show: function (msg) {
|
|
$('#loadingToast').show();
|
|
},
|
|
hide: function () {
|
|
$('#loadingToast').hide();
|
|
}
|
|
};
|
|
//cas begin
|
|
var query = new URLSearchParams(window.location.search);
|
|
var ticket = query.get('ticket');
|
|
if (ticket) {
|
|
var url = '/IoTCenter/api/v1/Project/CasLogin?ticket=' + ticket + "&home=" + encodeURIComponent(window.location.protocol + "//" + window.location.host);
|
|
setTimeout(function () { window.location.href = url; }, 0);
|
|
}
|
|
else {
|
|
var accessToken = query.get('accessToken');
|
|
var refreshToken = query.get('refreshToken');
|
|
if (accessToken && refreshToken) {
|
|
localStorage.setItem('accessToken', accessToken);
|
|
localStorage.setItem('refreshToken', refreshToken);
|
|
store.state.token.accessToken = accessToken;
|
|
store.state.token.refreshToken = refreshToken;
|
|
}
|
|
else {
|
|
var isAuthenticated = false;
|
|
if (store.state.token.accessToken) {
|
|
console.log('hastoken');
|
|
var jwt = jwt_decode(store.state.token.accessToken);
|
|
isAuthenticated = jwt.exp * 1000 >= new Date().getTime();
|
|
}
|
|
if (!isAuthenticated) {
|
|
localStorage.removeItem('accessToken');
|
|
localStorage.removeItem('refreshToken');
|
|
store.state.token.accessToken = null;
|
|
store.state.token.refreshToken = null;
|
|
axios.post("/IoTCenter/api/v1/site/getSite").then(function (response) {
|
|
if (response.data.sso) {
|
|
var url = response.data.sso + '/login?targetService=' + encodeURIComponent(window.location.protocol + "//" + window.location.host);
|
|
window.location.href = url;
|
|
}
|
|
}).catch(function (error) {
|
|
console.log(error);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
//cas end
|
|
|
|
const app = new Vue({
|
|
el: '#app',
|
|
store: store,
|
|
router,
|
|
mounted: function () {
|
|
}
|
|
});
|