1. 新增了日志系统
2. 新增了添加新训练选择对应的GPU
This commit is contained in:
@@ -94,6 +94,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 自定义确认弹窗 -->
|
||||
<div id="confirmModal" class="hidden fixed inset-0 bg-black/50 z-50 flex items-center justify-center">
|
||||
<div class="bg-white rounded-xl shadow-xl max-w-sm w-full mx-4 overflow-hidden">
|
||||
<div class="p-6 text-center">
|
||||
<div id="confirmIcon" class="w-12 h-12 mx-auto mb-4 rounded-full bg-yellow-100 flex items-center justify-center">
|
||||
<i class="fa fa-exclamation text-xl text-yellow-600"></i>
|
||||
</div>
|
||||
<h3 id="confirmTitle" class="text-lg font-medium text-gray-800 mb-2"></h3>
|
||||
<p id="confirmMessage" class="text-gray-600 text-sm"></p>
|
||||
</div>
|
||||
<div class="px-6 pb-6 flex justify-center space-x-4">
|
||||
<button id="confirmCancelBtn" class="px-6 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 transition-colors">取消</button>
|
||||
<button id="confirmOkBtn" class="px-6 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 动态获取 API 基础地址
|
||||
const getApiBase = () => {
|
||||
@@ -263,17 +280,112 @@
|
||||
return 'bg-gray-50 text-gray-500';
|
||||
}
|
||||
|
||||
// 自定义确认弹窗
|
||||
function showConfirm(title, message, onConfirm) {
|
||||
const modal = document.getElementById('confirmModal');
|
||||
const modalTitle = document.getElementById('confirmTitle');
|
||||
const modalMessage = document.getElementById('confirmMessage');
|
||||
const cancelBtn = document.getElementById('confirmCancelBtn');
|
||||
const okBtn = document.getElementById('confirmOkBtn');
|
||||
|
||||
modalTitle.textContent = title;
|
||||
modalMessage.textContent = message;
|
||||
|
||||
modal.classList.remove('hidden');
|
||||
document.body.style.overflow = 'hidden';
|
||||
|
||||
cancelBtn.onclick = function() {
|
||||
modal.classList.add('hidden');
|
||||
document.body.style.overflow = '';
|
||||
};
|
||||
|
||||
okBtn.onclick = function() {
|
||||
modal.classList.add('hidden');
|
||||
document.body.style.overflow = '';
|
||||
if (typeof onConfirm === 'function') {
|
||||
onConfirm();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 自定义消息弹窗
|
||||
function showMessage(title, message, type = 'info', onConfirm) {
|
||||
const modal = document.getElementById('confirmModal');
|
||||
const modalTitle = document.getElementById('confirmTitle');
|
||||
const modalMessage = document.getElementById('confirmMessage');
|
||||
const cancelBtn = document.getElementById('confirmCancelBtn');
|
||||
const okBtn = document.getElementById('confirmOkBtn');
|
||||
|
||||
// 隐藏取消按钮,只显示确定按钮
|
||||
cancelBtn.classList.add('hidden');
|
||||
|
||||
modalTitle.textContent = title;
|
||||
modalMessage.innerHTML = message;
|
||||
|
||||
// 根据类型设置图标和按钮颜色
|
||||
const iconContainer = document.getElementById('confirmIcon');
|
||||
if (type === 'success') {
|
||||
iconContainer.className = 'w-12 h-12 mx-auto mb-4 rounded-full bg-green-100 flex items-center justify-center';
|
||||
iconContainer.innerHTML = '<i class="fa fa-check text-xl text-green-600"></i>';
|
||||
okBtn.className = 'px-6 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors';
|
||||
} else if (type === 'error') {
|
||||
iconContainer.className = 'w-12 h-12 mx-auto mb-4 rounded-full bg-red-100 flex items-center justify-center';
|
||||
iconContainer.innerHTML = '<i class="fa fa-times text-xl text-red-600"></i>';
|
||||
okBtn.className = 'px-6 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors';
|
||||
} else if (type === 'warning') {
|
||||
iconContainer.className = 'w-12 h-12 mx-auto mb-4 rounded-full bg-yellow-100 flex items-center justify-center';
|
||||
iconContainer.innerHTML = '<i class="fa fa-exclamation text-xl text-yellow-600"></i>';
|
||||
okBtn.className = 'px-6 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors';
|
||||
} else {
|
||||
iconContainer.className = 'w-12 h-12 mx-auto mb-4 rounded-full bg-blue-100 flex items-center justify-center';
|
||||
iconContainer.innerHTML = '<i class="fa fa-info text-xl text-blue-600"></i>';
|
||||
okBtn.className = 'px-6 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors';
|
||||
}
|
||||
|
||||
modal.classList.remove('hidden');
|
||||
document.body.style.overflow = 'hidden';
|
||||
|
||||
okBtn.onclick = function() {
|
||||
modal.classList.add('hidden');
|
||||
document.body.style.overflow = '';
|
||||
// 恢复取消按钮
|
||||
cancelBtn.classList.remove('hidden');
|
||||
if (typeof onConfirm === 'function') {
|
||||
onConfirm();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 操作函数(挂载到 window 以便 onclick 调用)
|
||||
window.viewReport = function(id) {
|
||||
alert('查看报告功能开发中');
|
||||
};
|
||||
|
||||
window.deleteTask = function(id) {
|
||||
if (confirm('确定要删除此评测任务吗?')) {
|
||||
alert('删除功能开发中');
|
||||
}
|
||||
showConfirm('确认删除', '确定要删除此评测任务吗?', () => {
|
||||
executeDeleteTask(id);
|
||||
});
|
||||
};
|
||||
|
||||
async function executeDeleteTask(id) {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/model-eval/${id}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.code === 0) {
|
||||
showMessage('成功', '删除成功', 'success', () => {
|
||||
loadTasks();
|
||||
});
|
||||
} else {
|
||||
showMessage('错误', result.message || '删除失败', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除评测任务失败:', error);
|
||||
showMessage('错误', '删除失败: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
window.addDimension = function() {
|
||||
window.location.href = 'model-dimension-create.html';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user