From f5284837133c61a96a1c01ec44f0d31d4d3329a2 Mon Sep 17 00:00:00 2001 From: RhenCloud Date: Sat, 15 Nov 2025 18:11:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- static/js/file-operations.js | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 658f403..3b8d483 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] 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" authors = [{ name = "RhenCloud", email = "i@rhen.cloud" }] readme = "README.md" diff --git a/static/js/file-operations.js b/static/js/file-operations.js index 138745f..9c71a24 100644 --- a/static/js/file-operations.js +++ b/static/js/file-operations.js @@ -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, renameFolder, promptRename, + promptCreateFolder, copyItem, moveItem, promptCopyOrMove,