This commit is contained in:
2025-10-05 01:40:12 +08:00
parent aa8fcccf7d
commit 41d3246246
4 changed files with 51 additions and 13 deletions

View File

@@ -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>

View File

@@ -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() {