This commit is contained in:
孙小云 2026-02-04 17:43:23 +08:00
parent d19de44668
commit 21b8bc2560
1 changed files with 37 additions and 0 deletions

View File

@ -1803,6 +1803,43 @@ class DeploymentServer:
// 加载表列表
loadTables(dbName);
// 加载SQL历史记录
loadSQLHistory(dbName);
}}
// 加载SQL历史记录
function loadSQLHistory(dbName) {{
fetch(`/api/database/history?db=${{dbName}}`)
.then(response => response.json())
.then(data => {{
const historyPanel = document.getElementById('historyPanel');
const historyContainer = document.getElementById('historyContainer');
if (data.success && data.history && data.history.length > 0) {{
historyPanel.style.display = 'block';
historyContainer.innerHTML = data.history.map(sql =>
`<div class="history-item" onclick="loadHistorySQL('${{sql.replace(/'/g, "\\\\'").replace(/"/g, '&quot;')}}')">${{escapeHtml(sql)}}</div>`
).join('');
}} else {{
historyPanel.style.display = 'none';
}}
}})
.catch(error => {{
console.error('加载历史记录失败:', error);
}});
}}
// 加载历史SQL到编辑器
function loadHistorySQL(sql) {{
document.getElementById('sqlEditor').value = sql;
}}
// HTML转义函数
function escapeHtml(text) {{
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}}
// 加载表列表