diff options
author | 2022-04-04 00:24:45 +0200 | |
---|---|---|
committer | 2022-04-04 00:24:45 +0200 | |
commit | 25a86597862051b12aa8f46c802fd6b325e4389a (patch) | |
tree | 03498bfa246236990209ff313b6b577f3c8be262 /src/composable | |
parent | 64c92a661ccf1fb6a6482c5504db97dbcb003977 (diff) | |
download | it-tools-25a86597862051b12aa8f46c802fd6b325e4389a.tar.gz it-tools-25a86597862051b12aa8f46c802fd6b325e4389a.tar.zst it-tools-25a86597862051b12aa8f46c802fd6b325e4389a.zip |
chore: components base
Diffstat (limited to 'src/composable')
-rw-r--r-- | src/composable/copy.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/composable/copy.ts b/src/composable/copy.ts new file mode 100644 index 0000000..fb29be5 --- /dev/null +++ b/src/composable/copy.ts @@ -0,0 +1,15 @@ +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); + }, + }; +} |