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