chore: updates

This commit is contained in:
zerosoul
2022-05-18 22:19:11 +08:00
parent 6272e14493
commit ee527e47e6
10 changed files with 108 additions and 66 deletions
+3 -2
View File
@@ -12,6 +12,7 @@ const StyledMenu = styled.ul`
.item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
white-space: nowrap;
cursor: pointer;
@@ -23,8 +24,8 @@ const StyledMenu = styled.ul`
line-height: 20px;
color: #616161;
.icon {
width: 20px;
height: 20px;
width: 12px;
height: 12px;
path {
fill: #475467;
}
+16 -5
View File
@@ -1,4 +1,6 @@
import { useState } from "react";
import { copyImageToClipboard } from "copy-image-clipboard";
const useCopy = () => {
const copyToClipboard = (str) => {
const el = document.createElement("textarea");
@@ -23,13 +25,22 @@ const useCopy = () => {
const [copied, setCopied] = useState(false);
const copy = (text) => {
const copy = (text, isImage = false) => {
let inter = 0;
if (!copied) {
setCopied(copyToClipboard(text));
inter = setTimeout(() => {
setCopied(false);
}, 500);
if (!isImage) {
setCopied(copyToClipboard(text));
inter = setTimeout(() => {
setCopied(false);
}, 500);
} else {
copyImageToClipboard(text).then(() => {
setCopied(true);
inter = setTimeout(() => {
setCopied(false);
}, 500);
});
}
}
return () => {
clearTimeout(inter);