Commit feecce34 authored by 杨思琦's avatar 杨思琦

fix: 修复client

parent df7457e1
Pipeline #64571 passed with stages
...@@ -98,25 +98,30 @@ class Login { ...@@ -98,25 +98,30 @@ class Login {
site: this.getLocalSiteBytoken(token), site: this.getLocalSiteBytoken(token),
'request.preventCache': Date.now(), 'request.preventCache': Date.now(),
ignoreSite: true, ignoreSite: true,
}).then(response => { })
if (response && response.code === 0) { .then(response => {
self.globalConfig.userInfo = window?.globalConfig?.transformUserInfo?.(response.data) ?? {}; if (response && response.code === 0) {
self.updateConfig && self.updateConfig(self.globalConfig); self.globalConfig.userInfo = window?.globalConfig?.transformUserInfo?.(response.data) ?? {};
self.getUserInfoAndConfig(); self.updateConfig && self.updateConfig(self.globalConfig);
} else { self.getUserInfoAndConfig();
self.logout && self.logout(); } else {
if (params.getParams('token')) { self.logout && self.logout();
// token免登录失败,回到登录页,防止reload造成死循环 if (params.getParams('token')) {
window.location.href = `${window.location.origin}`; // token免登录失败,回到登录页,防止reload造成死循环
return false; window.location.href = `${window.location.origin}`;
} return false;
if (self.globalConfig.style === 'ios' && self.globalConfig.loginTemplate === 'IOSCloud.html') { }
window.location.href = `${window.location.origin}`; if (self.globalConfig.style === 'ios' && self.globalConfig.loginTemplate === 'IOSCloud.html') {
return false; window.location.href = `${window.location.origin}`;
return false;
}
window.location.reload();
} }
window.location.reload(); })
} .catch(error => {
}); this.handleLoginError();
Logger.log('获取用户配置失败');
});
} }
writeLogs() { writeLogs() {
...@@ -182,7 +187,6 @@ class Login { ...@@ -182,7 +187,6 @@ class Login {
getWebConfig(token, getIndustry) { getWebConfig(token, getIndustry) {
const self = this; const self = this;
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
// 获取网站配置的同时,预先获取到mqtt配置,注册进子应用 // 获取网站配置的同时,预先获取到mqtt配置,注册进子应用
Promise.all([ Promise.all([
noticeService.getMqttSiteCode({ 'request.preventCache': Date.now() }), noticeService.getMqttSiteCode({ 'request.preventCache': Date.now() }),
...@@ -701,11 +705,16 @@ class Login { ...@@ -701,11 +705,16 @@ class Login {
self.updateConfig && self.updateConfig(self.globalConfig); self.updateConfig && self.updateConfig(self.globalConfig);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
message.error('登录失败');
if (self.goLogin()) { if (self.goLogin()) {
return false; return false;
} }
// self.handleLoginError(failCallback); // self.handleLoginError(failCallback);
} }
})
.catch(error => {
this.handleLoginError();
Logger.log('获取用户配置失败');
}); });
} else { } else {
self.handleLoginError(); self.handleLoginError();
......
...@@ -60,7 +60,9 @@ export const AppInitState = () => { ...@@ -60,7 +60,9 @@ export const AppInitState = () => {
}; };
const client = getClient(); const client = getClient();
if (sessionStorage.getItem('client') && sessionStorage.getItem('client') !== client) {
sessionStorage.setItem('client', client);
}
let config = window.globalConfig || {}; let config = window.globalConfig || {};
// eslint-disable-next-line no-undef, no-restricted-globals // eslint-disable-next-line no-undef, no-restricted-globals
createStoreage.remove(`__PANDA_STORE__${location.hostname}`); createStoreage.remove(`__PANDA_STORE__${location.hostname}`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment