<style lang="scss" scoped>
</style>
<template>
  <div>
    <SvgIcon name="ele-CopyDocument" style="color:var(--el-color-success)"  class="cursor-pointer" title="复制" @click="handleCopy"></SvgIcon>
  </div>
</template>
<script setup lang="ts" name="ExtClipboard">
import {Msg} from "/@/utils/message";

const emit = defineEmits(['on-change']);

// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
const props = defineProps({
  message: {
    type: String,
    require: true,
  },
})

const handleCopy = () => {
  if (props.message) {
    navigator.clipboard.writeText(props.message).then(() => {
      Msg.message("复制成功");
      emit('on-change',props.message)
    })
  }else{
    Msg.message("无可复制内容",'warning')
  }
}

</script>
