mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-26 09:19:43 +00:00
* Move revertChanges * Show launch args * Explicit ServerConfigValue type * nit * nit * Add tests
38 lines
833 B
TypeScript
38 lines
833 B
TypeScript
import { useClipboard } from '@vueuse/core'
|
|
import { useToast } from 'primevue/usetoast'
|
|
|
|
export function useCopyToClipboard() {
|
|
const { copy, isSupported } = useClipboard()
|
|
const toast = useToast()
|
|
|
|
const copyToClipboard = async (text: string) => {
|
|
if (isSupported) {
|
|
try {
|
|
await copy(text)
|
|
toast.add({
|
|
severity: 'success',
|
|
summary: 'Success',
|
|
detail: 'Copied to clipboard',
|
|
life: 3000
|
|
})
|
|
} catch (err) {
|
|
toast.add({
|
|
severity: 'error',
|
|
summary: 'Error',
|
|
detail: 'Failed to copy report'
|
|
})
|
|
}
|
|
} else {
|
|
toast.add({
|
|
severity: 'error',
|
|
summary: 'Error',
|
|
detail: 'Clipboard API not supported in your browser'
|
|
})
|
|
}
|
|
}
|
|
|
|
return {
|
|
copyToClipboard
|
|
}
|
|
}
|