fix: 使用 inline onclick 方式关闭模态框,更可靠
This commit is contained in:
@@ -8,16 +8,14 @@ var refreshTimer = null;
|
|||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
loadConfig();
|
loadConfig();
|
||||||
refreshAll();
|
refreshAll();
|
||||||
|
});
|
||||||
|
|
||||||
// 点击模态框背景关闭
|
// 点击模态框背景关闭
|
||||||
document.querySelectorAll('.modal').forEach(function(modal) {
|
function closeModalOnBackground(event, modalId) {
|
||||||
modal.addEventListener('click', function(e) {
|
if (event.target.id === modalId) {
|
||||||
if (e.target === modal) {
|
document.getElementById(modalId).classList.remove('active');
|
||||||
modal.classList.remove('active');
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function loadConfig() {
|
function loadConfig() {
|
||||||
fetch(API_BASE + '/api/config')
|
fetch(API_BASE + '/api/config')
|
||||||
|
|||||||
@@ -156,8 +156,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 图片详情模态框 -->
|
<!-- 图片详情模态框 -->
|
||||||
<div class="modal" id="image-modal">
|
<div class="modal" id="image-modal" onclick="closeModalOnBackground(event, 'image-modal')">
|
||||||
<div class="modal-content">
|
<div class="modal-content" onclick="event.stopPropagation()">
|
||||||
<span class="modal-close" onclick="closeImageModal()">×</span>
|
<span class="modal-close" onclick="closeImageModal()">×</span>
|
||||||
<img id="modal-image" src="" alt="图片详情">
|
<img id="modal-image" src="" alt="图片详情">
|
||||||
<div class="modal-info">
|
<div class="modal-info">
|
||||||
@@ -177,4 +177,4 @@
|
|||||||
|
|
||||||
<script src="/static/app.js"></script>
|
<script src="/static/app.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>ml>
|
||||||
Reference in New Issue
Block a user