1. 我的模型添加成功

2. 评估维度页面创建成功
This commit is contained in:
2026-01-29 16:39:21 +08:00
parent e494c4ce50
commit 49393fefa0
9 changed files with 46 additions and 38 deletions

View File

@@ -23,7 +23,7 @@
</a> </a>
</div> </div>
<div class="nav-item-wrapper"> <div class="nav-item-wrapper">
<a href="model-manage.html" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors"> <a href="main.html?page=my-models" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
<i class="fa fa-database w-5 text-center"></i> <i class="fa fa-database w-5 text-center"></i>
<span class="ml-2">我的模型</span> <span class="ml-2">我的模型</span>
</a> </a>

View File

@@ -117,7 +117,7 @@
</a> </a>
</div> </div>
<div class="nav-item-wrapper"> <div class="nav-item-wrapper">
<a href="model-manage.html" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors"> <a href="main.html?page=my-models" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
<i class="fa fa-database w-5 text-center"></i> <i class="fa fa-database w-5 text-center"></i>
<span class="ml-2">我的模型</span> <span class="ml-2">我的模型</span>
</a> </a>

View File

@@ -120,7 +120,7 @@
</a> </a>
</div> </div>
<div class="nav-item-wrapper"> <div class="nav-item-wrapper">
<a href="model-manage.html" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors"> <a href="main.html?page=my-models" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
<i class="fa fa-database w-5 text-center"></i> <i class="fa fa-database w-5 text-center"></i>
<span class="ml-2">我的模型</span> <span class="ml-2">我的模型</span>
</a> </a>

View File

@@ -122,7 +122,7 @@
</a> </a>
</div> </div>
<div class="nav-item-wrapper"> <div class="nav-item-wrapper">
<a href="model-manage.html" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors"> <a href="main.html?page=my-models" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
<i class="fa fa-database w-5 text-center"></i> <i class="fa fa-database w-5 text-center"></i>
<span class="ml-2">我的模型</span> <span class="ml-2">我的模型</span>
</a> </a>

View File

@@ -200,7 +200,7 @@
</a> </a>
</div> </div>
<div class="nav-item-wrapper"> <div class="nav-item-wrapper">
<a href="model-manage.html" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors"> <a href="main.html?page=my-models" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
<i class="fa fa-database w-5 text-center"></i> <i class="fa fa-database w-5 text-center"></i>
<span class="ml-2">我的模型</span> <span class="ml-2">我的模型</span>
</a> </a>
@@ -437,16 +437,16 @@
}, },
'my-models': { 'my-models': {
title: '我的模型', title: '我的模型',
api: 'my-models', api: 'model-manage/trained-models',
dataPath: 'models', // 特殊处理API返回的是 {data: {models: [...]}} 格式
hasCreate: false, hasCreate: false,
columns: [ columns: [
{ title: '模型名称', key: 'name' }, { title: '模型名称', key: 'name' },
{ title: '类型', key: 'type' }, { title: '训练方法', key: 'train_methods', render: (val) => val && val[0] ? val[0].name : '-' },
{ title: '版本', key: 'version' }, { title: '模型路径', key: 'path', render: (val) => `<span class="text-xs text-gray-500 truncate max-w-xs block" title="${val}">${val}</span>` },
{ title: '描述', key: 'description' },
{ title: '创建时间', key: 'create_time', render: (val) => val ? new Date(val).toLocaleString('zh-CN') : '-' } { title: '创建时间', key: 'create_time', render: (val) => val ? new Date(val).toLocaleString('zh-CN') : '-' }
], ],
actions: ['deploy', 'eval', 'delete'] actions: ['view', 'delete']
}, },
'model-eval': { 'model-eval': {
title: '模型评测', title: '模型评测',
@@ -607,7 +607,8 @@
'detail': '详情', 'detail': '详情',
'edit': '编辑', 'edit': '编辑',
'compare': '开始对话', 'compare': '开始对话',
'chat': '对话' 'chat': '对话',
'view': '去推理'
}; };
// 训练进度缓存 // 训练进度缓存
@@ -966,7 +967,11 @@
} else if (config.isTools) { } else if (config.isTools) {
container.innerHTML = renderToolsPage(config); container.innerHTML = renderToolsPage(config);
} else { } else {
const data = await fetchData(`${API_BASE}/${config.api}`); let data = await fetchData(`${API_BASE}/${config.api}`);
// 如果配置了 dataPath从返回数据中提取指定字段
if (config.dataPath && typeof data === 'object' && data !== null) {
data = data[config.dataPath] || [];
}
currentPageData = data; // 保存当前页面数据 currentPageData = data; // 保存当前页面数据
container.innerHTML = renderTablePage(config, data); container.innerHTML = renderTablePage(config, data);
@@ -1369,6 +1374,8 @@
onclick = `startCompare(${item.id})`; onclick = `startCompare(${item.id})`;
} else if (action === 'logs' && config.api === 'fine-tune') { } else if (action === 'logs' && config.api === 'fine-tune') {
onclick = `navigateToTrainingLog(${item.id})`; onclick = `navigateToTrainingLog(${item.id})`;
} else if (action === 'view' && config.api === 'model-manage/trained-models') {
onclick = `viewTrainedModel('${item.name}', '${item.train_methods?.[0]?.name || '-'}', '${item.path || ''}')`;
} else { } else {
onclick = `showMessage('提示', '${actionLabels[action] || action}功能开发中...', 'info')`; onclick = `showMessage('提示', '${actionLabels[action] || action}功能开发中...', 'info')`;
} }
@@ -3157,6 +3164,14 @@
document.body.style.overflow = ''; document.body.style.overflow = '';
} }
// 查看已训练模型详情
window.viewTrainedModel = function(name, method, path) {
const message = '<p class="mb-2">模型名称:' + name + '</p>' +
'<p class="mb-2">训练方法:' + method + '</p>' +
'<p class="text-sm text-gray-500 break-all">路径:' + path + '</p>';
showMessage('模型详情', message, 'info');
};
// 确认弹窗(两个按钮)- 使用 window 确保全局可访问 // 确认弹窗(两个按钮)- 使用 window 确保全局可访问
window.showConfirm = function(title, message, onConfirm, onCancel, type = 'info') { window.showConfirm = function(title, message, onConfirm, onCancel, type = 'info') {
const modal = document.getElementById('customModal'); const modal = document.getElementById('customModal');

View File

@@ -5,17 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>添加评测维度 / 远光软件微调平台</title> <title>添加评测维度 / 远光软件微调平台</title>
<script src="../lib/tailwindcss/tailwind.js"></script> <script src="../lib/tailwindcss/tailwind.js"></script>
<script>
if (typeof console !== 'undefined' && console.warn) {
const originalWarn = console.warn;
console.warn = function(...args) {
if (args[0] && args[0].includes && args[0].includes('cdn.tailwindcss.com')) {
return;
}
originalWarn.apply(console, args);
};
}
</script>
<link href="../lib/font-awesome/css/font-awesome.min.css" rel="stylesheet"> <link href="../lib/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<style> <style>
/* 侧边栏滑块动画 */ /* 侧边栏滑块动画 */
@@ -216,7 +205,7 @@
</a> </a>
</div> </div>
<div class="nav-item-wrapper"> <div class="nav-item-wrapper">
<a href="model-manage.html" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors"> <a href="main.html?page=my-models" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
<i class="fa fa-database w-5 text-center"></i> <i class="fa fa-database w-5 text-center"></i>
<span class="ml-2">我的模型</span> <span class="ml-2">我的模型</span>
</a> </a>
@@ -467,15 +456,13 @@
</div> </div>
<script> <script>
// 使用 IIFE 避免全局变量污染 // API 基础地址 - 使用 config.yaml 中的 app.port (7861)
(function() {
// API 基础地址 - 优先使用 main.html 中定义的全局变量
const getApiBase = () => { const getApiBase = () => {
const protocol = window.location.protocol; const protocol = window.location.protocol;
const hostname = window.location.hostname; const hostname = window.location.hostname;
return `${protocol}//${hostname}:7861/api`; return `${protocol}//${hostname}:7861/api`;
}; };
const API_BASE = typeof window.API_BASE !== 'undefined' ? window.API_BASE : getApiBase(); const API_BASE = getApiBase();
// 加载评测模型列表(用途为 evaluation 的模型) // 加载评测模型列表(用途为 evaluation 的模型)
async function loadEvalModels() { async function loadEvalModels() {
@@ -1317,7 +1304,7 @@
} }
this._onConfirm = null; this._onConfirm = null;
}; };
})(); }
</script> </script>
<!-- 自定义消息弹窗 --> <!-- 自定义消息弹窗 -->

