mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-02 12:29:13 -04:00
15 lines
392 B
TypeScript
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);
|
|
},
|
|
};
|
|
}
|