mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-20 14:56:17 -04:00
16 lines
392 B
TypeScript
16 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);
|
||
|
},
|
||
|
};
|
||
|
}
|