2022-04-23 17:58:29 +02:00
|
|
|
import {error} from '@/message'
|
|
|
|
import {useI18n} from 'vue-i18n'
|
|
|
|
|
|
|
|
export function useCopyToClipboard() {
|
2022-05-23 07:23:59 +02:00
|
|
|
const {t} = useI18n({useScope: 'global'})
|
2022-04-23 17:58:29 +02:00
|
|
|
|
|
|
|
return async (text: string) => {
|
|
|
|
try {
|
|
|
|
await navigator.clipboard.writeText(text)
|
|
|
|
} catch {
|
|
|
|
error(t('misc.copyError'))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|