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