fix: backend+frontend full audit - 15 bugs fixed across all files

This commit is contained in:
2026-07-13 04:07:18 +08:00
parent 532efb962f
commit 4f4df7e479
6 changed files with 13 additions and 11 deletions

View File

@@ -27,11 +27,12 @@ const U = {
escJs(s) {
if (!s) return '';
return String(s).replace(/\\/g,'\\\\').replace(/'/g,"\\'").replace(/\n/g,'\\n');
return String(s).replace(/\\/g,'\\\\').replace(/'/g,"\\'").replace(/"/g,'"').replace(/\n/g,'\\n');
},
showAlert(containerId, type, msg) {
const ct = document.getElementById(containerId || 'page-content');
if (!ct) return;
const el = document.createElement('div');
el.className = `alert alert-${type === 'success' ? 's' : type === 'error' ? 'e' : 'i'}`;
el.textContent = msg;
@@ -39,20 +40,21 @@ const U = {
setTimeout(() => el.remove(), 6000);
},
loading(ct) { ct.innerHTML = '<div class="loading"><i class="fas fa-spinner"></i><p>加载中...</p></div>'; },
loading(ct) { if (!ct) return; ct.innerHTML = '<div class="loading"><i class="fas fa-spinner"></i><p>加载中...</p></div>'; },
modal(title, html, w) {
const o = document.getElementById('modal-overlay');
if (!o) return;
document.getElementById('modal-title').textContent = title;
document.getElementById('modal-body').innerHTML = html;
if (w) o.querySelector('.modal-box').style.width = w;
o.querySelector('.modal-box').style.width = w || '';
o.classList.remove('hidden');
},
confirm(msg) {
return new Promise(resolve => {
this.modal('确认', `
<p>${msg}</p>
<p>${this.esc(msg)}</p>
<div class="modal-f"><button class="btn btn-o btn-confirm-cancel">取消</button><button class="btn btn-p btn-confirm-ok">确认</button></div>
`);
document.querySelector('.btn-confirm-cancel').onclick = () => { App.closeModal(); resolve(false); };