Compare commits

...

1 Commits

Author SHA1 Message Date
f528483713 feat: 修复新建文件夹功能 2025-11-15 18:11:26 +08:00
2 changed files with 49 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "Cloud-Index" name = "Cloud-Index"
version = "0.10.1" version = "0.11.2"
description = "A cloud storage index system based on a number of cloud storage platforms" description = "A cloud storage index system based on a number of cloud storage platforms"
authors = [{ name = "RhenCloud", email = "i@rhen.cloud" }] authors = [{ name = "RhenCloud", email = "i@rhen.cloud" }]
readme = "README.md" readme = "README.md"

View File

@@ -41,6 +41,53 @@ async function uploadFiles(files) {
} }
} }
/**
* 新建文件夹(弹出输入框并调用后端创建)
*/
async function promptCreateFolder() {
const currentPrefix = document.body.dataset.currentPrefix || "";
const name = await showPrompt("请输入新文件夹名称:", {
title: "新建文件夹",
confirmLabel: "创建",
placeholder: "例如photos 或 nested/folder",
});
if (!name) return;
// 规范化路径:允许嵌套,移除多余斜杠
let normalized = name.trim().replace(/\\/g, "/");
normalized = normalized.replace(/^\/+|\/+$/g, "");
if (!normalized) {
updateStatus("✗ 文件夹名称不能为空", "error");
return;
}
const fullPath = (currentPrefix || "") + normalized + "/";
updateStatus(`正在创建文件夹: ${fullPath}...`, null);
try {
const response = await fetch("/create_folder", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ path: fullPath }),
});
const result = await response.json();
if (result.success) {
const statusDiv = updateStatus("✓ 文件夹创建成功!", "success");
hideStatusLater(statusDiv);
setTimeout(() => {
// 进入新建的文件夹
window.location.href = `/${(currentPrefix + normalized).replace(/\/+$/, "")}`;
}, 1200);
} else {
updateStatus(`✗ 创建失败: ${result.error}`, "error");
}
} catch (error) {
updateStatus(`✗ 创建失败: ${error.message}`, "error");
}
}
/** /**
* 提示删除文件 * 提示删除文件
*/ */
@@ -389,6 +436,7 @@ window.FileOps = {
renameFile, renameFile,
renameFolder, renameFolder,
promptRename, promptRename,
promptCreateFolder,
copyItem, copyItem,
moveItem, moveItem,
promptCopyOrMove, promptCopyOrMove,