From c56d19afd20daa4c989cde31d102b045da980030 Mon Sep 17 00:00:00 2001 From: mkitsdts Date: Fri, 26 Dec 2025 11:26:01 +0800 Subject: [PATCH 1/6] feat:add transfer share file button --- src/lang/en/home.json | 3 +- src/pages/home/toolbar/Right.tsx | 7 +++ src/pages/home/toolbar/Toolbar.tsx | 2 + src/pages/home/toolbar/TransferShare.tsx | 66 ++++++++++++++++++++++++ src/pages/home/toolbar/operations.ts | 3 +- 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 src/pages/home/toolbar/TransferShare.tsx diff --git a/src/lang/en/home.json b/src/lang/en/home.json index 29c30a0e7..d5e00c1ef 100644 --- a/src/lang/en/home.json +++ b/src/lang/en/home.json @@ -68,6 +68,7 @@ "input_filename": "Input filename", "cancel_select": "Cancel Select", "offline_download": "Offline download", + "transfer_share": "Transfer Share", "offline_download-tips": "One URL per line", "delete_policy": { "delete_on_upload_succeed": "Delete on upload succeed", @@ -197,4 +198,4 @@ "skip_existing": "Skip existing files", "merge": "Only Copy new files and subdirectories" } -} +} \ No newline at end of file diff --git a/src/pages/home/toolbar/Right.tsx b/src/pages/home/toolbar/Right.tsx index 82ec5ac8b..4236ff537 100644 --- a/src/pages/home/toolbar/Right.tsx +++ b/src/pages/home/toolbar/Right.tsx @@ -116,6 +116,13 @@ export const Right = () => { bus.emit("tool", "upload") }} /> + { + bus.emit("tool", "transfer_share") + }} + /> import("../uploads/Upload")) @@ -35,6 +36,7 @@ export const Modal = () => { + diff --git a/src/pages/home/toolbar/TransferShare.tsx b/src/pages/home/toolbar/TransferShare.tsx new file mode 100644 index 000000000..9909f8ea3 --- /dev/null +++ b/src/pages/home/toolbar/TransferShare.tsx @@ -0,0 +1,66 @@ +import { Button, Input, Text, VStack } from "@hope-ui/solid" +import { createSignal, onCleanup } from "solid-js" +import { useFetch, usePath, useRouter, useT } from "~/hooks" +import { bus, handleRespWithNotifySuccess, r } from "~/utils" +import { ModalWrapper } from "./ModalWrapper" + +export const TransferShare = () => { + const t = useT() + const { refresh } = usePath() + const { pathname } = useRouter() + const [srcUrl, setSrcUrl] = createSignal("") + const [validCode, setValidCode] = createSignal("") + const [loading, ok] = useFetch( + (): Promise => + r.post("/fs/transfer", { + url: srcUrl(), + dst_dir: pathname(), + valid_code: validCode(), + }), + ) + + const handler = (name: string) => { + if (name === "transfer_share") { + bus.emit("tool", "transfer_share_modal") + } + } + bus.on("tool", handler) + onCleanup(() => { + bus.off("tool", handler) + }) + + return ( + + + Source URL + setSrcUrl(e.currentTarget.value)} + placeholder="http://..." + /> + Valid Code (Optional) + setValidCode(e.currentTarget.value)} + placeholder="Code" + /> + + + + ) +} diff --git a/src/pages/home/toolbar/operations.ts b/src/pages/home/toolbar/operations.ts index 2f50c4976..2e475af1e 100644 --- a/src/pages/home/toolbar/operations.ts +++ b/src/pages/home/toolbar/operations.ts @@ -7,7 +7,7 @@ import { AiTwotoneDelete } from "solid-icons/ai" import { CgFileAdd, CgFolderAdd, CgFolderRemove } from "solid-icons/cg" import { AiOutlineCloudDownload } from "solid-icons/ai" import { ImMoveUp } from "solid-icons/im" -import { BiRegularRename } from "solid-icons/bi" +import { BiRegularRename, BiRegularTransfer } from "solid-icons/bi" export interface Operations { [key: string]: { @@ -31,6 +31,7 @@ export const operations: Operations = { cancel_select: { icon: TiDeleteOutline }, download: { icon: AiOutlineCloudDownload, color: "$primary9" }, share: { icon: CgShare, color: "$primary9" }, + transfer_share: { icon: BiRegularTransfer, p: true }, } // interface Operation { // label: string; From d91858513ef2f2d49bceb759dac0c1bc7cb9c7b7 Mon Sep 17 00:00:00 2001 From: mkitsdts Date: Fri, 2 Jan 2026 11:17:38 +0800 Subject: [PATCH 2/6] fix:cannot close window after using transfer share --- src/pages/home/toolbar/ModalWrapper.tsx | 5 ++++- src/pages/home/toolbar/Right.tsx | 13 +++++++++++-- src/pages/home/toolbar/TransferShare.tsx | 17 ++++++++++++----- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/pages/home/toolbar/ModalWrapper.tsx b/src/pages/home/toolbar/ModalWrapper.tsx index 19b91ef7d..d6b580731 100644 --- a/src/pages/home/toolbar/ModalWrapper.tsx +++ b/src/pages/home/toolbar/ModalWrapper.tsx @@ -17,18 +17,21 @@ export const ModalWrapper = (props: { name: string title: string blockScrollOnMount?: boolean + closeName?: string }) => { const t = useT() + const { isOpen, onOpen, onClose } = createDisclosure() const handler = (name: string) => { if (name === props.name) { onOpen() + } else if (props.closeName && name === props.closeName) { + onClose() } } bus.on("tool", handler) onCleanup(() => { bus.off("tool", handler) }) - const { isOpen, onOpen, onClose } = createDisclosure() return ( { - const { isOpen, onToggle } = createDisclosure({ + const { isOpen, onToggle, onClose } = createDisclosure({ defaultIsOpen: localStorage.getItem("more-open") === "true", onClose: () => localStorage.setItem("more-open", "false"), onOpen: () => localStorage.setItem("more-open", "true"), }) + const handler = (name: string) => { + if (name === "close_right_toolbar") { + onClose() + } + } + bus.on("tool", handler) + onCleanup(() => { + bus.off("tool", handler) + }) const margin = createMemo(() => (isOpen() ? "$4" : "$5")) const isFolder = createMemo(() => objStore.state === State.Folder) const { refresh } = usePath() diff --git a/src/pages/home/toolbar/TransferShare.tsx b/src/pages/home/toolbar/TransferShare.tsx index 9909f8ea3..0baf6f42f 100644 --- a/src/pages/home/toolbar/TransferShare.tsx +++ b/src/pages/home/toolbar/TransferShare.tsx @@ -33,6 +33,7 @@ export const TransferShare = () => { Source URL @@ -50,11 +51,17 @@ export const TransferShare = () => { - + ) } From 76fd921d87a8f1a82332a75aca998dabb98accf4 Mon Sep 17 00:00:00 2001 From: MadDogOwner Date: Fri, 2 Jan 2026 12:55:18 +0800 Subject: [PATCH 5/6] chore: apply suggestion Signed-off-by: MadDogOwner --- src/pages/home/toolbar/TransferShare.tsx | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/pages/home/toolbar/TransferShare.tsx b/src/pages/home/toolbar/TransferShare.tsx index d3d675ef4..01a577a40 100644 --- a/src/pages/home/toolbar/TransferShare.tsx +++ b/src/pages/home/toolbar/TransferShare.tsx @@ -1,7 +1,7 @@ import { Button, HStack, Input, Text, VStack } from "@hope-ui/solid" -import { createSignal, onCleanup } from "solid-js" +import { createSignal } from "solid-js" import { useFetch, usePath, useRouter, useT } from "~/hooks" -import { bus, handleRespWithNotifySuccess, r } from "~/utils" +import { bus, handleRespWithNotifySuccess, notify, r } from "~/utils" import { ModalWrapper } from "./ModalWrapper" export const TransferShare = () => { @@ -18,20 +18,9 @@ export const TransferShare = () => { valid_code: validCode(), }), ) - - const handler = (name: string) => { - if (name === "transfer_share") { - bus.emit("tool", "transfer_share_modal") - } - } - bus.on("tool", handler) - onCleanup(() => { - bus.off("tool", handler) - }) - return ( @@ -61,10 +50,15 @@ export const TransferShare = () => { loading={loading()} onClick={async () => { try { + if (!srcUrl()) { + throw new Error("Empty Source URL") + } const resp = await ok() handleRespWithNotifySuccess(resp, () => { refresh() }) + } catch (e) { + notify.error((e as Error).message) } finally { setSrcUrl("") setValidCode("") From 0d8155ed1d89d10d5927e03f43204792b65885ce Mon Sep 17 00:00:00 2001 From: KirCute <951206789@qq.com> Date: Fri, 2 Jan 2026 17:17:43 +0800 Subject: [PATCH 6/6] feat(transfer): hide transfer button when cannot transfer --- src/hooks/usePath.ts | 1 + src/pages/home/toolbar/Right.tsx | 16 +++++++++------- src/store/obj.ts | 10 +++++----- src/types/resp.ts | 1 + 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/hooks/usePath.ts b/src/hooks/usePath.ts index 230f94758..85cf6b19e 100644 --- a/src/hooks/usePath.ts +++ b/src/hooks/usePath.ts @@ -178,6 +178,7 @@ export const usePath = () => { ObjStore.setWrite(data.write) ObjStore.setProvider(data.provider) ObjStore.setDirectUploadTools(data.direct_upload_tools) + ObjStore.setCanTransfer(data.can_transfer) ObjStore.setState(State.Folder) }, handleErr, diff --git a/src/pages/home/toolbar/Right.tsx b/src/pages/home/toolbar/Right.tsx index ae7560c2b..454c17321 100644 --- a/src/pages/home/toolbar/Right.tsx +++ b/src/pages/home/toolbar/Right.tsx @@ -125,13 +125,15 @@ export const Right = () => { bus.emit("tool", "upload") }} /> - { - bus.emit("tool", "transfer_share") - }} - /> + + { + bus.emit("tool", "transfer_share") + }} + /> + undefined, + can_transfer: false, state: State.Initial, err: "", + write: undefined, } -const [objStore, setObjStore] = createStore< - typeof initialObjStore & { - write?: boolean - } ->(initialObjStore) +const [objStore, setObjStore] = createStore(initialObjStore) const setObjs = (objs: Obj[]) => { lastChecked.start = -1 @@ -79,6 +77,8 @@ export const ObjStore = { setState: (state: State) => setObjStore("state", state), setDirectUploadTools: (tools?: string[]) => setObjStore("direct_upload_tools", tools), + setCanTransfer: (canTransfer: boolean) => + setObjStore("can_transfer", canTransfer), setErr: (err: string) => setObjStore("err", err), } diff --git a/src/types/resp.ts b/src/types/resp.ts index 397e39a07..f03590534 100644 --- a/src/types/resp.ts +++ b/src/types/resp.ts @@ -19,6 +19,7 @@ export type FsListResp = Resp<{ write: boolean provider: string direct_upload_tools?: string[] + can_transfer: boolean }> export type SearchNode = {