fix: 修改登录跳转逻辑

This commit is contained in:
NICE CODE BY DEV 2024-03-20 18:07:04 +08:00
parent c821b7e428
commit 13bac87293
4 changed files with 613 additions and 154 deletions

View File

@ -18,6 +18,7 @@
"@ant-design/pro-components": "^2.6.49",
"@umijs/max": "^4.1.1",
"@zhst/communal-cabinet": "^0.3.0",
"@zhst/func": "^0.8.1",
"antd": "^5.14.1",
"cross-env": "^7.0.3"
},

File diff suppressed because it is too large Load Diff

View File

@ -69,8 +69,8 @@ export const qiankun = {
],
lifeCycles: {
// 所有子应用在挂载完成时,打印 props 信息
async afterMount(props: any) {
console.log('子应用已全部加载:', props);
async afterMount() {
// console.log('子应用已全部加载:', props);
},
},
};

View File

@ -4,15 +4,14 @@
import bg from '@/assets/ai-video.png';
import loginController from '@/services/login';
import { getValueByUrlParams } from '@/utils/format';
import { history, useModel, useRequest } from '@umijs/max';
import { Login } from '@zhst/communal-cabinet';
import { getValueByUrl } from '@zhst/func';
import { Spin } from 'antd';
import React from 'react';
const LoginPage = () => {
const { setGlobalState } = useModel('@@qiankunStateForSlave');
const urlJson = getValueByUrlParams(history.location.search);
const { run, loading } = useRequest((params) => {
return loginController.login(params);
@ -22,7 +21,19 @@ const LoginPage = () => {
run({ username: values.account, password: values.password }).then(
(res: any) => {
if (res.token) {
history.push(`${urlJson?.get('to')}?token=${res.token}` || '/', res);
const baseUrl =
getValueByUrl('to', history.location.search) ||
getValueByUrl('from', history.location.search);
// @ts-ignore
let jumpUrlObj = new URL(baseUrl);
if (jumpUrlObj.origin === location.origin) {
history.push(`${baseUrl || '/'}?token=${res.token}`, res);
} else {
location.href = `${baseUrl}?token=${res.token}`;
}
setGlobalState(res);
}
},