feat(easy-admin): update window open URL for new tab button

- Change the URL for the "New tab open" button to use the iframe's content URL
- Add fallback to current window URL if iframe content URL cannot be accessed
- Improve user experience by opening the correct URL in a new tab

Signed-off-by: wolfcode <37436228+wolf-leo@users.noreply.github.com>
This commit is contained in:
wolfcode
2024-10-28 18:26:26 +08:00
parent 47ef5d9f10
commit 846b8ffafc

View File

@@ -1000,9 +1000,17 @@ define(["jquery", "tableSelect"], function ($, tableSelect) {
},
success: function (layero, index) {
if (window.CONFIG.IFRAME_OPEN_TOP == '1') {
let iframeUrl = ``
try {
let iframeId = $('iframe:eq(0)').attr('id')
let iframe = document.getElementById(iframeId)
iframeUrl = iframe.contentWindow.location.href
} catch (e) {
iframeUrl = location.href
}
let _winTopBtn = `
<span class="_winTopBtn layui-btn layui-btn-primary layui-btn-xs"
style="position: absolute;top: 14px;right: 120px;color: #fff;border-color: #fff;" onclick="window.open(location.href)">
style="position: absolute;top: 14px;right: 120px;color: #fff;border-color: #fff;" onclick="window.open('${iframeUrl}')">
新标签页打开
</span>`
$('.layui-layer-iframe').append(_winTopBtn)