mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-12-11 07:13:55 +00:00
15 lines
431 B
TypeScript
15 lines
431 B
TypeScript
import { useClipboard, type MaybeRef, get } from '@vueuse/core';
|
|
import { useMessage } from 'naive-ui';
|
|
|
|
export function useCopy({ source, text = 'Copied to the clipboard' }: { source: MaybeRef<unknown>; text?: string }) {
|
|
const { copy } = useClipboard({ source: computed(() => String(get(source))) });
|
|
const message = useMessage();
|
|
|
|
return {
|
|
async copy() {
|
|
await copy();
|
|
message.success(text);
|
|
},
|
|
};
|
|
}
|