441 lines
21 KiB
HTML
441 lines
21 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>上传数据集 / 远光软件微调平台</title>
|
||
<script src="../lib/tailwindcss/tailwind.js"></script>
|
||
<link href="../lib/font-awesome/css/font-awesome.min.css" rel="stylesheet">
|
||
<style>
|
||
.sidebar-section-title {
|
||
padding: 0.5rem 1rem;
|
||
font-size: 0.75rem;
|
||
color: rgba(191, 203, 217, 0.7);
|
||
font-weight: 500;
|
||
text-transform: uppercase;
|
||
letter-spacing: 0.05em;
|
||
}
|
||
.nav-link:hover {
|
||
background-color: rgba(0, 21, 41, 0.2);
|
||
}
|
||
.form-input {
|
||
width: 100%;
|
||
padding: 0.5rem 0.75rem;
|
||
border: 1px solid #d1d5db;
|
||
border-radius: 0.5rem;
|
||
font-size: 0.875rem;
|
||
transition: border-color 0.2s, outline 0.2s;
|
||
}
|
||
.form-input:focus {
|
||
border-color: #1890ff;
|
||
outline: none;
|
||
}
|
||
.form-select {
|
||
width: 100%;
|
||
padding: 0.5rem 0.75rem;
|
||
border: 1px solid #d1d5db;
|
||
border-radius: 0.5rem;
|
||
font-size: 0.875rem;
|
||
transition: border-color 0.2s, outline 0.2s;
|
||
appearance: none;
|
||
background-color: white;
|
||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
|
||
background-position: right 0.5rem center;
|
||
background-repeat: no-repeat;
|
||
background-size: 1.5em 1.5em;
|
||
padding-right: 2.5rem;
|
||
}
|
||
.form-select:focus {
|
||
border-color: #1890ff;
|
||
outline: none;
|
||
}
|
||
.radio-dot {
|
||
width: 0.5rem;
|
||
height: 0.5rem;
|
||
border-radius: 50%;
|
||
background-color: transparent;
|
||
transition: all 0.2s;
|
||
}
|
||
.upload-area:hover,
|
||
.upload-area.drag-over {
|
||
border-color: #1890ff;
|
||
background-color: rgba(24, 144, 255, 0.05);
|
||
}
|
||
.bg-primary { background-color: #1890ff; }
|
||
.text-primary { color: #1890ff; }
|
||
.border-primary { border-color: #1890ff; }
|
||
:root { --primary: #1890ff; --danger: #f5222d; --success: #52c41a; }
|
||
</style>
|
||
</head>
|
||
<body class="antialiased bg-gray-50 flex h-screen overflow-hidden">
|
||
<!-- 侧边导航 -->
|
||
<aside class="w-64 text-[#bfcbd9] flex-shrink-0 hidden md:block flex flex-col h-full" style="background-color: #001529;">
|
||
<!-- 平台LOGO区域 -->
|
||
<div class="p-4 border-b border-[#001529]/30 flex items-center">
|
||
<img src="../assets/logo/logo.png" alt="Logo" class="w-6 h-6 object-contain mr-2">
|
||
<span class="text-white font-medium">远光软件微调平台</span>
|
||
</div>
|
||
|
||
<!-- 导航主区域 -->
|
||
<nav class="flex-1 overflow-y-auto py-2">
|
||
<!-- 第一分区:模型服务 -->
|
||
<div class="sidebar-section-title">模型服务</div>
|
||
<a href="main.html" data-page="fine-tune" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
|
||
<i class="fa fa-cogs w-5 text-center"></i>
|
||
<span class="ml-2">模型调优</span>
|
||
</a>
|
||
<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>
|
||
<span class="ml-2">我的模型</span>
|
||
</a>
|
||
<a href="main.html?page=model-eval" data-page="model-eval" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
|
||
<i class="fa fa-line-chart w-5 text-center"></i>
|
||
<span class="ml-2">模型评测</span>
|
||
</a>
|
||
<a href="main.html?page=model-deploy" data-page="model-deploy" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
|
||
<i class="fa fa-server w-5 text-center"></i>
|
||
<span class="ml-2">模型部署</span>
|
||
</a>
|
||
|
||
<!-- 第二分区:资源管理 -->
|
||
<div class="sidebar-section-title mt-6">资源管理</div>
|
||
<a href="main.html?page=model-manage" data-page="model-manage" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
|
||
<i class="fa fa-cube w-5 text-center"></i>
|
||
<span class="ml-2">模型管理</span>
|
||
</a>
|
||
<a href="main.html?page=dataset-manage" data-page="dataset-manage" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
|
||
<i class="fa fa-file-text w-5 text-center"></i>
|
||
<span class="ml-2">数据集管理</span>
|
||
</a>
|
||
<a href="main.html?page=data-generate" data-page="data-generate" 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>
|
||
<span class="ml-2">其他工具</span>
|
||
</a>
|
||
|
||
<!-- 第三分区:系统设置 -->
|
||
<div class="sidebar-section-title mt-6">系统设置</div>
|
||
<a href="main.html?page=config" data-page="config" class="nav-link flex items-center px-4 py-2.5 hover:bg-[#001529]/20 transition-colors">
|
||
<i class="fa fa-bar-chart w-5 text-center"></i>
|
||
<span class="ml-2">平台性能</span>
|
||
</a>
|
||
</nav>
|
||
|
||
<!-- 底部信息区域 -->
|
||
<div class="p-4 border-t border-[#001529]/30 text-xs mt-auto">
|
||
<div class="mb-2 text-[#bfcbd9]/80">默认业务空间</div>
|
||
<div class="flex items-center justify-between">
|
||
<span class="text-[#bfcbd9]">版本 v1.0.0</span>
|
||
<i class="fa fa-question-circle-o text-[#bfcbd9]/70"></i>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
<!-- 主内容区 -->
|
||
<div class="flex-1 flex flex-col overflow-hidden">
|
||
<!-- 顶部导航 -->
|
||
<header class="bg-white border-b border-gray-200 shadow-sm">
|
||
<div class="flex items-center justify-between px-6 h-14">
|
||
<div class="flex items-center space-x-4">
|
||
<a href="#" onclick="goBack()" class="text-gray-500 hover:text-gray-700 flex items-center">
|
||
<i class="fa fa-arrow-left"></i>
|
||
<span class="ml-1">上一步</span>
|
||
</a>
|
||
</div>
|
||
<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-2 bg-white rounded shadow-lg py-1 hidden group-hover:block 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>
|
||
</header>
|
||
|
||
<!-- 内容区域 -->
|
||
<main class="flex-1 overflow-y-auto p-6 bg-gray-50">
|
||
<!-- 页面标题 -->
|
||
<div class="bg-white rounded-lg shadow-sm p-4 border-b border-gray-100 mb-4">
|
||
<div class="flex items-center text-sm">
|
||
<span id="breadcrumbParent" class="text-primary cursor-pointer hover:underline" onclick="goBack()">数据集管理</span>
|
||
<span class="mx-2 text-gray-300">/</span>
|
||
<span class="text-gray-800 font-medium">上传数据集</span>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 表单内容 -->
|
||
<div class="bg-white rounded-lg shadow-sm">
|
||
<div class="p-6 max-w-3xl">
|
||
<form id="datasetForm">
|
||
<!-- 1. 数据集名称输入框 -->
|
||
<div class="mb-6">
|
||
<label class="form-label">
|
||
数据集名称
|
||
</label>
|
||
<div class="relative">
|
||
<input
|
||
type="text"
|
||
name="name"
|
||
placeholder="数据集名称"
|
||
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:border-primary focus:outline-none"
|
||
maxlength="20"
|
||
>
|
||
<span class="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm">0 / 20</span>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 2. 数据集类型(单选按钮) -->
|
||
<div class="mb-6 pl-4">
|
||
<label class="block text-sm font-medium text-gray-700 mb-2">数据集类型</label>
|
||
<div class="flex items-center space-x-6">
|
||
<label class="flex items-center cursor-pointer">
|
||
<input type="radio" name="dataset_type" id="train-set" value="train" checked onchange="switchDatasetType()" class="radio-custom absolute opacity-0">
|
||
<div class="flex items-center space-x-1">
|
||
<div class="w-4 h-4 rounded-full border-2 border-gray-300 flex items-center justify-center">
|
||
<div class="radio-dot"></div>
|
||
</div>
|
||
<span class="text-sm text-gray-700">训练集</span>
|
||
</div>
|
||
</label>
|
||
<label class="flex items-center cursor-pointer">
|
||
<input type="radio" name="dataset_type" id="eval-set" value="eval" onchange="switchDatasetType()" class="radio-custom absolute opacity-0">
|
||
<div class="flex items-center space-x-1">
|
||
<div class="w-4 h-4 rounded-full border-2 border-gray-300 flex items-center justify-center">
|
||
<div class="radio-dot"></div>
|
||
</div>
|
||
<span class="text-sm text-gray-700">评测集</span>
|
||
</div>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 4. 存储位置 -->
|
||
<div class="mb-6 pl-4">
|
||
<label class="block text-sm font-medium text-gray-700 mb-2">存储位置</label>
|
||
<div class="flex items-center space-x-6">
|
||
<label class="flex items-center cursor-pointer">
|
||
<input type="radio" name="storage" value="local" class="radio-custom absolute opacity-0" checked>
|
||
<div class="flex items-center space-x-1">
|
||
<div class="w-4 h-4 rounded-full border-2 border-gray-300 flex items-center justify-center">
|
||
<div class="radio-dot"></div>
|
||
</div>
|
||
<span class="text-sm text-gray-700">本地存储</span>
|
||
</div>
|
||
</label>
|
||
<label class="flex items-center cursor-pointer">
|
||
<input type="radio" name="storage" value="cloud" class="radio-custom absolute opacity-0">
|
||
<div class="flex items-center space-x-1">
|
||
<div class="w-4 h-4 rounded-full border-2 border-gray-300 flex items-center justify-center">
|
||
<div class="radio-dot"></div>
|
||
</div>
|
||
<span class="text-sm text-gray-700">云平台存储</span>
|
||
</div>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 5. 上传文件区域 -->
|
||
<div class="mb-6 pl-4">
|
||
<label class="block text-sm font-medium text-gray-700 mb-1">上传文件</label>
|
||
<p class="text-xs text-gray-500 mb-2">选择文件进行上传,数据格式可下载模板查看,一次最多导入10个文件</p>
|
||
<div
|
||
id="upload-area"
|
||
class="upload-area border-2 border-dashed border-gray-300 rounded-lg p-8 text-center transition-colors cursor-pointer relative"
|
||
>
|
||
<input type="file" id="file-upload" class="absolute opacity-0" multiple accept=".jsonl,.xls,.xlsx">
|
||
<div class="flex flex-col items-center space-y-2">
|
||
<i class="fa fa-cloud-upload text-2xl text-gray-400"></i>
|
||
<p class="text-sm text-gray-600">点击或将文件拖拽到这里上传 (0/10)</p>
|
||
<p class="text-xs text-gray-500">支持扩展名:jsonl, xls, xlsx, 文件最大200MB<br>一次最多导入10个文件</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 8. 模板链接 -->
|
||
<div class="mb-6 pl-4 space-x-4">
|
||
<a href="#" class="text-primary text-sm hover:underline">
|
||
<i class="fa fa-file-excel mr-1"></i>EXCEL数据模板
|
||
</a>
|
||
<a href="#" class="text-primary text-sm hover:underline">
|
||
<i class="fa fa-file-code mr-1"></i>JSON数据模板
|
||
</a>
|
||
</div>
|
||
|
||
<!-- 底部按钮 -->
|
||
<div class="flex items-center justify-between pt-6 border-t border-gray-100 mt-8">
|
||
<div class="flex items-center space-x-3">
|
||
<button type="button" onclick="submitForm()" class="px-4 py-2 bg-primary text-white rounded-lg text-sm hover:bg-primary/90">
|
||
保存
|
||
</button>
|
||
<a href="main.html?page=dataset-manage" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg text-sm hover:bg-gray-300">
|
||
取消
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</main>
|
||
</div>
|
||
|
||
<script>
|
||
// API 基础地址
|
||
const getApiBase = () => {
|
||
const protocol = window.location.protocol;
|
||
const hostname = window.location.hostname;
|
||
return `${protocol}//${hostname}:8080/api`;
|
||
};
|
||
const API_BASE = getApiBase();
|
||
|
||
// 返回页面
|
||
let backUrl = 'main.html?page=dataset-manage';
|
||
|
||
// 页面加载完成后初始化
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
// 根据URL参数设置返回页面
|
||
const urlParams = new URLSearchParams(window.location.search);
|
||
const from = urlParams.get('from');
|
||
const breadcrumbParent = document.getElementById('breadcrumbParent');
|
||
if (from === 'fine-tune') {
|
||
backUrl = 'fine-tune-create.html';
|
||
if (breadcrumbParent) {
|
||
breadcrumbParent.textContent = '创建训练任务';
|
||
}
|
||
}
|
||
// 文件上传区域拖拽逻辑
|
||
const uploadArea = document.getElementById('upload-area');
|
||
const fileUpload = document.getElementById('file-upload');
|
||
|
||
// 点击上传区域触发文件选择
|
||
uploadArea.addEventListener('click', () => fileUpload.click());
|
||
|
||
// 拖拽事件处理
|
||
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
||
uploadArea.addEventListener(eventName, preventDefaults, false);
|
||
});
|
||
|
||
function preventDefaults(e) {
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
}
|
||
|
||
['dragenter', 'dragover'].forEach(eventName => {
|
||
uploadArea.addEventListener(eventName, () => uploadArea.classList.add('drag-over'), false);
|
||
});
|
||
|
||
['dragleave', 'drop'].forEach(eventName => {
|
||
uploadArea.addEventListener(eventName, () => uploadArea.classList.remove('drag-over'), false);
|
||
});
|
||
|
||
// 处理文件拖放
|
||
uploadArea.addEventListener('drop', (e) => {
|
||
const files = e.dataTransfer.files;
|
||
if (files.length) {
|
||
fileUpload.files = files;
|
||
console.log('拖放的文件:', files);
|
||
}
|
||
});
|
||
|
||
// 监听文件选择
|
||
fileUpload.addEventListener('change', () => {
|
||
console.log('选择的文件:', fileUpload.files);
|
||
});
|
||
|
||
// 绑定导航点击事件
|
||
document.querySelectorAll('.nav-link').forEach(link => {
|
||
link.addEventListener('click', function(e) {
|
||
if (!this.href.includes('dataset-create')) {
|
||
e.preventDefault();
|
||
window.location.href = this.href;
|
||
}
|
||
});
|
||
});
|
||
|
||
// 初始化单选框选中样式
|
||
initRadioStyles();
|
||
});
|
||
|
||
// 初始化单选框选中样式
|
||
function initRadioStyles() {
|
||
document.querySelectorAll('.radio-custom').forEach(radio => {
|
||
updateRadioStyle(radio);
|
||
radio.addEventListener('change', function() {
|
||
document.querySelectorAll('.radio-custom').forEach(r => updateRadioStyle(r));
|
||
});
|
||
});
|
||
}
|
||
|
||
// 更新单选框样式
|
||
function updateRadioStyle(radio) {
|
||
const parent = radio.closest('label');
|
||
const dotContainer = parent.querySelector('.w-4');
|
||
const dot = parent.querySelector('.radio-dot');
|
||
if (radio.checked) {
|
||
if (dotContainer) {
|
||
dotContainer.classList.add('border-primary', 'bg-primary/10');
|
||
dotContainer.classList.remove('border-gray-300');
|
||
}
|
||
if (dot) {
|
||
dot.classList.add('bg-primary');
|
||
dot.classList.remove('bg-transparent');
|
||
}
|
||
} else {
|
||
if (dotContainer) {
|
||
dotContainer.classList.remove('border-primary', 'bg-primary/10');
|
||
dotContainer.classList.add('border-gray-300');
|
||
}
|
||
if (dot) {
|
||
dot.classList.remove('bg-primary');
|
||
dot.classList.add('bg-transparent');
|
||
}
|
||
}
|
||
}
|
||
|
||
// 数据集类型切换逻辑
|
||
function switchDatasetType() {
|
||
// 数据集类型切换逻辑
|
||
}
|
||
|
||
// 提交表单
|
||
async function submitForm() {
|
||
const form = document.getElementById('datasetForm');
|
||
const formData = new FormData(form);
|
||
const data = {
|
||
name: formData.get('name'),
|
||
dataset_type: formData.get('dataset_type'),
|
||
storage: formData.get('storage')
|
||
};
|
||
|
||
if (!data.name) {
|
||
alert('请输入数据集名称');
|
||
return;
|
||
}
|
||
|
||
try {
|
||
const response = await fetch(`${API_BASE}/dataset-manage`, {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify(data)
|
||
});
|
||
const result = await response.json();
|
||
if (result.code === 0) {
|
||
alert('创建成功!');
|
||
window.location.href = 'main.html?page=dataset-manage';
|
||
} else {
|
||
alert(result.message || '创建失败');
|
||
}
|
||
} catch (error) {
|
||
alert('创建失败: ' + error.message);
|
||
}
|
||
}
|
||
|
||
// 返回上一页
|
||
function goBack() {
|
||
window.location.href = backUrl;
|
||
}
|
||
</script>
|
||
</body>
|
||
</html>
|