fix copy
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Icon } from "@iconify/vue"
|
||||
import copy from "copy-text-to-clipboard"
|
||||
import { copyToClipboard } from "~/utils/functions"
|
||||
|
||||
defineProps<{ value: string }>()
|
||||
const [copied, toggle] = useToggle()
|
||||
@@ -9,10 +9,12 @@ const { start } = useTimeoutFn(() => toggle(false), 1000, { immediate: false })
|
||||
const COPY = h(Icon, { icon: "twemoji:clipboard" })
|
||||
const OK = h(Icon, { icon: "twemoji:check-mark-button" })
|
||||
|
||||
function handleClick(value: string) {
|
||||
copy(value)
|
||||
toggle(true)
|
||||
start()
|
||||
async function handleClick(value: string) {
|
||||
const success = await copyToClipboard(value)
|
||||
if (success) {
|
||||
toggle(true)
|
||||
start()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
|
||||
@@ -9,16 +9,20 @@
|
||||
</n-tooltip>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import copyText from "copy-text-to-clipboard"
|
||||
import { copyToClipboard } from "~/utils/functions"
|
||||
|
||||
const message = useMessage()
|
||||
|
||||
const slots = useSlots()
|
||||
|
||||
function handleClick() {
|
||||
async function handleClick() {
|
||||
const textToCopy = getTextFromSlot()
|
||||
copyText(textToCopy)
|
||||
message.success("已复制")
|
||||
const success = await copyToClipboard(textToCopy)
|
||||
if (success) {
|
||||
message.success("已复制")
|
||||
} else {
|
||||
message.error("复制失败")
|
||||
}
|
||||
}
|
||||
|
||||
function getTextFromSlot() {
|
||||
|
||||
Reference in New Issue
Block a user