mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-24 02:02:35 -04:00
15 lines
388 B
TypeScript
15 lines
388 B
TypeScript
import { useClipboard, type MaybeRef } from '@vueuse/core';
|
|
import { useMessage } from 'naive-ui';
|
|
|
|
export function useCopy({ source, text = 'Copied to the clipboard' }: { source: MaybeRef<string>; text?: string }) {
|
|
const { copy } = useClipboard({ source });
|
|
const message = useMessage();
|
|
|
|
return {
|
|
async copy() {
|
|
await copy();
|
|
message.success(text);
|
|
},
|
|
};
|
|
}
|