@tntd/reference
Version:
<!-- * @Author: 周泽飞 zefei.zhou@tongdun.net * @Date: 2024-12-03 10:07:54 * @LastEditors: 周泽飞 zefei.zhou@tongdun.net * @LastEditTime: 2024-12-03 10:11:41 * @FilePath: /tntd3/packages/reference/README.md * @Description: 这是默认设置,请设置`customMade`, 打开koroFi
59 lines (58 loc) • 2.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var __rest = void 0 && (void 0).__rest || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
var _default = exports["default"] = function _default(props) {
var children = props.children,
href = props.href,
unmountHandle = props.unmountHandle,
jumpFun = props.jumpFun,
iframeJump = props.iframeJump,
rest = __rest(props, ["children", "href", "unmountHandle", "jumpFun", "iframeJump"]);
if (window.__isMultiTab__) {
return _react["default"].createElement("a", {
onClick: function onClick(evt) {
evt.preventDefault();
if (unmountHandle && typeof unmountHandle === 'function') {
unmountHandle();
}
var pathName = href;
if (href && href.includes('?')) {
pathName = href === null || href === void 0 ? void 0 : href.split('?')[0];
}
if (jumpFun && typeof jumpFun === 'function') {
jumpFun(href);
return;
}
var isInIframe = (window === null || window === void 0 ? void 0 : window.self) !== (window === null || window === void 0 ? void 0 : 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);
}
return _react["default"].createElement("a", Object.assign({
href: href
}, rest), children);
};