Files
orion-visor/orion-ops-ui/src/hooks/copy.ts

25 lines
494 B
TypeScript
Raw Normal View History

2023-09-11 16:33:57 +08:00
import { useClipboard } from '@vueuse/core';
import { Message } from '@arco-design/web-vue';
export default function useCopy() {
const { isSupported, copy: c, text, copied } = useClipboard();
const copy = (value: string, tips = `${value} 已复制`) => {
return c(value)
.then(() => {
if (tips) {
Message.success(tips);
}
}).catch(() => {
Message.error('复制失败');
});
};
return {
isSupported,
copy,
text,
copied
};
}