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

fix: 免登修改

parent b9465cdf
Pipeline #73670 passed with stages
...@@ -23,12 +23,10 @@ const Login = forwardRef((props, _ref) => { ...@@ -23,12 +23,10 @@ const Login = forwardRef((props, _ref) => {
const param = params.getParams('token')?.replaceAll(';', '&'); const param = params.getParams('token')?.replaceAll(';', '&');
return param ? decodeURIComponent(escape(param)) : null; return param ? decodeURIComponent(escape(param)) : null;
}); });
const [authCode] = useState(() => { const [authCode] = useState(() => {
const param = params.getParams('authCode')?.replaceAll(';', '&'); const param = params.getParams('authCode')?.replaceAll(';', '&');
return param ? decodeURIComponent(escape(param)) : null; return param ? decodeURIComponent(escape(param)) : null;
}); });
// 需要在 GetGateWay 和 GetConfig 之后再执行登录。避免信息错落乱 // 需要在 GetGateWay 和 GetConfig 之后再执行登录。避免信息错落乱
const hasLogin = useRef(); const hasLogin = useRef();
useEffect(() => { useEffect(() => {
...@@ -40,56 +38,40 @@ const Login = forwardRef((props, _ref) => { ...@@ -40,56 +38,40 @@ const Login = forwardRef((props, _ref) => {
hasLogin.current !== true && hasLogin.current !== true &&
window.hasLogin !== true window.hasLogin !== true
) { ) {
appService hasLogin.current = true;
.checkFreeLogin({ window.hasLogin = true;
token, if (window.globalConfig && window.globalConfig.hasGateWay) {
authCode, appService
}) .authorizationToken({
.then(response => { loginName: token,
if (response?.data) { type: 'token',
hasLogin.current = true; generateType: params.getParams('generateType') || '',
window.hasLogin = true; })
if (window.globalConfig && window.globalConfig.hasGateWay) { .then(res => {
appService if (res.code === 0) {
.authorizationToken({ const { data } = res;
loginName: token, props.updateConfig &&
type: 'token', props.updateConfig(
generateType: params.getParams('generateType') || '', Object.assign({}, window.globalConfig, {
}) access_token: data.access_token,
.then(res => { token: data.user_token,
if (res.code === 0) { }),
const { data } = res; );
props.updateConfig && return data;
props.updateConfig(
Object.assign({}, window.globalConfig, {
access_token: data.access_token,
token: data.user_token,
}),
);
return data;
}
message.error({
duration: 3,
content: `授权失败:${res.msg}`,
});
action && action.events.emit('loginError', res.msg);
return Promise.reject(res);
})
.then(res => {
action.transformLoginHander(res, false);
});
} else {
action.init();
} }
return response?.data; message.error({
} duration: 3,
message.error({ content: `授权失败:${res.msg}`,
duration: 3, });
content: `授权失败`, action && action.events.emit('loginError', res.msg);
return Promise.reject(res);
})
.then(res => {
action.transformLoginHander(res, false);
}); });
action && action.events.emit('loginError', '授权失败'); } else {
return Promise.reject(response); action.init();
}); }
} }
}, [action, action.globalConfig, props.global]); }, [action, action.globalConfig, props.global]);
......
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