Giter Club home page Giter Club logo

Comments (6)

BobDu avatar BobDu commented on June 2, 2024

我在 chrome 123 浏览器中测试复制按钮是可以正常工作的
可以提供一些更多的信息以更好的解决这个问题吗?

from chatgpt-web.

huangzt avatar huangzt commented on June 2, 2024

我在 chrome 123 浏览器中测试复制按钮是可以正常工作的 可以提供一些更多的信息以更好的解决这个问题吗?
我的是macbook pro m1
mac下都提示复制失败!

image image

Parallels Desktop 虚拟机win11,同样也是提示复制失败!
image
image

这个js对象 navigator.clipboard 是 undefined

上面各个版本测试了,确实不行。可以让有macbook的同事帮忙测试下

from chatgpt-web.

huangzt avatar huangzt commented on June 2, 2024

原来的代码这样改就可以了吧?可能是监听事件的问题!

export function copyToClip(text: string) {
return new Promise((resolve, reject) => {
try {
const input: HTMLTextAreaElement = document.createElement('textarea')
input.setAttribute('readonly', 'readonly')
input.value = text?.replace(/\n+$/, '\n')
document.body.appendChild(input)
input.select()
if (document.execCommand('copy'))
document.execCommand('copy')
document.body.removeChild(input)
resolve(text)
}
catch (error) {
reject(error)
}
})
}

from chatgpt-web.

huangzt avatar huangzt commented on June 2, 2024

上面这样改测试没有问题的,仅供参考:
image

from chatgpt-web.

BobDu avatar BobDu commented on June 2, 2024

应该是 你使用的 http 访问一个非localhost地址 导致的 navigator.clipboard api无法使用?
方便的话帮忙测试一下PR中的更改是否解决了这个问题?
ping @huangzt

from chatgpt-web.

huangzt avatar huangzt commented on June 2, 2024

测试可以
@BobDu

from chatgpt-web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.