🐛 修复点击应用无法跳转问题

pull/81/MERGE
awenes 2024-08-05 12:20:38 +08:00
parent d09b73d797
commit 284ee9a9d2
1 changed files with 34 additions and 18 deletions

View File

@ -16,7 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import type { ActionType } from '@ant-design/pro-components'; import type { ActionType } from '@ant-design/pro-components';
import {PageContainer, ProCard, ProFormText, ProList, QueryFilter,} from '@ant-design/pro-components'; import {
PageContainer,
ProCard,
ProFormText,
ProList,
QueryFilter,
} from '@ant-design/pro-components';
import { Avatar, Badge, Card, Typography } from 'antd'; import { Avatar, Badge, Card, Typography } from 'antd';
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import { AppGroupList, AppList } from './data.d'; import { AppGroupList, AppList } from './data.d';
@ -55,7 +61,7 @@ const CardList = () => {
const [loading, setLoading] = useState<boolean | SpinProps | undefined>(false); const [loading, setLoading] = useState<boolean | SpinProps | undefined>(false);
const getItems = () => { const getItems = () => {
let data: { key: string; label: React.React.JSX.Element }[] = [ let data: { key: string; label: React.JSX.Element }[] = [
{ {
key: all, key: all,
label: ( label: (
@ -82,15 +88,25 @@ const CardList = () => {
const initSso = (idpInitUrl: string) => { const initSso = (idpInitUrl: string) => {
const div = window.document.createElement('div'); const div = window.document.createElement('div');
div.innerHTML = const a = document.createElement('a');
"<form action='" + a.href = idpInitUrl;
idpInitUrl + const form = document.createElement('form');
"' method='POST' name='auto_submit_form' style='display:none'>"; form.method = 'GET';
form.action = a.origin + a.pathname; // 使用URL的origin和pathname部分作为action
form.name = 'auto_submit_form';
form.style.display = 'none';
form.target = '_blank';
const queryParams = new URLSearchParams(a.search);
queryParams.forEach((value, key) => {
const input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = value;
form.appendChild(input);
});
div.appendChild(form);
document.body.appendChild(div); document.body.appendChild(div);
// eslint-disable-next-line @typescript-eslint/dot-notation form.submit();
document.forms['auto_submit_form'].setAttribute('target', '_blank');
// eslint-disable-next-line @typescript-eslint/dot-notation
document.forms['auto_submit_form'].submit();
document.body.removeChild(div); document.body.removeChild(div);
}; };