import { App } from 'antd'

function useCopy() {
    const { message } = App.useApp()
    const copy = (str: string) => {
        let element = document.createElement("textarea");
        element.textContent = str
        document.body.append(element);
        document.getElementsByTagName('textarea')[0].select();
        document.execCommand("Copy")
        document.body.removeChild(element);
        message.success(`复制成功：${str}`)
    }
    return { copy }
}

export default useCopy
