import { message } from 'antd'

function useCopy() {
    const copy = (str: string) => {
        let element = document.createElement("textarea");
        element.id = 'myTextarea'
        element.textContent = str
        document.body.append(element);
        (document.getElementById('myTextarea') as any).select();
        document.execCommand("Copy")
        document.body.removeChild(element);
        message.success(`复制成功：${str}`)
    }
    return { copy }
}

export default useCopy
