From 8d5870d6e157b9bc332de52c63c0df25cd4b763d Mon Sep 17 00:00:00 2001 From: allence Date: Thu, 4 May 2023 16:24:36 +0800 Subject: [PATCH] feat(web): add link copy --- web/public/locales/en/translation.json | 5 +- web/public/locales/zh-CN/translation.json | 3 +- web/public/locales/zh/translation.json | 3 +- .../app/storages/mods/FileList/index.tsx | 53 +++++++++++-------- .../app/storages/mods/UploadButton/index.tsx | 7 ++- 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/web/public/locales/en/translation.json b/web/public/locales/en/translation.json index d1640c5a9a..a03a409113 100644 --- a/web/public/locales/en/translation.json +++ b/web/public/locales/en/translation.json @@ -415,5 +415,6 @@ "item3_2": "Forum" } }, - "ChatGPT example": "ChatGPT example" -} \ No newline at end of file + "ChatGPT example": "ChatGPT example", + "LinkCopied": "Link Copied" +} diff --git a/web/public/locales/zh-CN/translation.json b/web/public/locales/zh-CN/translation.json index ca0c580106..c64f441db4 100644 --- a/web/public/locales/zh-CN/translation.json +++ b/web/public/locales/zh-CN/translation.json @@ -415,5 +415,6 @@ "item3_2": "开发者社区" } }, - "ChatGPT example": "ChatGPT 示例" + "ChatGPT example": "ChatGPT 示例", + "LinkCopied": "链接复制成功" } diff --git a/web/public/locales/zh/translation.json b/web/public/locales/zh/translation.json index ca0c580106..c64f441db4 100644 --- a/web/public/locales/zh/translation.json +++ b/web/public/locales/zh/translation.json @@ -415,5 +415,6 @@ "item3_2": "开发者社区" } }, - "ChatGPT example": "ChatGPT 示例" + "ChatGPT example": "ChatGPT 示例", + "LinkCopied": "链接复制成功" } diff --git a/web/src/pages/app/storages/mods/FileList/index.tsx b/web/src/pages/app/storages/mods/FileList/index.tsx index 87e583df1d..289d41cdcb 100644 --- a/web/src/pages/app/storages/mods/FileList/index.tsx +++ b/web/src/pages/app/storages/mods/FileList/index.tsx @@ -1,5 +1,5 @@ import { BiCloudUpload, BiRefresh } from "react-icons/bi"; -import { DeleteIcon, ViewIcon } from "@chakra-ui/icons"; +import { DeleteIcon, LinkIcon, ViewIcon } from "@chakra-ui/icons"; import { Button, Center, @@ -19,8 +19,8 @@ import clsx from "clsx"; import { t } from "i18next"; import ConfirmButton from "@/components/ConfirmButton"; +import CopyText from "@/components/CopyText"; import EmptyBox from "@/components/EmptyBox"; -// import CopyText from "@/components/CopyText"; import FileTypeIcon from "@/components/FileTypeIcon"; import IconWrap from "@/components/IconWrap"; import Panel from "@/components/Panel"; @@ -30,11 +30,9 @@ import { formatDate, formateType, formatSize } from "@/utils/format"; import useStorageStore, { TFile } from "../../store"; import CreateFolderModal from "../CreateFolderModal"; import CreateWebsiteModal from "../CreateWebsiteModal"; -// import CreateWebsiteModal from "../CreateWebsiteModal"; import PathLink from "../PathLink"; import UploadButton from "../UploadButton"; -// import styles from "../index.module.scss"; import useAwsS3 from "@/hooks/useAwsS3"; export default function FileList() { const { getList, getFileUrl, deleteFile } = useAwsS3(); @@ -53,21 +51,23 @@ export default function FileList() { }, ); - const viewAppFile = (file: TFile) => { - if (file.Prefix) { - changeDirectory(file); - return; - } - + const getLinkUrl = (file: TFile) => { let fileUrl = ""; - if (bucketType === "private") { fileUrl = getFileUrl(bucketName!, file.Key); } else { fileUrl = getOrigin(currentStorage?.domain?.domain || "") + `/${file.Key}` || ""; } - window.open(fileUrl, "_blank"); + return fileUrl; + }; + + const viewAppFile = (file: TFile) => { + if (file.Prefix) { + changeDirectory(file); + return; + } + window.open(getLinkUrl(file), "_blank"); }; const changeDirectory = (file: TFile) => { @@ -213,18 +213,25 @@ export default function FileList() { {!file.Prefix ? ( - { - await deleteFile(bucketName!, file.Key); - query.refetch(); - }} - headerText={String(t("Delete"))} - bodyText={t("StoragePanel.DeleteFileTip")} - > - - + <> + + + + - + { + await deleteFile(bucketName!, file.Key); + query.refetch(); + }} + headerText={String(t("Delete"))} + bodyText={t("StoragePanel.DeleteFileTip")} + > + + + + + ) : ( { diff --git a/web/src/pages/app/storages/mods/UploadButton/index.tsx b/web/src/pages/app/storages/mods/UploadButton/index.tsx index 4a24ba2518..b11daa181b 100644 --- a/web/src/pages/app/storages/mods/UploadButton/index.tsx +++ b/web/src/pages/app/storages/mods/UploadButton/index.tsx @@ -7,6 +7,7 @@ import { ModalContent, ModalHeader, ModalOverlay, + Spinner, useDisclosure, } from "@chakra-ui/react"; @@ -80,7 +81,11 @@ function UploadButton(props: { onUploadSuccess: Function; children: React.ReactE className="my-2 flex h-10 w-full items-center justify-between px-5 hover:bg-slate-100" > {item.fileName} - {item.status ? : ""} + {item.status ? ( + + ) : ( + + )} ); })}