From 1ae1139f17c04e99b1528660d335167e2b707de9 Mon Sep 17 00:00:00 2001 From: leokaka1 Date: Mon, 19 Jan 2026 11:33:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/pages/custom-tool-create.html | 442 +++++++++++++++++++++++++++++ web/pages/dataset-create.html | 2 +- web/pages/fine-tune-create.html | 2 +- web/pages/main.html | 156 ++++++++-- web/pages/model-eval-create.html | 2 +- web/pages/model-manage-create.html | 2 +- 6 files changed, 571 insertions(+), 35 deletions(-) create mode 100644 web/pages/custom-tool-create.html diff --git a/web/pages/custom-tool-create.html b/web/pages/custom-tool-create.html new file mode 100644 index 0000000..0dde29a --- /dev/null +++ b/web/pages/custom-tool-create.html @@ -0,0 +1,442 @@ + + + + + + 添加自定义工具 / 远光软件微调平台 + + + + + + + + + + +
+ +
+ +
+ + +
+ +
+
+ 其他工具 + / + 添加自定义工具 +
+
+ + +
+
+
+ +
+ + +

支持中文、英文、数字,最多30个字符

+
+ + +
+ + +

0 / 100

+
+ + +
+ + +

输入工具页面的相对路径或完整URL

+
+ + +
+ +
+ +
+ + +
+
+ + + 取消 + +
+
+
+
+
+
+
+ + + + + + + diff --git a/web/pages/dataset-create.html b/web/pages/dataset-create.html index 091999f..578bca5 100644 --- a/web/pages/dataset-create.html +++ b/web/pages/dataset-create.html @@ -101,7 +101,7 @@ - 数据生成 + 其他工具 diff --git a/web/pages/fine-tune-create.html b/web/pages/fine-tune-create.html index 95e70d6..5606bca 100644 --- a/web/pages/fine-tune-create.html +++ b/web/pages/fine-tune-create.html @@ -87,7 +87,7 @@ - 数据生成 + 其他工具 diff --git a/web/pages/main.html b/web/pages/main.html index 457cfa6..d043cfd 100644 --- a/web/pages/main.html +++ b/web/pages/main.html @@ -79,7 +79,7 @@ - 模型部署 + 模型对比 @@ -94,7 +94,7 @@ - 数据生成 + 其他工具 @@ -229,18 +229,14 @@ actions: ['preview', 'download', 'delete'] }, 'data-generate': { - title: '数据生成', - api: 'data-generate', - hasCreate: true, - createText: '新建生成任务', - columns: [ - { title: '任务名称', key: 'name' }, - { title: '模板', key: 'template' }, - { title: '生成数', key: 'count' }, - { title: '状态', key: 'status' }, - { title: '创建时间', key: 'create_time', render: (val) => val ? new Date(val).toLocaleString('zh-CN') : '-' } + title: '其他工具', + isTools: true, + defaultTools: [ + { id: 'data-generate', name: '数据生成', icon: 'fa-database', description: '基于LLM生成微调数据集' }, + { id: 'json2jsonl', name: 'JSON转JSONL', icon: 'fa-code', description: '将JSON文件转换为JSONL格式' }, + { id: 'md-convert', name: '转换Markdown', icon: 'fa-file-text', description: '将Markdown文件转换为训练数据' } ], - actions: ['stop', 'detail', 'delete'] + customTools: [] }, 'model-manage': { title: '模型管理', @@ -287,6 +283,12 @@ // 页面加载完成后初始化 document.addEventListener('DOMContentLoaded', function() { + // 从 localStorage 加载自定义工具 + const savedCustomTools = localStorage.getItem('customTools'); + if (savedCustomTools) { + tableConfigs['data-generate'].customTools = JSON.parse(savedCustomTools); + } + // 检查URL参数 const urlParams = new URLSearchParams(window.location.search); const pageParam = urlParams.get('page'); @@ -340,19 +342,14 @@ `; try { - // 获取数据 - let data = []; - if (config.isForm) { - // 平台配置页面,直接获取配置列表 - data = await fetchData(`${API_BASE}/${config.api}`); - } else { - data = await fetchData(`${API_BASE}/${config.api}`); - } - // 渲染页面 if (config.isForm) { + const data = await fetchData(`${API_BASE}/${config.api}`); container.innerHTML = renderConfigPage(config, data); + } else if (config.isTools) { + container.innerHTML = renderToolsPage(config); } else { + const data = await fetchData(`${API_BASE}/${config.api}`); container.innerHTML = renderTablePage(config, data); } } catch (error) { @@ -462,6 +459,103 @@ `; } + // 渲染工具卡片页面 + function renderToolsPage(config) { + // 渲染单个工具卡片 + const renderToolCard = (tool, canDelete = false, isCustom = false) => ` +
+
+ +
+

${tool.name}

+

${tool.description}

+ ${canDelete ? ` + + + ` : ''} +
+ `; + + const defaultCards = config.defaultTools.map(t => renderToolCard(t, false, false)).join(''); + const customCards = config.customTools.map(t => renderToolCard(t, true, true)).join(''); + + return ` +
+
+

${config.title}

+ +
+
+ +

默认工具

+
+ ${defaultCards || '

暂无默认工具

'} +
+ + +

自定义工具

+
+ ${customCards || '

暂无自定义工具,点击右上角添加

'} +
+
+
+ `; + } + + // 删除自定义工具 + function deleteCustomTool(toolId) { + showConfirm('确认删除', '确定要删除这个自定义工具吗?', () => { + const config = tableConfigs['data-generate']; + config.customTools = config.customTools.filter(t => t.id !== toolId); + // 保存到 localStorage + localStorage.setItem('customTools', JSON.stringify(config.customTools)); + document.getElementById('page-content').innerHTML = renderToolsPage(config); + // 删除成功,无需额外弹窗提示 + }); + } + + // 修改自定义工具 + function editCustomTool(toolId) { + const config = tableConfigs['data-generate']; + const tool = config.customTools.find(t => t.id === toolId); + if (tool) { + // 将工具信息存储到 localStorage,编辑页面读取 + localStorage.setItem('editTool', JSON.stringify(tool)); + window.location.href = 'custom-tool-create.html?edit=true'; + } + } + + // 显示创建工具弹窗 + function showCreateToolModal() { + window.location.href = 'custom-tool-create.html'; + } + + // 跳转到工具页面 + function navigateToTool(toolId, url, isCustom = false) { + if (isCustom && url) { + // 自定义工具,使用配置的URL + if (url.startsWith('http')) { + window.open(url, '_blank'); + } else { + window.location.href = url; + } + } else if (toolId === 'data-generate') { + window.location.href = 'data-generate.html'; + } else if (toolId === 'json2jsonl') { + showMessage('提示', 'JSON转JSONL 工具开发中...', 'info'); + } else if (toolId === 'md-convert') { + showMessage('提示', '转换Markdown 工具开发中...', 'info'); + } else { + showMessage('提示', `${toolId} 功能开发中...`, 'info'); + } + } + // 渲染配置页面 function renderConfigPage(config, data) { return ` @@ -1265,22 +1359,22 @@