Commit 77b8a7ad authored by 杨思琦's avatar 杨思琦

fix: iframe添加自定义参数

parent 9b70963d
Pipeline #94756 passed with stages
......@@ -10,12 +10,32 @@ import styles from './index.less';
import Hoc from './HocContainer';
import useFullScreen from './useFullScreen';
const TabWidget = props => {
function addParamToUrl(url, params) {
if (params.length) {
try {
params.forEach((item) => {
const value = _.get(window, item);
if (value) {
var regex = new RegExp('([?&])' + item + '=.*?(&|$)', 'i');
if (url.match(regex)) {
url = url.replace(regex, '$1' + item + '=' + value + '$2');
} else {
url += (url.indexOf('?') === -1 ? '?' : '&') + item + '=' + value;
}
}
})
} catch (error) {
}
}
return url;
}
const params = Object.assign({}, props.params, {
fullscreen: !(props.params !== undefined && props.params.fullscreen === 'true'),
});
const { linkUrl, fullscreen, bgColor } = params;
const { linkUrl, fullscreen, bgColor, extraParams = '' } = params;
const newLink = linkUrl.replaceAll('@', '#').replaceAll('*', '?').replaceAll('$', '|').replaceAll('!', '&');
const link = extraParams !== '' && extraParams.split ? addParamToUrl(newLink, extraParams.split(',')) : newLink;
const [ref, isFullscreen, handleFullScreen, handleExit] = useFullScreen(fullscreen);
const goToPath = (name, data, widgetId) => {
try {
......@@ -90,9 +110,9 @@ const TabWidget = props => {
)}
</div>
</div>
{newLink ? (
{link ? (
<Iframe
url={newLink}
url={link}
width="100%"
height="100%"
display="block"
......
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