This commit is contained in:
孙小云 2026-02-04 18:25:21 +08:00
parent b0d956084c
commit 57edab1cb2
1 changed files with 15 additions and 3 deletions

View File

@ -1591,6 +1591,10 @@ class DeploymentServer:
background-color: #4caf50; background-color: #4caf50;
color: white; color: white;
}} }}
.table-item.active {{
background-color: #4caf50;
color: white;
}}
.sql-editor {{ .sql-editor {{
width: 100%; width: 100%;
min-height: 150px; min-height: 150px;
@ -1865,6 +1869,14 @@ class DeploymentServer:
// 查看表数据 // 查看表数据
function viewTable(dbName, tableName) {{ function viewTable(dbName, tableName) {{
// 更新表格选中状态
document.querySelectorAll('.table-item').forEach(item => {{
item.classList.remove('active');
if (item.textContent === tableName) {{
item.classList.add('active');
}}
}});
const sql = `SELECT * FROM \`${{tableName}}\` LIMIT 100`; const sql = `SELECT * FROM \`${{tableName}}\` LIMIT 100`;
document.getElementById('sqlEditor').value = sql; document.getElementById('sqlEditor').value = sql;
executeSQL(dbName); executeSQL(dbName);
@ -1992,7 +2004,7 @@ class DeploymentServer:
container_name = db_config.get('container_name', 'ruoyi-mysql') container_name = db_config.get('container_name', 'ruoyi-mysql')
# 通过 docker exec 连接到容器内的 MySQL # 通过 docker exec 连接到容器内的 MySQL
cmd = f"docker exec {container_name} mysql -uroot -ppassword -e 'SHOW DATABASES;'" cmd = f"docker exec {container_name} mysql -uroot -ppassword --default-character-set=utf8mb4 -e 'SHOW DATABASES;'"
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=10) result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=10)
if result.returncode != 0: if result.returncode != 0:
@ -2024,7 +2036,7 @@ class DeploymentServer:
container_name = db_config.get('container_name', 'ruoyi-mysql') container_name = db_config.get('container_name', 'ruoyi-mysql')
# 通过 docker exec 连接到容器内的 MySQL # 通过 docker exec 连接到容器内的 MySQL
cmd = f"docker exec {container_name} mysql -uroot -ppassword -e 'USE {db_name}; SHOW TABLES;'" cmd = f"docker exec {container_name} mysql -uroot -ppassword --default-character-set=utf8mb4 -e 'USE {db_name}; SHOW TABLES;'"
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=10) result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=10)
if result.returncode != 0: if result.returncode != 0:
@ -2062,7 +2074,7 @@ class DeploymentServer:
sql_escaped = sql.replace("'", "'\\''") sql_escaped = sql.replace("'", "'\\''")
# 通过 docker exec 执行 SQL # 通过 docker exec 执行 SQL
cmd = f"docker exec {container_name} mysql -uroot -ppassword {database} -e '{sql_escaped}' --batch" cmd = f"docker exec {container_name} mysql -uroot -ppassword --default-character-set=utf8mb4 {database} -e '{sql_escaped}' --batch"
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30) result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
if result.returncode != 0: if result.returncode != 0: