{"size": 640, "ext": "js", "max_stars_repo_path": "src/utils/clipboard.js", "max_stars_repo_name": "viticm/vue-app", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/utils/clipboard.js", "max_issues_repo_name": "viticm/vue-app", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/utils/clipboard.js", "max_forks_repo_name": "viticm/vue-app", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.0, "max_line_length": 55, "alphanum_fraction": 0.66875}
import Vue from 'vue'
import Clipboard from 'clipboard'

const dialog = Vue.prototype.$dialog

function clipboardSuccess() {
  dialog.message.success('Copy successfully')
}

function clipboardError() {
  dialog.message.error('Copy failed')
}

export default function handleClipboard(target, text) {
  if (! Clipboard.isSupported()) {
    clipboardError()
    return
  }
  const clipboard = new Clipboard(target, {
    text: () => text
  })
  clipboard.on('success', () => {
    clipboardSuccess()
    clipboard.destroy()
  })
  clipboard.on('error', () => {
    clipboardError()
    clipboard.destroy()
  })
  // clipboard.onClick(event)
}
