This repository has been archived on 2023-08-29. You can view files and clone it, but cannot push or open issues/pull-requests.
yutent
/
anot.js
Archived
1
0
Fork 0

剪切板的操作更新为调用navigator的API

master
宇天 2019-09-02 21:01:31 +08:00
parent 9d790d087a
commit fe1fd505ed
3 changed files with 10 additions and 19 deletions

View File

@ -1,6 +1,6 @@
{
"name": "anot",
"version": "2.1.1",
"version": "2.2.0",
"description": "Anot - 迷你mvvm框架",
"main": "dist/anot.js",
"files": ["dist"],

View File

@ -31,6 +31,8 @@ function createMap() {
return Object.create(null)
}
var encode = encodeURIComponent
var decode = decodeURIComponent
var subscribers = '$' + expose
var nullObject = {} //作用类似于noop只用于代码防御千万不要在它上面添加属性

View File

@ -423,7 +423,7 @@ Anot.mix({
if ((this.type(val) == 'string' && val.trim() === '') || val === null) {
document.cookie =
encodeURIComponent(key) +
encode(key) +
'=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=' +
opt.domain +
'; path=' +
@ -447,9 +447,9 @@ Anot.mix({
}
}
document.cookie =
encodeURIComponent(key) +
encode(key) +
'=' +
encodeURIComponent(val) +
encode(val) +
opt.expires +
'; domain=' +
opt.domain +
@ -463,11 +463,11 @@ Anot.mix({
return document.cookie
}
return (
decodeURIComponent(
decode(
document.cookie.replace(
new RegExp(
'(?:(?:^|.*;)\\s*' +
encodeURIComponent(key).replace(/[\-\.\+\*]/g, '\\$&') +
encode(key).replace(/[\-\.\+\*]/g, '\\$&') +
'\\s*\\=\\s*([^;]*).*$)|^.*$'
),
'$1'
@ -484,7 +484,7 @@ Anot.mix({
if (!key || !uri) {
return null
}
uri = decodeURIComponent(uri)
uri = decode(uri)
uri = uri.slice(1)
uri = uri.split('&')
@ -509,22 +509,11 @@ Anot.mix({
},
//复制文本到粘贴板
copy: function(txt) {
if (!DOC.queryCommandSupported || !DOC.queryCommandSupported('copy')) {
return log('该浏览器不支持复制到粘贴板')
}
let ta = DOC.createElement('textarea')
ta.textContent = txt
ta.style.position = 'fixed'
ta.style.bottom = '-1000px'
DOC.body.appendChild(ta)
ta.select()
try {
DOC.execCommand('copy')
navigator.clipboard.writeText(txt)
} catch (err) {
log('复制到粘贴板失败', err)
}
DOC.body.removeChild(ta)
}
})