forked from x/volcanos
opt copy
This commit is contained in:
parent
2c3fd988f1
commit
97429a6416
18
lib/user.js
18
lib/user.js
@ -32,15 +32,15 @@ Volcanos("user", {help: "用户模块", agent: {
|
||||
open: function(url) { window.open(url) },
|
||||
|
||||
copy: function(event, can, text) {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
can.user.toast(can, text, "复制成功")
|
||||
}).catch(err => {
|
||||
var input = can.page.Append(can, event.target, [{type: "input", value: text}]).first
|
||||
input.setSelectionRange(0,-1), input.focus()
|
||||
document.execCommand("Copy"), can.page.Remove(can, input)
|
||||
can.user.toast(can, text, "复制成功")
|
||||
event.stopPropagation(), event.preventDefault()
|
||||
})
|
||||
if (navigator.clipboard) { var ok = false
|
||||
navigator.clipboard.writeText(text).then(() => { ok = true })
|
||||
if (ok) { return can.user.toast(can, text, "复制成功") }
|
||||
}
|
||||
|
||||
var input = can.page.Append(can, event.target.parentNode, [{type: "input", value: text}]).first
|
||||
input.setSelectionRange(0,-1), input.focus(), document.execCommand("Copy")
|
||||
can.page.Remove(can, input), can.user.toast(can, text, "复制成功")
|
||||
event.stopPropagation(), event.preventDefault()
|
||||
},
|
||||
|
||||
camera: function(can, msg, cb) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user