1. 增加了模型管理页面的功能
2. 修改了若干的bug
This commit is contained in:
@@ -217,10 +217,12 @@
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="relative group">
|
||||
<img src="https://picsum.photos/id/1005/32/32" class="w-8 h-8 rounded-full cursor-pointer" alt="用户头像">
|
||||
<div class="absolute right-0 top-full mt-1 bg-white rounded shadow-lg py-1 hidden group-hover:block border border-gray-100 min-w-[140px] z-50">
|
||||
<a href="login.html" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 whitespace-nowrap">
|
||||
<i class="fa fa-sign-out mr-1"></i>退出登录
|
||||
</a>
|
||||
<div class="absolute right-0 top-full pt-2 hidden group-hover:block z-50">
|
||||
<div class="bg-white rounded shadow-lg py-1 border border-gray-100 min-w-[140px]">
|
||||
<a href="login.html" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 whitespace-nowrap">
|
||||
<i class="fa fa-sign-out mr-1"></i>退出登录
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -309,12 +311,24 @@
|
||||
createText: '上传数据集',
|
||||
columns: [
|
||||
{ title: '数据集名称', key: 'name' },
|
||||
{ title: '类型', key: 'type' },
|
||||
{ title: '数据类型', key: 'type', render: (val) => {
|
||||
const textMap = {
|
||||
'train': '训练数据',
|
||||
'test': '测试数据',
|
||||
'val': '验证数据',
|
||||
'other': '其他'
|
||||
};
|
||||
const displayText = textMap[val?.toLowerCase()] || val || '-';
|
||||
return '<span class="px-2 py-1 rounded text-xs bg-blue-100 text-blue-700">' + displayText + '</span>';
|
||||
}},
|
||||
{ title: '存储位置', key: 'storage_type', render: (val) => {
|
||||
if (val === 'local') return '<span class="px-2 py-1 rounded text-xs bg-blue-100 text-blue-700">本地存储</span>';
|
||||
if (val === 'minio') return '<span class="px-2 py-1 rounded text-xs bg-orange-100 text-orange-700">MinIO</span>';
|
||||
if (val === 'cloud') return '<span class="px-2 py-1 rounded text-xs bg-green-100 text-green-700">云存储</span>';
|
||||
return '<span class="px-2 py-1 rounded text-xs bg-gray-100 text-gray-700">' + (val || '-') + '</span>';
|
||||
const textMap = {
|
||||
'local': '本地存储',
|
||||
'minio': 'MinIO',
|
||||
'cloud': '云存储'
|
||||
};
|
||||
const displayText = textMap[val] || val || '-';
|
||||
return '<span class="px-2 py-1 rounded text-xs bg-green-100 text-green-700">' + displayText + '</span>';
|
||||
}},
|
||||
{ title: '大小', key: 'size', render: (val) => (val && val !== '0 B' && val !== '0') ? val : '-' },
|
||||
{ title: '数据条数', key: 'count', render: (val) => val || 0 },
|
||||
@@ -340,9 +354,25 @@
|
||||
createText: '添加模型',
|
||||
columns: [
|
||||
{ title: '模型名称', key: 'name' },
|
||||
{ title: '模型类型', key: 'type' },
|
||||
{ title: '模型版本', key: 'version' },
|
||||
{ title: '模型路径', key: 'path', render: (val) => val || '-' },
|
||||
{ title: '模型类型', key: 'type', render: (val) => {
|
||||
const textMap = {
|
||||
'LLM': '大语言模型',
|
||||
'CV': '计算机视觉',
|
||||
'NLP': '自然语言处理',
|
||||
'Embedding': '向量模型',
|
||||
'Other': '其他'
|
||||
};
|
||||
const displayText = textMap[val] || val || '-';
|
||||
return '<span class="px-2 py-1 rounded text-xs bg-blue-100 text-blue-700">' + displayText + '</span>';
|
||||
}},
|
||||
{ title: '模型来源', key: 'model_source', render: (val) => {
|
||||
const textMap = {
|
||||
'local': '本地模型',
|
||||
'online': '在线模型'
|
||||
};
|
||||
const displayText = textMap[val] || val || '-';
|
||||
return '<span class="px-2 py-1 rounded text-xs bg-green-100 text-green-700">' + displayText + '</span>';
|
||||
}},
|
||||
{ title: '描述', key: 'description', render: (val) => val || '-' },
|
||||
{ title: '创建时间', key: 'create_time', render: (val) => val ? new Date(val).toLocaleString('zh-CN') : '-' }
|
||||
],
|
||||
@@ -383,8 +413,30 @@
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const pageParam = urlParams.get('page');
|
||||
|
||||
// 加载页面(优先使用URL参数)
|
||||
const defaultPage = pageParam || 'fine-tune';
|
||||
// 确定加载的页面
|
||||
let defaultPage = 'fine-tune'; // 默认页面
|
||||
|
||||
if (pageParam) {
|
||||
// URL有参数,优先使用URL参数
|
||||
defaultPage = pageParam;
|
||||
} else {
|
||||
// 没有URL参数,使用 sessionStorage 或 localStorage
|
||||
// 优先使用 sessionStorage(仅当前会话有效)
|
||||
const sessionPage = sessionStorage.getItem('lastPage');
|
||||
const localPage = localStorage.getItem('lastPage');
|
||||
const savedPage = sessionPage || localPage;
|
||||
|
||||
if (savedPage && tableConfigs[savedPage]) {
|
||||
defaultPage = savedPage;
|
||||
}
|
||||
// 否则保持默认 'fine-tune'
|
||||
}
|
||||
|
||||
// 保存到 sessionStorage(当前会话)
|
||||
sessionStorage.setItem('lastPage', defaultPage);
|
||||
|
||||
console.log('Page init - URL param:', pageParam, 'saved:', sessionStorage.getItem('lastPage'), 'loading:', defaultPage);
|
||||
|
||||
loadPage(defaultPage);
|
||||
|
||||
// 更新侧边栏高亮状态
|
||||
@@ -405,6 +457,10 @@
|
||||
const page = this.dataset.page;
|
||||
loadPage(page);
|
||||
|
||||
// 保存当前页面到 sessionStorage(当前会话有效,关闭浏览器后失效)
|
||||
sessionStorage.setItem('lastPage', page);
|
||||
localStorage.setItem('lastPage', page); // 同时保存到 localStorage
|
||||
|
||||
// 更新高亮状态
|
||||
document.querySelectorAll('.nav-link').forEach(l => {
|
||||
l.classList.remove('sidebar-item-active');
|
||||
@@ -495,6 +551,9 @@
|
||||
if (api === 'dataset-manage') {
|
||||
// 跳转到数据集创建页面进行编辑
|
||||
window.location.href = `dataset-create.html?id=${id}`;
|
||||
} else if (api === 'model-manage') {
|
||||
// 跳转到模型创建页面进行编辑
|
||||
window.location.href = `model-manage-create.html?id=${id}`;
|
||||
} else {
|
||||
showMessage('提示', '编辑功能开发中...', 'info');
|
||||
}
|
||||
@@ -508,6 +567,26 @@
|
||||
window.open(`${baseUrl}/api/dataset-manage/download/${datasetId}`, '_blank');
|
||||
}
|
||||
|
||||
// 筛选表格
|
||||
function filterTable() {
|
||||
const searchInput = document.getElementById('tableSearchInput');
|
||||
if (!searchInput) return;
|
||||
|
||||
const keyword = searchInput.value.toLowerCase().trim();
|
||||
const tbody = document.querySelector('#page-content table tbody');
|
||||
if (!tbody) return;
|
||||
|
||||
const rows = tbody.querySelectorAll('tr');
|
||||
rows.forEach(row => {
|
||||
const text = row.querySelector('td')?.textContent?.toLowerCase() || '';
|
||||
if (keyword === '' || text.includes(keyword)) {
|
||||
row.style.display = '';
|
||||
} else {
|
||||
row.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 渲染表格页面
|
||||
function renderTablePage(config, data) {
|
||||
const createButton = config.hasCreate ? `
|
||||
@@ -516,6 +595,16 @@
|
||||
</button>
|
||||
` : '';
|
||||
|
||||
// 搜索框(模型管理和数据集管理)
|
||||
const searchBox = (config.api === 'model-manage' || config.api === 'dataset-manage') ? `
|
||||
<div class="relative">
|
||||
<input type="text" id="tableSearchInput" placeholder="搜索${config.title}..."
|
||||
class="w-72 pl-9 pr-3 py-1.5 rounded border border-gray-300 text-sm focus:outline-none focus:border-primary focus:ring-1 focus:border-primary"
|
||||
oninput="filterTable()">
|
||||
<i class="fa fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
|
||||
</div>
|
||||
` : '';
|
||||
|
||||
const columns = config.columns;
|
||||
const hasData = data && data.length > 0;
|
||||
|
||||
@@ -524,6 +613,7 @@
|
||||
<div class="flex items-center justify-between p-4 border-b border-gray-100">
|
||||
<h2 class="text-lg font-medium">${config.title}</h2>
|
||||
<div class="flex items-center space-x-3">
|
||||
${searchBox}
|
||||
${createButton}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1079,8 +1169,12 @@
|
||||
|
||||
// 页面加载后初始化并启动定时器
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
initGPUList();
|
||||
startRefreshTimer();
|
||||
// 只在平台性能页面初始化GPU列表
|
||||
const gpuCountEl = document.getElementById('gpuCount');
|
||||
if (gpuCountEl) {
|
||||
initGPUList();
|
||||
startRefreshTimer();
|
||||
}
|
||||
});
|
||||
|
||||
function saveConfig() {
|
||||
|
||||
Reference in New Issue
Block a user