View File

@@ -126,7 +126,7 @@
</a> </a>
</div> </div>
<div class="nav-item-wrapper"> <div class="nav-item-wrapper">
<a href="model-manage.html" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors"> <a href="main.html?page=my-models" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
<i class="fa fa-database w-5 text-center"></i> <i class="fa fa-database w-5 text-center"></i>
<span class="ml-2">我的模型</span> <span class="ml-2">我的模型</span>
</a> </a>

View File

@@ -114,7 +114,7 @@
</a> </a>
</div> </div>
<div class="nav-item-wrapper"> <div class="nav-item-wrapper">
<a href="model-manage.html" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors"> <a href="main.html?page=my-models" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
<i class="fa fa-database w-5 text-center"></i> <i class="fa fa-database w-5 text-center"></i>
<span class="ml-2">我的模型</span> <span class="ml-2">我的模型</span>
</a> </a>

View File

@@ -107,7 +107,7 @@
</a> </a>
</div> </div>
<div class="nav-item-wrapper"> <div class="nav-item-wrapper">
<a href="model-manage.html" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors"> <a href="main.html?page=my-models" data-page="my-models" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
<i class="fa fa-database w-5 text-center"></i> <i class="fa fa-database w-5 text-center"></i>
<span class="ml-2">我的模型</span> <span class="ml-2">我的模型</span>
</a> </a>
@@ -306,8 +306,10 @@
</main> </main>
<script> <script>
console.log('[DEBUG] model-manage.html 脚本开始加载');
// 使用 IIFE 避免全局变量污染 // 使用 IIFE 避免全局变量污染
(function() { (function() {
console.log('[DEBUG] model-manage.html IIFE 开始执行');
// API 基础地址 - 优先使用 main.html 中定义的全局变量 // API 基础地址 - 优先使用 main.html 中定义的全局变量
const getApiBase = () => { const getApiBase = () => {
const protocol = window.location.protocol; const protocol = window.location.protocol;
@@ -722,7 +724,11 @@
} }
// 页面加载时初始化 // 页面加载时初始化
try {
loadModels(); loadModels();
} catch (e) {
console.error('初始化失败:', e);
}
})(); })();
</script> </script>
</body> </body>