全新popiart网站 react项目重构
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
621 B

import { Message } from "@arco-design/web-react";
import { useCallback } from "react";
import { useTranslation } from "react-i18next";
export function useCopyText() {
const { t } = useTranslation();
return useCallback(
async (text: unknown) => {
if (text === null || text === undefined || text === "") return false;
try {
await navigator.clipboard.writeText(String(text));
Message.success(t("common.copy_success"));
return true;
} catch {
Message.error(t("common.copy_failed_manual"));
return false;
}
},
[t],
);
}