feat: copy settings config

This commit is contained in:
archer
2023-08-16 18:21:55 +08:00
parent a149b3a2ce
commit 2c174aa91c
8 changed files with 173 additions and 69 deletions

View File

@@ -1,15 +1,21 @@
import crypto from 'crypto';
import { useToast } from '@/hooks/useToast';
import dayjs from 'dayjs';
import { useTranslation } from 'react-i18next';
/**
* copy text data
*/
export const useCopyData = () => {
const { t } = useTranslation();
const { toast } = useToast();
return {
copyData: async (data: string, title: string = '复制成功', duration = 1000) => {
copyData: async (
data: string,
title: string | null = t('common.Copy Successful'),
duration = 1000
) => {
try {
if (navigator.clipboard) {
await navigator.clipboard.writeText(data);