@tntd/reference
Version:
<!-- * @Author: 周泽飞 zefei.zhou@tongdun.net * @Date: 2024-12-03 10:07:54 * @LastEditors: 郑泳健 * @LastEditTime: 2026-01-20 15:55:03 * @FilePath: /tntd3/packages/reference/README.md * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: http
46 lines (45 loc) • 1.3 kB
JavaScript
import React from 'react';
export default (props) => {
const { children, href, unmountHandle, jumpFun, iframeJump,...rest } = props;
if (window.__isMultiTab__) {
return (
<a
onClick={(evt) => {
evt.preventDefault();
if (unmountHandle && typeof unmountHandle === 'function') {
unmountHandle();
}
let pathName = href;
if (href && href.includes('?')) {
pathName = href?.split('?')[0];
}
if(jumpFun && typeof jumpFun==='function'){
jumpFun(href);
return
}
const isInIframe = window?.self !== window?.top;
if(iframeJump && isInIframe){
if (pathName === window.location.pathname) {
window.parent.location.href = href;
} else {
window.parent.open(href);
}
return
}
// if (pathName === window.location.pathname) {
window.location.href = href;
// } else {
// window.push(href);
// }
}}
>
{children}
</a>
);
}
return (
<a href={href} {...rest}>
{children}
</a>
);
};