fix: copy to clipboard failed in non-secure (HTTP) contexts (#32287)

This commit is contained in:
hizhujianfeng
2026-03-10 15:46:17 +08:00
committed by GitHub
parent 322d3cd555
commit 2a468da440
3 changed files with 23 additions and 4 deletions

View File

@ -1,10 +1,10 @@
'use client'
import copy from 'copy-to-clipboard'
import { t } from 'i18next'
import * as React from 'react'
import { useEffect, useState } from 'react'
import CopyFeedback from '@/app/components/base/copy-feedback'
import Tooltip from '@/app/components/base/tooltip'
import { writeTextToClipboard } from '@/utils/clipboard'
type IInputCopyProps = {
value?: string
@ -39,8 +39,9 @@ const InputCopy = ({
<div
className="r-0 absolute left-0 top-0 w-full cursor-pointer truncate pl-2 pr-2"
onClick={() => {
copy(value)
setIsCopied(true)
writeTextToClipboard(value).then(() => {
setIsCopied(true)
})
}}
>
<Tooltip