fix model del & rename

This commit is contained in:
2026-07-31 11:15:54 +08:00
parent d45acaf50f
commit feaddfee7b
8 changed files with 196 additions and 28 deletions
+1 -1
View File
@@ -172,7 +172,7 @@
</div>
</div>
<div class="data-surface">
<table><thead><tr><th>文件名</th><th>上传时间</th><th>大小</th><th>操作</th></tr></thead><tbody id="model-list"></tbody></table>
<table><thead><tr><th>服务器文件名</th><th>原始文件名</th><th>上传时间</th><th>大小</th><th>操作</th></tr></thead><tbody id="model-list"></tbody></table>
<p id="model-empty" class="empty-row">选择公司和产线后刷新模型列表</p>
</div>
</section>
+10 -6
View File
@@ -281,7 +281,7 @@ async function refreshModels() {
if (!result) return;
state.models = result.fileList;
elements.modelList.innerHTML = state.models.map((model) => `
<tr><td>${escapeHtml(model.fileName)}</td><td>${escapeHtml(model.uploadTime || "-")}</td>
<tr><td>${escapeHtml(model.fileName)}</td><td>${escapeHtml(model.originalFileName || model.fileName)}</td><td>${escapeHtml(model.uploadTime || "-")}</td>
<td>${formatSize(model.size)}</td><td><button class="table-action" data-model-download="${escapeHtml(model.fileID)}">下载</button><button class="table-action danger" data-model-delete="${escapeHtml(model.fileID)}">删除</button></td></tr>
`).join("");
elements.modelEmpty.hidden = state.models.length > 0;
@@ -698,12 +698,16 @@ document.querySelector("#upload-model").addEventListener("click", async () => {
state.models = models.fileList;
const selected = await runBusy("正在选择模型文件", () => window.reinloop.chooseModelUploadFile());
if (!selected) return;
const existing = state.models.find((model) => model.fileName === selected.fileName);
const enteredModelName = window.prompt("请输入模型在服务器上的文件名:", selected.fileName);
if (enteredModelName === null) return;
const modelName = enteredModelName.trim();
if (!modelName) return showError(new Error("服务器文件名不能为空"));
const existing = state.models.find((model) => model.fileName === modelName);
let overwrite = false;
if (existing) {
if (!window.confirm(`已存在同名模型 ${selected.fileName},覆盖后无法恢复。是否继续?`)) return;
const confirmation = window.prompt(`请输入完整文件名以确认覆盖:${selected.fileName}`);
if (confirmation !== selected.fileName) {
if (!window.confirm(`服务器已存在模型 ${modelName},覆盖后无法恢复。是否继续?`)) return;
const confirmation = window.prompt(`请输入服务器文件名以确认覆盖:${modelName}`);
if (confirmation !== modelName) {
setStatus("文件名不匹配,已取消覆盖", "idle");
return;
}
@@ -711,7 +715,7 @@ document.querySelector("#upload-model").addEventListener("click", async () => {
}
const result = await runBusy("正在上传模型", () => window.reinloop.uploadModel({
deviceId: elements.deviceId.value, sourcePath: selected.sourcePath, fileName: selected.fileName,
overwrite, credentials: credentials()
modelName, overwrite, credentials: credentials()
}));
if (result) {
setStatus(overwrite ? "模型已覆盖" : "模型已上传", "success");