From 0992b7bc294b8b04b4ee252843fcff9c9bd88e38 Mon Sep 17 00:00:00 2001 From: varg1714 <51254954+varg1714@users.noreply.github.com> Date: Fri, 14 Apr 2023 21:37:17 +0800 Subject: [PATCH] feat: empty folder clear, recursive move, regular rename (#78) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 页面增加递归移动和正则重命名按钮 * 正则重命名操作样式变更 * 增加清理空文件夹按钮 * 正则重命名文件添加提示语 * 技术债 * chore: change ui * fix codefactor --------- Co-authored-by: Andy Hsu --- src/components/ModalTwoInput.tsx | 125 ++++++++++++++++++ src/components/index.ts | 1 + src/lang/en/home.json | 7 +- src/pages/home/toolbar/RecursiveMove.tsx | 35 +++++ src/pages/home/toolbar/RegexRename.tsx | 36 +++++ .../home/toolbar/RemoveEmptyDirectory.tsx | 71 ++++++++++ src/pages/home/toolbar/Right.tsx | 21 +++ src/pages/home/toolbar/Toolbar.tsx | 6 + src/pages/home/toolbar/operations.ts | 6 + src/utils/api.ts | 19 +++ 10 files changed, 326 insertions(+), 1 deletion(-) create mode 100644 src/components/ModalTwoInput.tsx create mode 100644 src/pages/home/toolbar/RecursiveMove.tsx create mode 100644 src/pages/home/toolbar/RegexRename.tsx create mode 100644 src/pages/home/toolbar/RemoveEmptyDirectory.tsx diff --git a/src/components/ModalTwoInput.tsx b/src/components/ModalTwoInput.tsx new file mode 100644 index 0000000000..53e16d473c --- /dev/null +++ b/src/components/ModalTwoInput.tsx @@ -0,0 +1,125 @@ +import { + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalBody, + ModalFooter, + Button, + Input, + Textarea, + FormHelperText, + VStack, +} from "@hope-ui/solid" +import { createSignal, JSXElement, Show } from "solid-js" +import { useT } from "~/hooks" +import { notify } from "~/utils" +export type ModalTwoInputProps = { + opened: boolean + onClose: () => void + title: string + onSubmit?: (text1: string, text2: string) => void // Update onSubmit to accept two input texts + type?: string + defaultValue1?: string // Update defaultValue to defaultValue1 + defaultValue2?: string // Add defaultValue2 for second input + loading?: boolean + tips?: string + topSlot?: JSXElement +} +export const ModalTwoInput = (props: ModalTwoInputProps) => { + const [value1, setValue1] = createSignal(props.defaultValue1 ?? "") // Update value and setValue to value1 and setValue1 + const [value2, setValue2] = createSignal(props.defaultValue2 ?? "") // Add value2 and setValue2 for second input + const t = useT() + const submit = () => { + if (!value1() || !value2()) { + // Check if both input values are not empty + notify.warning(t("global.empty_input")) + return + } + props.onSubmit?.(value1(), value2()) // Update onSubmit to pass both input values + setValue1("") + setValue2("") + } + return ( + + + + {/* */} + {t(props.title)} + + {props.topSlot} + + { + setValue1(e.currentTarget.value) + }} + onKeyDown={(e) => { + if (e.key === "Enter") { + submit() + } + }} + /> + { + setValue2(e.currentTarget.value) + }} + onKeyDown={(e) => { + if (e.key === "Enter") { + submit() + } + }} + /> + + } + > +
+