import { XMessage } from './useMessage'
export const hookCopy = (str: string | undefined) => {
  try {
    if (str === null) return
    const tempInput = document.createElement('input')
    document.body.appendChild(tempInput)
    tempInput.setAttribute('value', str)
    tempInput.select()
    document.execCommand('copy')
    document.body.removeChild(tempInput)
    // navigator.clipboard.writeText(str);
    XMessage.success('复制成功')
  } catch {
    XMessage.error('浏览器版本太低，不支持复制功能')
  }
}
