1
0
Fork 0
mirror of https://github.com/CorentinTh/it-tools.git synced 2025-07-30 10:39:38 +02:00
it-tools/src/composable/copy.ts
2022-04-04 00:24:45 +02:00

15 lines
392 B
TypeScript

import { useClipboard } from '@vueuse/core';
import { useMessage } from 'naive-ui';
import type { Ref } from 'vue';
export function useCopy({ source, text = 'Copied to the clipboard' }: { source: Ref; text?: string }) {
const { copy } = useClipboard({ source });
const message = useMessage();
return {
async copy() {
await copy();
message.success(text);
},
};
}