From a63fe86b521583f80f1daec86f2b63596197daf4 Mon Sep 17 00:00:00 2001 From: VirtualHotBar Date: Tue, 2 Jun 2026 03:13:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20#74=20=E6=94=B9=E8=BF=9B=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E9=87=8D=E5=91=BD=E5=90=8D=E5=8A=9F=E8=83=BD=20-=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BE=93=E5=85=A5=E9=AA=8C=E8=AF=81=E5=92=8C?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/storage/storage.tsx | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/page/storage/storage.tsx b/src/page/storage/storage.tsx index 92ebc35..337c668 100644 --- a/src/page/storage/storage.tsx +++ b/src/page/storage/storage.tsx @@ -1,6 +1,6 @@ -import { Button, Grid, Input, Modal, Popconfirm, Space, Tag, Tooltip } from '@arco-design/web-react' +import { Button, Grid, Input, Message, Modal, Popconfirm, Space, Tag, Tooltip } from '@arco-design/web-react' import { useTranslation } from 'react-i18next' -import { delStorage, filterHideStorage, renameStorage } from '../../services/storage/StorageManager' +import { delStorage, filterHideStorage, renameStorage, searchStorage } from '../../services/storage/StorageManager' import { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' import { useStorageStore } from '../../stores' @@ -32,13 +32,32 @@ function Storage_page() { } const handleRename = async () => { - if (!newStorageName.trim()) { + const trimmedName = newStorageName.trim() + if (!trimmedName) { + Message.error(t('storage_name_cannot_be_empty')) return } - const success = await renameStorage(renamingStorage, newStorageName.trim()) + if (trimmedName === renamingStorage) { + setRenameModalVisible(false) + return + } + // Check for duplicate name + if (searchStorage(trimmedName)) { + Message.error(t('storage_name_already_exists')) + return + } + // Validate storage name characters + if (/[\\/:*?"<>|]/.test(trimmedName)) { + Message.error(t('storage_name_illegal')) + return + } + const success = await renameStorage(renamingStorage, trimmedName) if (success) { + Message.success(t('success')) setRenameModalVisible(false) refreshStorage() + } else { + Message.error(t('rename_failed')) } } @@ -140,6 +159,8 @@ function Storage_page() {