From 6c161866dae99880f85b72a6f09388676d579df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Fri, 8 Jan 2021 20:34:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=98=85=E8=AF=BB=E5=99=A81.?= =?UTF-8?q?0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/app.css | 2 +- src/css/app.scss | 26 ++ src/css/view.scss | 2 +- src/index.html | 26 +- src/js/app.js | 195 +++++++++- src/js/view.js | 55 ++- src/lib/anot.js | 8 +- src/lib/drag/core.js | 2 +- src/lib/drag/index.js | 2 +- src/lib/icon/index.js | 16 +- src/lib/layer/index.js | 16 +- src/lib/md5.js | 764 ++++++++++++++++++++++++++++++++++++++++ src/lib/scroll/index.js | 16 +- src/lib/utils.js | 2 +- src/main.js | 10 +- src/tools/socket.js | 59 ++-- src/tools/window.js | 26 +- src/view.html | 2 +- 18 files changed, 1120 insertions(+), 109 deletions(-) create mode 100644 src/lib/md5.js diff --git a/src/css/app.css b/src/css/app.css index f22fd40..8837de6 100644 --- a/src/css/app.css +++ b/src/css/app.css @@ -1 +1 @@ -html{width:100%;height:100vh}body{overflow:hidden;display:flex;width:100%;height:100%;line-height:1.25;font-size:14px;color:var(--color-dark-1);background:rgba(255,255,255,0.3)}.app{position:relative;display:flex;height:100%}.app .category{width:200px;height:100%;background:#fff}.app .category .item{display:flex;justify-content:space-between;align-items:center;height:54px;padding:8px;border-bottom:1px solid var(--color-plain-1);background:#fff;transition:background 0.2s ease-in-out, color 0.2s ease-in-out;cursor:pointer}.app .category .item strong{max-width:150px}.app .category .item .num{display:flex;justify-content:center;align-items:center;min-width:16px;height:16px;padding:2px;line-height:1;border-radius:50%;font-size:12px;background:var(--color-grey-1);color:#fff}.app .category .item:last-child{border-bottom:0}.app .category .item:hover{color:var(--color-blue-1);background:var(--color-plain-1)}.app .category .item.active{color:var(--color-plain-1);background:var(--color-blue-1)}.app .category .item.active .num{background:#fff;color:var(--color-blue-1)}.app .books-scroll{flex:1;height:100%;border-left:1px solid var(--color-plain-2)}.app .books{display:flex;flex-wrap:wrap}.app .books .book{display:flex;flex-direction:column;width:128px;margin:24px;background:#fff;box-shadow:0 0 12px rgba(0,0,0,0.15);transition:box-shadow 0.1s ease-in;cursor:pointer}.app .books .book img{width:100%;height:160px;-o-object-fit:fill;object-fit:fill}.app .books .book:hover{box-shadow:0 0 12px rgba(0,0,0,0.35)}.app .drag-mask{display:flex;align-items:center;position:fixed;left:0;top:0;z-index:9999;width:100%;height:100%;background:linear-gradient(to right, transparent, transparent 200px, rgba(252,232,207,0.6) 200px)}.app .drag-mask::after{font-size:46px;text-indent:360px;content:'Drop epub file here...';color:var(--color-grey-1)}.app .book-loading{display:flex;align-items:center;justify-content:center;position:fixed;left:0;top:0;z-index:9999;width:100%;height:100%;font-size:20px;background:rgba(255,255,255,0.01);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.app .book-loading .loading{display:flex;flex-direction:column;align-items:center;justify-content:center}.app .book-loading .loading::before{content:'🌑';font-size:36px;-webkit-animation:loading 1s infinite;animation:loading 1s infinite}@-webkit-keyframes loading{1%,100%{content:'🌑'}12.5%{content:'🌒'}25%{content:'🌓'}37.5%{content:'🌔'}50%{content:'🌕'}62.5%{content:'🌖'}75%{content:'🌗'}87.5%{content:'🌘'}}@keyframes loading{1%,100%{content:'🌑'}12.5%{content:'🌒'}25%{content:'🌓'}37.5%{content:'🌔'}50%{content:'🌕'}62.5%{content:'🌖'}75%{content:'🌗'}87.5%{content:'🌘'}} +html{width:100%;height:100vh}body{overflow:hidden;display:flex;width:100%;height:100%;line-height:1.25;font-size:14px;color:var(--color-dark-1);background:rgba(255,255,255,0.3)}.app{position:relative;display:flex;width:100%;height:100%}.app .category{width:200px;height:100%;background:#fff}.app .category .item{display:flex;justify-content:space-between;align-items:center;height:54px;padding:8px;border-bottom:1px solid var(--color-plain-1);background:#fff;transition:background 0.2s ease-in-out, color 0.2s ease-in-out;cursor:pointer}.app .category .item strong{max-width:150px}.app .category .item .num{display:flex;justify-content:center;align-items:center;min-width:16px;height:16px;padding:2px;line-height:1;border-radius:50%;font-size:12px;background:var(--color-grey-1);color:#fff}.app .category .item:last-child{border-bottom:0}.app .category .item:hover{color:var(--color-blue-1);background:var(--color-plain-1)}.app .category .item.active{color:var(--color-plain-1);background:var(--color-blue-1)}.app .category .item.active .num{background:#fff;color:var(--color-blue-1)}.app .books-scroll{flex:1;height:100%;border-left:1px solid var(--color-plain-2)}.app .books{display:flex;flex-wrap:wrap}.app .books .book{display:flex;flex-direction:column;width:128px;margin:24px;background:#fff;box-shadow:0 0 12px rgba(0,0,0,0.15);transition:box-shadow 0.1s ease-in;cursor:pointer}.app .books .book img{width:100%;height:160px;-o-object-fit:fill;object-fit:fill}.app .books .book:hover{box-shadow:0 0 12px rgba(0,0,0,0.35)}.app .drag-mask{display:flex;align-items:center;position:fixed;left:0;top:0;z-index:9999;width:100%;height:100%;background:linear-gradient(to right, transparent, transparent 200px, rgba(252,232,207,0.6) 200px)}.app .drag-mask::after{font-size:46px;text-indent:360px;content:'Drop epub file here...';color:var(--color-grey-1)}.app .book-loading{display:flex;align-items:center;justify-content:center;position:fixed;left:0;top:0;z-index:9999;width:100%;height:100%;font-size:20px;background:rgba(255,255,255,0.01);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.app .book-loading .loading{display:flex;flex-direction:column;align-items:center;justify-content:center}.app .book-loading .loading::before{content:'🌑';font-size:36px;-webkit-animation:loading 1s infinite;animation:loading 1s infinite}.app .context-menu{display:flex;flex-direction:column;width:100px;padding:5px 0;background:#fff}.app .context-menu .item{height:30px;line-height:30px;padding:0 15px;cursor:pointer}.app .context-menu .item:hover{background:#f2f5fc}.app .context-menu .item.diabled{color:var(--color-plain-2);background:#fff;cursor:default}@-webkit-keyframes loading{1%,100%{content:'🌑'}12.5%{content:'🌒'}25%{content:'🌓'}37.5%{content:'🌔'}50%{content:'🌕'}62.5%{content:'🌖'}75%{content:'🌗'}87.5%{content:'🌘'}}@keyframes loading{1%,100%{content:'🌑'}12.5%{content:'🌒'}25%{content:'🌓'}37.5%{content:'🌔'}50%{content:'🌕'}62.5%{content:'🌖'}75%{content:'🌗'}87.5%{content:'🌘'}} diff --git a/src/css/app.scss b/src/css/app.scss index efd3c97..dff5881 100644 --- a/src/css/app.scss +++ b/src/css/app.scss @@ -24,6 +24,7 @@ body { .app { position: relative; display: flex; + width: 100%; height: 100%; .category { @@ -163,6 +164,31 @@ body { } } } + + .context-menu { + display: flex; + flex-direction: column; + width: 100px; + padding: 5px 0; + background: #fff; + + .item { + height: 30px; + line-height: 30px; + padding: 0 15px; + cursor: pointer; + + &:hover { + background: #f2f5fc; + } + + &.diabled { + color: var(--color-plain-2); + background: #fff; + cursor: default; + } + } + } } @keyframes loading { diff --git a/src/css/view.scss b/src/css/view.scss index 31b0d40..6834bd7 100644 --- a/src/css/view.scss +++ b/src/css/view.scss @@ -1,6 +1,6 @@ @charset "UTF-8"; /** - * 浮窗样式 + * 阅读样式 * @authors yutent * @date 2018/12/16 17:15:07 */ diff --git a/src/index.html b/src/index.html index c3eb069..b6d5607 100644 --- a/src/index.html +++ b/src/index.html @@ -16,6 +16,8 @@ @@ -28,7 +30,12 @@ - + @@ -38,13 +45,28 @@
-
+
共 {{load.num}} 本书 当前正在解析第 {{load.curr}} 本
+ +
    +
  • 删除
  • +
  • 重命名
  • +
  • 新建分类
  • +
+
+ + +
    +
  • 删除
  • +
  • 移动到
  • +
+
+
diff --git a/src/js/app.js b/src/js/app.js index f43c2d6..41f93cf 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -9,7 +9,9 @@ import '/lib/anot.js' import '/lib/scroll/index.js' -import layer from '/lib/layer/index.js' +import '/lib/layer/index.js' +import Utils from '/lib/utils.js' +import { md5 } from '/lib/md5.js' import app from '/lib/socket.js' @@ -25,7 +27,7 @@ Anot({ state: { input: '', curr: '默认分类', - cates: [{ name: '默认分类', num: 12 }], + cates: [], books: [], loading: false, isDragIn: false, @@ -33,12 +35,21 @@ Anot({ num: 0, curr: 0 }, - $db: {} + $db: {}, + $ctx1: null, + $ctx2: null }, - watch: {}, - mounted() { + Utils.outside(this.$refs.ctx1, ev => { + this.$refs.ctx1.close() + }) + + Utils.outside(this.$refs.ctx2, ev => { + this.$refs.ctx2.close() + }) + + /* --------------------- */ $doc.bind('dragover', ev => { ev.preventDefault() @@ -50,7 +61,7 @@ Anot({ this.isDragIn = false }) - $doc.bind('drop', ev => { + $doc.bind('drop', async ev => { ev.preventDefault() this.isDragIn = false @@ -72,17 +83,32 @@ Anot({ let book = files.pop() let res = app.dispatch('parse-book', { book, cate: this.curr }) + await sleep(500) + if (res) { this.books.push(res) } } + for (let it of this.cates) { + if (it.name === this.curr) { + it.num = this.books.length + break + } + } this.loading = false }) + /* --------------------- */ + let db = app.dispatch('get-books') let cates = [], books + + if (Object.keys(db).length < 1) { + db = { 默认分类: [] } + } + for (let k in db) { cates.push({ name: k, num: db[k].length }) // 默认选中第一个 @@ -91,10 +117,161 @@ Anot({ books = db[k] } } - // books = books.concat(books, books, books, books, books, books) + this.$db = db this.cates = cates - this.books = books + this.books = books || [] }, - methods: {} + methods: { + view(item) { + this.books = this.$db[item.name] + }, + read(item) { + var params = { title: item.title } + var readCache = Anot.ls(md5(item.title)) + + if (readCache) { + params.chapter = readCache + } + + app.dispatch( + 'read', + Buffer.from(JSON.stringify(params)).toString('base64') + ) + }, + + pickCtx1(item, ev) { + this.$ctx1 = item + ev.stopPropagation() + + let { pageX, pageY } = ev + if (pageY + 70 > 600) { + pageY -= 70 + } + + this.$refs.ctx1.close() + + Anot.nextTick(_ => { + this.$refs.ctx1.moveTo({ left: pageX + 'px', top: pageY + 'px' }) + this.$refs.ctx1.show() + }) + }, + + pickCtx2(item, ev) { + this.$ctx2 = item + + ev.stopPropagation() + + let { pageX, pageY } = ev + if (pageY + 70 > 600) { + pageY -= 70 + } + + this.$refs.ctx2.close() + + Anot.nextTick(_ => { + this.$refs.ctx2.moveTo({ left: pageX + 'px', top: pageY + 'px' }) + this.$refs.ctx2.show() + }) + }, + saveDB() { + app.dispatch('save-books', Anot.deepCopy(this.$db)) + }, + + deleteCate() { + // + this.$refs.ctx1.close() + if (this.$ctx1) { + let { name, num } = this.$ctx1 + + if (num > 0) { + return layer.toast(`${name} 下有书籍, 不可删除!`, 'error') + } + delete this.$db[name] + this.cates.remove(this.$ctx1) + this.saveDB() + } + }, + + createCate() { + this.$ctx1 = null + this.$refs.ctx1.close() + + layer + .prompt('请输入分类名', (val, done) => { + if (val.trim()) { + if (this.$db[val.trim()]) { + return layer.toast('分类已存在, 请换个名字', 'error') + } + done() + } + }) + .then(v => { + v = v.trim() + this.$db[v] = [] + this.cates.push({ name: v, num: 0 }) + this.saveDB() + }) + .catch(Anot.noop) + }, + + renameCate() { + // + this.$refs.ctx1.close() + if (this.$ctx1) { + let { name } = this.$ctx1 + + layer + .prompt(`请输入新的分类名(${name})`, (val, done) => { + val = val.trim() + if (val) { + if (this.$db[val] || val === name) { + return layer.toast('分类已存在, 请换个名字', 'error') + } + done() + } + }) + .then(v => { + v = v.trim() + this.$db[v] = this.$db[name] + delete this.$db[name] + this.$ctx1.name = v + this.$ctx1 = null + this.saveDB() + }) + .catch(Anot.noop) + } + }, + + deleteBook() { + this.$refs.ctx2.close() + if (this.$ctx2) { + let { title } = this.$ctx2 + layer + .confirm(`是否要删除[${title}]? 该操作不可逆!`) + .then(r => { + this.books.remove(this.$ctx2) + this.$db[this.curr] = this.books + + for (let it of this.cates) { + if (it.name === this.curr) { + it.num = this.books.length + break + } + } + + this.saveDB() + app.dispatch('delete-book', title) + }) + .catch(Anot.noop) + } + } + + // moveBook() { + // this.$refs.ctx2.close() + // if (this.$ctx2) { + // let { title } = this.$ctx2 + // } + // } + } }) diff --git a/src/js/view.js b/src/js/view.js index 70367ab..18bb245 100644 --- a/src/js/view.js +++ b/src/js/view.js @@ -8,7 +8,7 @@ import '/lib/anot.js' import '/lib/scroll/index.js' import '/lib/code/index.js' -import layer from '/lib/layer/index.js' +import { md5 } from '/lib/md5.js' import fetch from '/lib/fetch/index.js' import app from '/lib/socket.js' @@ -16,29 +16,52 @@ Anot({ $id: 'app', state: { toc: [], - title: 'HTML5 canvas开发详解(第2版) (无)', - curr: '', - file: '', - chapter: '' + book: '', // 当前阅读的书名 + curr: '', // 当前选中的章节名 + file: '', // 章节所属的文件名 + chapter: '' // 章节渲染html文本 }, mounted() { - // app.on('float-visible', data => {}) + var search = location.search - document.title = this.title - this.getToc() + if (search) { + search = JSON.parse(Buffer.from(search.slice(1), 'base64')) + + document.title = this.book = search.title + this.curr = search.chapter || '' + + this.getToc() + } }, methods: { getToc() { - fetch('book://cache/HTML5 canvas开发详解(第2版) (无)/toc.json') + fetch(`book://cache/${this.book}/toc.json`) .then(r => r.json()) .then(list => { - for (let it of list) { + let chapter, idx + for (let i = -1, it; (it = list[++i]); ) { delete it.id delete it.order - } - this.toc = list - this.viewChapter(list[23]) + it.href = it.href.replace('.xhtml', '.html') + + if (it.title === this.curr) { + chapter = it + idx = i + } + } + + if (!chapter) { + chapter = list[0] + idx = 0 + } + + this.toc = list + this.viewChapter(chapter) + + setTimeout(() => { + this.$refs.toc.scrollTop = 36 * (idx - 10) + }, 100) }) }, @@ -49,6 +72,8 @@ Anot({ this.curr = item.title + Anot.ls(md5(this.book), item.title) + if (this.file === file) { if (hash) { location.hash = hash @@ -58,14 +83,14 @@ Anot({ } } else { this.file = file - fetch('book://cache/HTML5 canvas开发详解(第2版) (无)/' + file) + fetch(`book://cache/${this.book}/${file}`) .then(r => r.text()) .then(txt => { this.chapter = txt.replace( /]*?src="(.*?)"[^>]*?\/?>/g, (m, s1) => { s1 = s1.replace('../', '') - return `` + return `` } ) diff --git a/src/lib/anot.js b/src/lib/anot.js index 2f010fd..5be5269 100644 --- a/src/lib/anot.js +++ b/src/lib/anot.js @@ -1,8 +1,8 @@ /*================================================== * Anot normal version for future browsers - * @authors yutent (yutent@doui.cc) - * @date 2017-03-21 21:05:57 - * V2.0.0 + * @authors yutent + * @date 2021-01-08 10:31:08 + * @version v2.2.4 * ==================================================*/ - const _Anot=function(){var e=1024,t=A(),n=window.document,r=n.head;r.insertAdjacentHTML("afterbegin",'');var i=r.firstChild;function a(){console.log.apply(console,arguments)}function o(){return Object.create(null)}var s=encodeURIComponent,c=decodeURIComponent,l="$"+t,u={},f=/[^, ]+/g,p=/\w+/g,d=/^\[object SVG\w*Element\]$/,h=Object.prototype,v=h.hasOwnProperty,m=h.toString,y=Array.prototype,g=y.slice,b=n.documentElement,$=n.createDocumentFragment(),x=(n.createElement("div"),{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object","[object Error]":"error","[object AsyncFunction]":"asyncfunction","[object Promise]":"promise","[object Generator]":"generator","[object GeneratorFunction]":"generatorfunction"});function w(){}function k(e){return Function.apply(w,e)}function C(e,t){"string"==typeof e&&(e=e.match(f)||[]);for(var n={},r=void 0!==t?t:1,i=0,a=e.length;i{e.resolve=t,e.reject=n}),e}),String.prototype.splice||Object.defineProperty(String.prototype,"splice",{value:function(e,t,n){let r=this.length,i=arguments.length;if(n=void 0===n?"":n,i<1)return this;if(e<0&&(e=Math.abs(e)>=r?0:r+e),1===i)return this.slice(0,e);return t-=0,this.slice(0,e)+n+this.slice(e+t)},enumerable:!1}),Date.prototype.getFullWeek||(Object.defineProperty(Date.prototype,"getFullWeek",{value:function(){let e=this.getFullYear(),t=new Date(e,0,1),n=t.getDay()||1,r=(this-t)/864e5;return Math.ceil((r+n)/7)},enumerable:!1}),Object.defineProperty(Date.prototype,"getWeek",{value:function(){let e=this.getDate(),t=this.getMonth(),n=this.getFullYear(),r=new Date(n,t,1).getDay();return Math.ceil((e+r)/7)},enumerable:!1})),Date.isDate||Object.defineProperty(Date,"isDate",{value:function(e){return!("object"!=typeof e||!e.getTime)},enumerable:!1}),Date.prototype.format||Object.defineProperty(Date.prototype,"format",{value:function(e){e=e||"Y-m-d H:i:s";let t,n={fullyear:this.getFullYear(),year:this.getYear(),fullweek:this.getFullWeek(),week:this.getWeek(),month:this.getMonth()+1,date:this.getDate(),day:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"][this.getDay()],hours:this.getHours(),minutes:this.getMinutes(),seconds:this.getSeconds()};n.g=n.hours>12?n.hours-12:n.hours,t={Y:n.fullyear,y:n.year,m:n.month<10?"0"+n.month:n.month,n:n.month,d:n.date<10?"0"+n.date:n.date,j:n.date,H:n.hours<10?"0"+n.hours:n.hours,h:n.g<10?"0"+n.g:n.g,G:n.hours,g:n.g,i:n.minutes<10?"0"+n.minutes:n.minutes,s:n.seconds<10?"0"+n.seconds:n.seconds,W:n.fullweek,w:n.week,D:n.day};for(let n in t)e=e.replace(new RegExp(n,"g"),t[n]);return e},enumerable:!1});let N=function(e){return new N.init(e)};N.nextTick=new function(){let e=window.setImmediate,t=window.MutationObserver;if(e)return e.bind(window);let n=[];if(t){let e=document.createTextNode("anot");new t(function(){let e=n.length;for(let t=0;t>>0)return!0}return!1}(e))for(let n=0,r=e.length;n1){if(!e)return;if(n=n||{},n=Object.assign({expires:"",path:"/",domain:document.domain,secure:""},n),"string"==this.type(t)&&""===t.trim()||null===t)return document.cookie=s(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain="+n.domain+"; path="+n.path,!0;if(n.expires)switch(n.expires.constructor){case Number:n.expires=n.expires===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+n.expires;break;case String:n.expires="; expires="+n.expires;break;case Date:n.expires="; expires="+n.expires.toUTCString()}return document.cookie=s(e)+"="+s(t)+n.expires+"; domain="+n.domain+"; path="+n.path+"; "+n.secure,!0}return e?c(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+s(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null:document.cookie},search:function(e){e+="";let t=location.search;if(!e||!t)return null;t=(t=(t=c(t)).slice(1)).split("&");let n={};for(let e,r=0;e=t[r++];){let t=e.split("=");t[1]=t.length<2?null:t[1],t[1]=t[1],n.hasOwnProperty(t[0])?"object"==typeof n[t[0]]?n[t[0]].push(t[1]):(n[t[0]]=[n[t[0]]],n[t[0]].push(t[1])):n[t[0]]=t[1]}return n.hasOwnProperty(e)?n[e]:null},copy:function(e){try{navigator.clipboard.writeText(e)}catch(e){a("复制到粘贴板失败",e)}}});let O=N.bindingHandlers={},E=N.bindingExecutors={},S=N.directives={};N.directive=function(e,t){return O[e]=t.init=t.init||w,E[e]=t.update=t.update||w,S[e]=t};let D=new function(){function e(e){this.size=0,this.limit=e,this.head=this.tail=void 0,this._keymap={}}let t=e.prototype;return t.put=function(e,t){let n={key:e,value:t};return this._keymap[e]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit?this.shift():this.size++,t},t.shift=function(){let e=this.head;e&&(this.head=this.head.newer,this.head.older=e.newer=e.older=this._keymap[e.key]=void 0,delete this._keymap[e.key])},t.get=function(e){let t=this._keymap[e];if(void 0!==t)return t===this.tail?t.value:(t.newer&&(t===this.head&&(this.head=t.newer),t.newer.older=t.older),t.older&&(t.older.newer=t.newer),t.newer=void 0,t.older=this.tail,this.tail&&(this.tail.newer=t),this.tail=t,t.value)},e};n.contains||(Node.prototype.contains=function(e){return!!(16&this.compareDocumentPosition(e))}),N.contains=function(e,t){try{for(;t=t.parentNode;)if(t===e)return!0;return!1}catch(e){return!1}};let _=N.eventHooks;function P(e){for(var t in e)if(v.call(e,t)){var n=e[t];"function"==typeof P.plugins[t]?P.plugins[t](n):"object"==typeof P[t]?N.mix(P[t],n):P[t]=n}return this}void 0===n.onmousewheel&&(_.mousewheel={type:"wheel",fix:function(e,t){return function(n){n.wheelDeltaY=n.wheelDelta=n.deltaY>0?-120:120,n.wheelDeltaX=0,Object.defineProperty(n,"type",{value:"mousewheel"}),t.call(e,n)}}}),N.config=P;var L,M,H,F,B=/[-.*+?^${}()|[\]\/\\]/g;function I(e){return(e+"").replace(B,"\\$&")}var R={interpolate:function(e){if(L=e[0],M=e[1],L===M)throw new SyntaxError("openTag!==closeTag");P.openTag=L,P.closeTag=M;var t=I(L),n=I(M);H=new RegExp(t+"([\\s\\S]*)"+n),F=new RegExp(t+"([\\s\\S]*)"+n,"g"),new RegExp(t+"[\\s\\S]*"+n+"|\\s:")}};function q(t,r){var i=this.$events||(this.$events={}),a=i[t]||(i[t]=[]);if("function"==typeof r){var o=r;o.uuid="_"+ ++e,(r={element:b,type:"user-watcher",handler:w,vmodels:[this],expr:t,uuid:o.uuid}).wildcard=/\*/.test(t)}if(r.update)r.oneTime||N.Array.ensure(a,r);else{if(/\w\.*\B/.test(t)||"*"===t){r.getter=w;var s=this;r.update=function(){var e=this.fireArgs||[];e[2]&&r.handler.apply(s,e),delete this.fireArgs},a.sync=!0,N.Array.ensure(a,r)}else N.injectBinding(r);o&&(r.handler=o)}return function(){r.update=r.getter=r.handler=w,r.element=n.createElement("a")}}function V(t,n){var r=this.$events,i=null;if(r&&r[t]){n&&(n[2]=t);var a=r[t];if(function(t,n){if(!t)return;new Date-se>444&&"object"==typeof t[0]&&le();for(var r,i=[],a=[],o=0;r=t[o++];)"user-watcher"===r.type?i.push(r):a.push(r);if(P.async){for(dt.render(),o=0;r=a[o++];)if(r.update){r.uuid=r.uuid||"_"+ ++e;var s=r.uuid;dt.queue[s]||(dt.queue[s]="__",dt.queue.push(r))}}else for(o=0;r=a[o++];)r.update&&r.update();for(o=0;r=i[o++];)(n&&n[2]===r.expr||r.wildcard)&&(r.fireArgs=n),r.update()}(a,n),n&&r["*"]&&!/\./.test(t))for(var o,s=0;o=r["*"][s++];)try{o.handler.apply(this,n)}catch(e){}(i=this.$up)&&(this.$pathname&&V.call(i,this.$pathname+"."+t,n),V.call(i,"*."+t,n))}else{if(i=this.$up,this.$ups){for(var c in this.$ups)V.call(this.$ups[c],c+"."+t,n);return}if(i){var l=this.$pathname;""===l&&(l="*");var u=l+"."+t;a=u.split("."),n=n&&n.concat([u,t])||[u,t],-1===a.indexOf("*")?(V.call(i,u,n),a[1]="*",V.call(i,a.join("."),n)):V.call(i,u,n)}}}P.plugins=R,P.plugins.interpolate(["{{","}}"]),P.async=!0,P.paths={},P.shim={},P.maxRepeatSize=100;var W=C("$id,$watch,$fire,$events,$model,$active,$pathname,$up,$ups,$track,$accessors");function z(e,t){return(t=t||{}).watch=!0,U(e,t)}function U(e,t){if(!e||e.$id&&e.$accessors||e.nodeName&&e.nodeType>0)return e;var n,r=(t=t||u).force||u,i=t.old,o=i&&i.$accessors||u,s=new function(){},c={},l={},f=[],p=[],d={},h=e.state,v=e.computed,m=e.methods,y=e.props,g=e.watch,b=e.mounted;if(delete e.state,delete e.computed,delete e.methods,delete e.props,delete e.watch,e.skip&&(d=C(e.skip),delete e.skip),h)for(x in e.$id&&delete h.props,h){var $=h[x];W[x]||(l[x]=!0),"function"==typeof $||$&&$.nodeName&&$.nodeType>0||!r[x]&&("$"===(n=x).charAt(0)||"__"===n.slice(0,2)||W[n]||d[x])?f.push(x):Y($)?(a("warning:计算属性建议放在[computed]对象中统一定义"),v[x]=$):(p.push(x),o[x]?c[x]=o[x]:c[x]=G(x,$))}if(v)for(var x in delete v.props,v)l[x]=!0,function(e,t){var n;"function"==typeof t&&(t={get:t,set:w}),"function"!=typeof t.set&&(t.set=w),c[e]={get:function(){return n=t.get.call(this)},set:function(r){var i,a=n;t.set.call(this,r),i=this[e],this.$fire&&i!==a&&this.$fire(e,i,a)},enumerable:!0,configurable:!0}}(x,v[x]);if(m)for(var x in delete m.props,m)l[x]=!0,f.push(x);if(y)for(var x in X(s,"props",{}),l.props=!!e.$id,y)s.props[x]=y[x];if(Object.assign(e,h,m),c.$model=Z,s=Object.defineProperties(s,c,e),f.forEach(function(t){s[t]=e[t]}),X(s,"$id","anonymous"),X(s,"$up",i?i.$up:null),X(s,"$track",Object.keys(l)),X(s,"$active",!1),X(s,"$pathname",i?i.$pathname:""),X(s,"$accessors",c),X(s,"$events",{}),X(s,"$refs",{}),X(s,"$children",[]),X(s,"hasOwnProperty",function(e){return!0===l[e]}),X(s,"$mounted",b),t.watch&&(X(s,"$watch",function(){return q.apply(s,arguments)}),X(s,"$fire",function(e,t){if(0===e.indexOf("all!")){var n=e.slice(4);for(var r in N.vmodels){(i=N.vmodels[r]).$fire&&i.$fire.apply(i,[n,t])}}else if(0===e.indexOf("child!")){n="props."+e.slice(6);for(var r in s.$children){var i;(i=s.$children[r]).$fire&&i.$fire.apply(i,[n,t])}}else V.call(s,e,[t])})),p.forEach(function(e){var t=i&&i[e],n=s[e]=h[e];n&&"object"==typeof n&&!Date.isDate(n)&&(n.$up=s,n.$pathname=e),V.call(s,e,[n,t])}),g)for(var k in delete g.props,g)if(Array.isArray(g[k]))for(var A;A=g[k].pop();)q.call(s,k,A);else q.call(s,k,g[k]);return s.$active=!0,"anonymous"!==s.$id&&i&&i.$up&&i.$up.$children&&i.$up.$children.push(s),s}function Y(e){if(e&&"object"==typeof e){for(var t in e)if("get"!==t&&"set"!==t)return!1;return"function"==typeof e.get}}function G(e,t){var n;t=NaN;return{get:function(){return this.$active&&function(e,t){for(;;){if(e.$watch){var n=e.$events||(e.$events={}),r=n[t]||(n[t]=[]);return void ae.collectDependency(r)}if(!(e=e.$up))break;t=e.$pathname+"."+t}}(this,e),t},set:function(r){if(t!==r){var i=t;(n=J(r,t))?t=n:(n=void 0,t=r),Object(n)===n&&(n.$pathname=e,n.$up=this),this.$active&&V.call(this,e,[t,i])}},enumerable:!0,configurable:!0}}function J(e,t,n,r){if(Array.isArray(e))return function(e,t,n){if(t&&t.splice){var r=[0,t.length].concat(e);return t.splice.apply(t,r),t}for(var i in ee)e[i]=ee[i];X(e,"$up",null),X(e,"$pathname",""),X(e,"$track",ne(e.length)),e._=U({state:{length:NaN}},{watch:!0}),e._.length=e.length,e._.$watch("length",function(t,n){V.call(e.$up,e.$pathname+".length",[t,n])}),n&&X(e,"$watch",function(){return q.apply(e,arguments)}),Object.defineProperty(e,"$model",Z);for(var a=0,o=e.length;a>>=0)>this.length)throw Error(e+"set方法的第一个参数不能大于原数组长度");if(this[e]!==t){var n=this[e];this.splice(e,1,t),V.call(this.$up,this.$pathname+".*",[t,n,null,e])}},contains:function(e){return this.indexOf(e)>-1},ensure:function(e){return this.contains(e)||this.push(e),this},pushArray:function(e){return this.push.apply(this,K(e))},remove:function(e){return this.removeAt(this.indexOf(e))},removeAt:function(e){return e>>>=0,this.splice(e,1)},size:function(){return this._.length},removeAll:function(e){if(Array.isArray(e))for(var t=this.length-1;t>=0;t--)-1!==e.indexOf(this[t])&&(te.call(this.$track,t,1),te.call(this,t,1));else if("function"==typeof e)for(t=this.length-1;t>=0;t--){e(this[t],t)&&(te.call(this.$track,t,1),te.call(this,t,1))}else te.call(this.$track,0,this.length),te.call(this,0,this.length);this.notify(),this._.length=this.length},clear:function(){this.removeAll()}},te=Q.splice;function ne(e){for(var t=[],n=0;n2){n[1],n.length;n=[n[0],n[1]].concat(ne(n.length-2))}}Array.prototype[t].apply(e,n)}(this.$track,e,n),this.notify(),this._.length=this.length,a}}),"sort,reverse".replace(f,function(e){ee[e]=function(){var t=this.concat(),n=Math.random(),r=[],i=!1;Q[e].apply(this,arguments);for(var a=0,o=t.length;a444&&le())}(n,t)}}),t.getter=He(t.expr,t.vmodels,t),t.observers.forEach(function(e){e.v.$watch(e.p,t)}),delete t.observers);try{var r,i,o=t.fireArgs;if(delete t.fireArgs,o)r=o[0],i=o[1];else if("on"===t.type)r=t.getter+"";else try{r=t.getter.apply(0,t.args)}catch(e){r=null}if(i=void 0===i?t.oldValue:i,t._filters&&(r=cn.$filter.apply(0,[r].concat(t._filters))),t.signature){var s=N.type(r);if("array"!==s&&"object"!==s)throw Error("warning:"+t.expr+"只能是对象或数组");t.xtype=s;var c=function(e,t){for(var n,r=[],i=0;n=e[i++];)r.push(t?n.$id:n.$key);return r.join(";")}(t.proxies||[],s),l=r.$track||("array"===s?ne(r.length):Object.keys(r));t.track=l,c!==l.join(";")&&(t.handler(r,i),t.oldValue=1)}else Array.isArray(r)&&r.length!==(i&&i.length)?(t.handler(r,i),t.oldValue=r.concat()):"oldValue"in t&&r===i||(t.handler(r,i),t.oldValue=Array.isArray(r)?r.concat():r)}catch(e){delete t.getter,a("warning:exception throwed in [Anot.injectBinding] ",e);var u=t.element;u&&3===u.nodeType&&(u.nodeValue=L+(t.oneTime?"::":"")+t.expr+M)}finally{n&&ae.end()}},t.update()};var oe=N.$$subscribers=[],se=new Date;var ce=0;function le(e){for(var t=ce||oe.length,n=0;e=oe[--t];)if(e.i<7){if(null===e.element){oe.splice(t,1),e.list&&(N.Array.remove(e.list,e),delete oe[e.uuid]);continue}if(fe(e.element)){if(oe.splice(t,1),N.Array.remove(e.list,e),ue(e),n++>500){ce=t;break}continue}e.i++,7===e.i&&(e.i=14)}else e.i--;se=new Date}function ue(e){for(var t in delete oe[e.uuid],e.element=null,e.rollback&&e.rollback(),e)e[t]=null}function fe(e){try{e.parentNode.nodeType}catch(e){return!0}return e.ifRemove&&!b.contains(e.ifRemove)&&i===e.parentNode?(e.parentNode&&e.parentNode.removeChild(e),!0):e.msRetain?0:1===e.nodeType?!b.contains(e):!N.contains(b,e)}var pe=new function(){N.mix(this,{option:n.createElement("select"),thead:n.createElement("table"),td:n.createElement("tr"),area:n.createElement("map"),tr:n.createElement("tbody"),col:n.createElement("colgroup"),legend:n.createElement("fieldset"),_default:n.createElement("div"),g:n.createElementNS("http://www.w3.org/2000/svg","svg")}),this.optgroup=this.option,this.tbody=this.tfoot=this.colgroup=this.caption=this.thead,this.th=this.td};String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(f,function(e){pe[e]=pe.g});var de=/<([\w:]+)/,he=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,ve=C(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),me=n.createElement("script"),ye=/<|&#?\w+;/;function ge(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function be(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}N.parseHTML=function(e){var t=$.cloneNode(!1);if("string"!=typeof e)return t;if(!ye.test(e))return t.appendChild(n.createTextNode(e)),t;e=e.replace(he,"<$1>").trim();var r,i=(de.exec(e)||["",""])[1].toLowerCase(),a=pe[i]||pe._default;a.innerHTML=e;var o=a.getElementsByTagName("script");if(o.length)for(var s,c=0;s=o[c++];)if(ve[s.type]){var l=me.cloneNode(!1);y.forEach.call(s.attributes,function(e){l.setAttribute(e.name,e.value)}),l.text=s.text,s.parentNode.replaceChild(l,s)}for(;r=a.firstChild;)t.appendChild(r);return t},N.innerHTML=function(e,t){var n=this.parseHTML(t);this.clearHTML(e).appendChild(n)},N.clearHTML=function(e){for(e.textContent="";e.firstChild;)e.removeChild(e.firstChild);return e},"add,remove".replace(f,function(e){N.fn[e+"Class"]=function(t){var n=this[0];return t&&"string"==typeof t&&n&&1===n.nodeType&&t.replace(/\S+/g,function(t){n.classList[e](t)}),this}}),N.fn.mix({attr:function(e,t){return 2===arguments.length?(this[0].setAttribute(e,t),this):this[0].getAttribute(e)},data:function(e,t){var n=arguments.length,r=this[0].dataset;switch((e=ge(e||""))||(n=0),n){case 2:return r[e]=t,this;case 1:return xe(r[e]);case 0:var i=o();for(var a in r)i[a]=xe(r[a]);return i}},removeData:function(e){return e="data-"+ge(e),this[0].removeAttribute(e),this},css:function(e,t){if(N.isPlainObject(e))for(var n in e)N.css(this,n,e[n]);else var r=N.css(this,e,t);return void 0!==r?r:this},position:function(){var e,t,n=this[0],r={top:0,left:0};if(n)return"fixed"===this.css("position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),"HTML"!==e[0].tagName&&(r=e.offset()),r.top+=N.css(e[0],"borderTopWidth",!0),r.left+=N.css(e[0],"borderLeftWidth",!0),r.top-=e.scrollTop(),r.left-=e.scrollLeft()),{top:t.top-r.top-N.css(n,"marginTop",!0),left:t.left-r.left-N.css(n,"marginLeft",!0)}},offsetParent:function(){for(var e=this[0].offsetParent;e&&"static"===N.css(e,"position");)e=e.offsetParent;return N(e||b)},bind:function(e,t,n){if(this[0])return N.bind(this[0],e,t,n)},unbind:function(e,t,n){return this[0]&&N.unbind(this[0],e,t,n),this},val:function(e){var t,n,r=this[0];if(r&&1===r.nodeType){var i=0===arguments.length,a=i?":get":":set",o=je[(t=r,n=t.tagName.toLowerCase(),("input"===n&&/checkbox|radio/.test(t.type)?"checked":n)+a)];if(o)var s=o(r,e);else{if(i)return(r.value||"").replace(/\r/g,"");r.value=e}}return i?s:this}}),N.parseJSON=JSON.parse;var $e=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/;function xe(e){try{if("object"==typeof e)return e;e="true"===e||"false"!==e&&("null"===e?null:+e+""===e?+e:$e.test(e)?JSON.parse(e):e)}catch(e){}return e}N.fireDom=function(e,t,r){var i=n.createEvent("Events");i.initEvent(t,!0,!0),N.mix(i,r),e.dispatchEvent(i)},N.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){N.fn[e]=function(n){var r=this[0]||{},i=function(e){return e.window&&e.document?e:9===e.nodeType&&e.defaultView}(r),a="scrollTop"===e;if(!arguments.length)return i?i[t]:r[e];i?i.scrollTo(a?i[t]:n,a?n:i[t]):r[e]=n}});var we=N.cssHooks=o(),ke=["","-webkit-","-moz-","-ms-"],Ce={float:"cssFloat"};N.cssNumber=C("animationIterationCount,animationIterationCount,columnCount,order,flex,flexGrow,flexShrink,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),N.cssName=function(e,t,n){if(Ce[e])return Ce[e];t=t||b.style;for(var r=0,i=ke.length;r-1)&&(n=!0);n||(e.selectedIndex=-1)}},Te={};["break,case,catch,continue,debugger,default,delete,do,else,false","finally,for,function,if,in,instanceof,new,null,return,switch,this","throw,true,try,typeof,var,void,while,with","abstract,boolean,byte,char,class,const,double,enum,export,extends","final,float,goto,implements,import,int,interface,long,native","package,private,protected,public,short,static,super,synchronized","throws,transient,volatile","arguments,let,yield,async,await,undefined"].join(",").replace(/\w+/g,function(e){Te[e]=!0});var Oe=/[a-z_$]/i,Ee=/[\s\uFEFF\xA0]/;function Se(e,t){if(t&&!Te[t])return e.push(t),!0}function De(e,t,n,r){for(var i,a=[],o=" = "+n+".",s=e.length;i=e[--s];){var c=i.split(".")[0];t.hasOwnProperty(c)&&(a.push(c+o+c),r.observers.push({v:t,p:i,type:N.type(t[c])}),e.splice(s,1))}return a}var _e=/(proxy\-[a-z]+)\-[\-0-9a-f]+$/,Pe=new D(218),Le=new D(128);function Me(e){e=e.trim();var t=Pe.get(e);if(t)return t.concat();for(var n,r=function e(t,n){var r=[],i=!!n;n=n||0;for(var a="unknown",o="",s=0;s0){var t=e.replace(st,function(e){return Array(e.length+1).join("1")}).replace(ot,"ᄢ㍄").indexOf("|");if(t>-1)return{type:"text",filters:e.slice(t).trim(),expr:e.slice(0,t)}}return{type:"text",expr:e,filters:""}}function ut(e){for(var t,n,r=[],i=0;;){if(-1===(n=e.indexOf(L,i)))break;if((t=e.slice(i,n))&&r.push({expr:t}),i=n+L.length,-1===(n=e.indexOf(M,i)))break;(t=e.slice(i,n))&&r.push(lt(t.replace(ct,""))),i=n+M.length}return(t=e.slice(i))&&r.push({expr:t}),r}function ft(e,t,r){var i=[],a=ut(e.data);if(a.length){for(var o,s=0;o=a[s++];){var c=n.createTextNode(o.expr);o.type&&(o.expr=o.expr.replace(Ge,function(){return o.oneTime=!0,""}),o.element=c,o.filters=o.filters.replace(at,function(){return o.type="html",""}),o.pos=1e3*r+s,i.push(o)),$.appendChild(c)}e.parentNode.replaceChild($,e),i.length&&Ye(i,t)}}var pt=function(){this.queue=[]};pt.prototype={render:function(e){if(!this.locked){this.locked=e?b.offsetHeight+10:1;var t=this;N.nextTick(function(){t.flush()})}},flush:function(){for(var e,t=0;e=this.queue[t++];)e.update&&e.update();this.locked=0,this.queue=[]}};var dt=new pt,ht={};["autofocus,autoplay,async,allowTransparency,checked,controls","declare,disabled,defer,defaultChecked,defaultSelected","contentEditable,isMap,loop,multiple,noHref,noResize,noShade","open,readOnly,selected"].join(",").replace(f,function(e){ht[e.toLowerCase()]=e});N.directive("attr",{init:function(e){if(e.expr=Fe(e.expr.trim()),"include"===e.type){var t=e.element;St(t,e),e.includeRendered=Ue(t,"data-rendered",e.vmodels),e.includeLoaded=Ue(t,"data-loaded",e.vmodels);var r=e.includeReplace=t.hasAttribute("replace");t.hasAttribute("cache")&&(e.templateCache={}),e.start=n.createComment(":include"),e.end=n.createComment(":include-end"),r?(e.element=e.end,e._element=t,t.parentNode.insertBefore(e.start,t),t.parentNode.insertBefore(e.end,t.nextSibling)):(t.insertBefore(e.start,t.firstChild),t.appendChild(e.end))}},update:function(e){var t=this.element,n=Object.create(null),r=d.test(t);if(e=K(e),this.param)e&&"object"==typeof e?Array.isArray(e)?n[this.param]=e:Date.isDate(e)?n[this.param]=e.toISOString():n[this.param]=e:n[this.param]=e;else{if(!e||"object"!=typeof e||Array.isArray(e)||Date.isDate(e))return;n=e}for(var i in n)if("style"!==i){if("xlink:"===i.slice(0,6)){var a=i;n[i=i.slice(6)]=n[a],delete n[a]}if(!1!==n[i]&&null!==n[i]&&void 0!==n[i]||(n[i]=""),"boolean"==typeof t[i]||"boolean"==typeof t[ht[i]]){a=i;if(ht[i]&&a!==ht[i]&&(a=ht[i]),n[i]=!!n[i],t[a]=n[i],!n[i]){t.removeAttribute(a);continue}}!r&&i in t.cloneNode(!1)?t[i]=n[i]:("object"==typeof n[i]&&(n[i]=Date.isDate(n[i])?n[i].toISOString():JSON.stringify(n[i])),t.setAttribute(i,n[i]))}else t.style.cssText=n[i]}});N.directive("class",{init:function(e){if(e.expr=e.expr.replace(/\n/g," ").replace(/\s+/g," "),"hover"===e.type||"active"===e.type){var t=new Function("return "+e.expr)();if(!e.hasBindEvent){var n=e.element,r=N(n),i="mouseenter",a="mouseleave";if("active"===e.type){n.tabIndex=n.tabIndex||-1,i="mousedown",a="mouseup";var o=r.bind("mouseleave",function(){r.removeClass(t)})}}var s=r.bind(i,function(){r.addClass(t)}),c=r.bind(a,function(){r.removeClass(t)});e.rollback=function(){r.unbind("mouseleave",o),r.unbind(i,s),r.unbind(a,c)},e.hasBindEvent=!0}},update:function(e){if("class"===this.type){var t=e;if(!t||this.param)return a('class指令语法错误 %c %s="%s"',"color:#f00",this.name,this.expr);for(var n in"string"==typeof t&&((t={})[e]=!0),N.isPlainObject(t)||(t=t.$model),t)this.element.classList.toggle(n,!!t[n])}}}),"hover,active".replace(f,function(e){S[e]=S.class}),N.directive("css",{init:S.attr.init,update:function(e){var t=N(this.element);if(this.param)t.css(this.param,e);else{if("object"!=typeof e)return a(':css指令格式错误 %c %s="%s"',"color:#f00",this.name,this.expr);var n=e;N.isPlainObject(n)||(n=e.$model),t.css(n)}}}),N.directive("data",{priority:100,init:S.attr.init,update:function(e){var t=N(this.element);if(this.param)t.data(this.param,e);else{if("object"!=typeof e)return a(':data指令格式错误 %c %s="%s"',"color:#f00",this.name,this.expr);var n=e;for(var r in N.isPlainObject(n)||(n=e.$model),n)t.data(r,n[r])}}});var vt=/^(?:checkbox|radio)$/,mt=/^(?:radio|checked)$/,yt=/^(file|button|reset|submit|checkbox|radio|range)$/;N.directive("duplex",{priority:2e3,init:function(e,t){var n=e.element,r=e.vmodels;e.changed=Ue(n,"data-changed",r)||w;var i=[],o=C("string,number,boolean,checked");"radio"===n.type&&""===e.param&&(e.param="checked"),e.param.replace(p,function(r){vt.test(n.type)&&mt.test(r)&&(r="checked",e.isChecked=!0,e.xtype="radio"),o[r]&&(t=!0),N.Array.ensure(i,r)}),t||i.push("string"),e.param=i.join("-"),e.xtype||(e.xtype="SELECT"===n.tagName?"select":"checkbox"===n.type?"checkbox":"radio"===n.type?"radio":/^change/.test(n.getAttribute("data-event"))?"change":"input"),n.expr=e.expr;var s=e.bound=function(t,r){n.addEventListener(t,r,!1);var i=e.rollback;e.rollback=function(){n.anotSetter=null,N.unbind(n,t,r),i&&i()}};function c(t){e.changed.call(this,t)}var l=!1;var u=function(t){var r=n.value;if(!l&&r!==e.oldValue&&null!==e.pipe){var i=e.pipe(r,e,"get");e.oldValue=r,e.setter(i),c.call(n,i),N.fireDom(n,"change")}};switch(e.xtype){case"radio":s("click",function(){var t=e.pipe(n.value,e,"get");e.setter(t),c.call(n,t)});break;case"checkbox":s("change",function(){var t=n.checked?"ensure":"remove",r=e.getter.apply(0,e.vmodels);Array.isArray(r)||(a(":duplex应用于checkbox上要对应一个数组"),r=[r]);var i=e.pipe(n.value,e,"get");N.Array[t](r,i),c.call(n,r)});break;case"change":s("change",u);break;case"input":s("input",u),s("keyup",u),s("compositionstart",function(){l=!0}),s("compositionend",function(){l=!1,setTimeout(u)}),s("DOMAutoComplete",u);break;case"select":s("change",function(){var t=N(n).val();if((t=Array.isArray(t)?t.map(function(t){return e.pipe(t,e,"get")}):e.pipe(t,e,"get"))+""!==e.oldValue)try{e.setter(t)}catch(e){a(e)}}),s("datasetchanged",function(t){if("selectDuplex"===t.bubble){var r=e._value,i=Array.isArray(r)?r.map(String):r+"";N(n).val(i),n.oldValue=i+"",c.call(n,i)}})}"input"!==e.xtype||yt.test(n.type)||("hidden"!==n.type&&(s("focus",function(){n.msFocus=!0}),s("blur",function(){n.msFocus=!1})),n.anotSetter=u,kt(function(){if(b.contains(n))n.msFocus||u();else if(!n.msRetain)return!1}))},update:function(e){var t,n=this.element;this.init||((this.pipe||(this.pipe=bt))(null,this,"init"),this.init=1);switch(this.xtype){case"input":n.value=e;break;case"change":if((t=this.pipe(e,this,"set"))!==this.oldValue){var r=!1;if(n.msFocus)try{var i=n.selectionStart;if(i===n.selectionEnd){var a=i;r=!0}}catch(e){}n.value=this.oldValue=t,r&&!n.readOnly&&(n.selectionStart=n.selectionEnd=a)}break;case"radio":t=this.isChecked?!!e:e+""===n.value,n.checked=t;break;case"checkbox":var o=[].concat(e);t=this.pipe(n.value,this,"get"),n.checked=o.indexOf(t)>-1;break;case"select":this._value=e,n.msHasEvent?N.fireDom(n,"datasetchanged",{bubble:n.msHasEvent}):n.msHasEvent="selectDuplex"}}});function gt(e){return null==e?"":e}function bt(e,t,n,r){return t.param.replace(p,function(r){var i=N.duplexHooks[r];i&&"function"==typeof i[n]&&(e=i[n](e,t))}),e}N.duplexHooks={checked:{get:function(e,t){return!t.oldValue}},string:{get:function(e){return e},set:gt},boolean:{get:function(e){return"true"===e},set:gt},number:{get:function(e,t){var n=+e;return+e===n?n:0},set:gt}};var $t,xt=[];function wt(){for(var e=xt.length-1;e>=0;e--){!1===(0,xt[e])()&&xt.splice(e,1)}xt.length||clearInterval($t)}N.tick=function(e){1===xt.push(e)&&($t=setInterval(wt,60))};var kt=w;new function(){try{var e={},t=HTMLInputElement.prototype,n=HTMLTextAreaElement.prototype;function r(t){e[this.tagName].call(this,t),!this.msFocus&&this.anotSetter&&this.anotSetter()}var i=HTMLInputElement.prototype;Object.getOwnPropertyNames(i),e.INPUT=Object.getOwnPropertyDescriptor(t,"value").set,Object.defineProperty(t,"value",{set:r}),e.TEXTAREA=Object.getOwnPropertyDescriptor(n,"value").set,Object.defineProperty(n,"value",{set:r})}catch(e){kt=N.tick}},N.directive("effect",{priority:5,init:function(e){var t,n,r=e.expr,i=r.replace(F,function(e){return e.replace(/./g,"0")}).indexOf(":");-1===i?(t=r,n=!0):(t=r.slice(0,i),n=r.slice(i+1)),t=H.test(r)?Fe(t):We(t),e.expr="["+t+","+n+"]"},update:function(e){var t=e[0],n=this.element;if(n.getAttribute("data-effect-name")!==t){n.removeAttribute("data-effect-driver");var r=n.style,i=window.getComputedStyle?window.getComputedStyle(n):null,a=!1;if(i&&(Nt||jt)){var o=r[Tt]||i[Tt];o&&"0s"!==o&&(n.setAttribute("data-effect-driver","t"),a=!0),a||(o=r[Ot]||i[Ot])&&"0s"!==o&&(n.setAttribute("data-effect-driver","a"),a=!0)}a||N.effects[t]&&(n.setAttribute("data-effect-driver","j"),a=!0),a&&n.setAttribute("data-effect-name",t)}}}),N.effects={},N.effect=function(e,t){N.effects[e]=t};var Ct,At,Nt=!1,jt=!1,Tt=N.cssName("transition-duration"),Ot=N.cssName("animation-duration");new function(){var e,t,n={TransitionEvent:"transitionend",WebKitTransitionEvent:"webkitTransitionEnd",OTransitionEvent:"oTransitionEnd",otransitionEvent:"otransitionEnd"};for(var r in n){if(window[r]){e=n[r];break}try{document.createEvent(r);e=n[r];break}catch(e){}}for(r in"string"==typeof e&&(Nt=!0,Ct=e),n={AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"})if(window[r]){t=n[r];break}"string"==typeof t&&(Nt=!0,At=t)};var Et=[];function St(e,t){var n=e.getAttribute("data-effect-name");if(n){t.effectName=n,t.effectDriver=e.getAttribute("data-effect-driver");var r=+e.getAttribute("data-effect-stagger");t.effectLeaveStagger=+e.getAttribute("data-effect-leave-stagger")||r,t.effectEnterStagger=+e.getAttribute("data-effect-enter-stagger")||r,t.effectClass=e.className||NaN}}function Dt(e){return e.replace(/^[\S]/g,function(e){return e.toUpperCase()})}var _t=new pt;function Pt(){}function Lt(e,t){var n=e.callbacks[t+"Class"];return"string"==typeof n?n:"function"==typeof n?n():e.name+"-"+t}function Mt(e,t,n){var r=e.callbacks[t];r&&r.call(e,e.el,n)}Pt.prototype={contrustor:Pt,enterClass:function(){return Lt(this,"enter")},leaveClass:function(){return Lt(this,"leave")},actionFun:function(e,t,n){if(!document.hidden){var r=this,i=r.el,a="leave"===e;e=a?"leave":"enter",Mt(r,"abort"+Dt(a?"enter":"leave")),Mt(r,"before"+Dt(e)),a||t(i);var o=function(o){i.removeEventListener(r.cssEvent,r.cssCallback),a?(t(i),N(i).removeClass(r.cssClass)):"a"===r.driver&&N(i).removeClass(r.cssClass),!0!==o&&(Mt(r,"after"+Dt(e)),n&&n(i)),r.dispose()};r.useCss?(r.cssCallback&&r.cssCallback(!0),r.cssClass=Lt(r,e),r.cssCallback=o,r.update=function(){i.addEventListener(r.cssEvent,r.cssCallback),a||"t"!==r.driver||N(i).removeClass(r.cssClass)},N(i).addClass(r.cssClass),_t.render(!0),_t.queue.push(r)):Mt(r,e,o)}},enter:function(e,t){this.actionFun.apply(this,["enter"].concat(N.slice(arguments)))},leave:function(e,t){this.actionFun.apply(this,["leave"].concat(N.slice(arguments)))},dispose:function(){this.update=this.cssCallback=null,Et.unshift(this)>100&&Et.pop()}};var Ht=function(e,t){var n=g.call(arguments,0);"function"!=typeof n[2]&&n.splice(2,0,w),"function"!=typeof n[3]&&n.splice(3,0,w);var r=n[2],i=n[3],a=function(e,t){if(!e||1!==e.nodeType)return null;if(t)var n=t.effectName,r=t.effectDriver;else n=e.getAttribute("data-effect-name"),r=e.getAttribute("data-effect-driver");if(!n||!r)return null;var i=Et.pop()||new Pt;return i.el=e,i.driver=r,i.useCss="j"!==r,i.useCss&&(t&&N(e).addClass(t.effectClass),i.cssEvent="t"===r?Ct:At),i.name=n,i.callbacks=N.effects[n]||{},i}(e,n[4]);if(!a)return r(),i(),!1;a[t?"enter":"leave"](r,i)};N.mix(N.effect,{apply:Ht,append:function(e,t,n,r){return Ht(e,1,function(){t.appendChild(e)},n,r)},before:function(e,t,n,r){return Ht(e,1,function(){t.parentNode.insertBefore(e,t)},n,r)},remove:function(e,t,n,r){return Ht(e,0,function(){e.parentNode===t&&t.removeChild(e)},n,r)}}),N.directive("html",{update:function(e){var t=this.element,r=1!==t.nodeType,i=r?t.parentNode:t;if(i){if(e=null==e?"":e,3===t.nodeType){var a=A("html");i.insertBefore(n.createComment(a),t),this.element=n.createComment(a+":end"),i.replaceChild(this.element,t),t=this.element}if("object"!=typeof e)var o=N.parseHTML(String(e));else if(11===e.nodeType)o=e;else if(1===e.nodeType||e.item){var s=1===e.nodeType?e.childNodes:e.item;for(o=$.cloneNode(!0);s[0];)o.appendChild(s[0])}if(s=N.slice(o.childNodes),r){for(var c=t.nodeValue.slice(0,-4);;){var l=t.previousSibling;if(!l||8===l.nodeType&&l.nodeValue===c)break;i.removeChild(l)}i.insertBefore(o,t)}else N.clearHTML(t).appendChild(o);rt(s,this.vmodels)}}}),N.directive("text",{update:function(e){var t=this.element;if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(e){}else t.textContent=e}}),N.directive("if",{priority:10,update:function(e){var t,r=this,a=this.element,o=r.stamp=Date.now(),s=function(){o===r.stamp&&(r.recoverNode=null)};r.recoverNode&&r.recoverNode();try{if(!a.parentNode)return;t=a.parentNode}catch(e){return}if(e){function c(){a.getAttribute(r.name)&&(a.removeAttribute(r.name),et(a,r.vmodels)),r.rollback=null}if(8===a.nodeType){var l=r.keep,u=N.effect.apply(l,1,function(){o===r.stamp&&(a.parentNode.replaceChild(l,a),a=r.element=l,l.getAttribute("_required")&&(a.required=!0,a.removeAttribute("_required")),a.querySelectorAll&&N.each(a.querySelectorAll("[_required=true]"),function(e){e.required=!0,e.removeAttribute("_required")}),c())},s);u=!1===u}u||c()}else if(1===a.nodeType){!0===a.required&&(a.required=!1,a.setAttribute("_required","true"));try{N.each(a.querySelectorAll(":required"),function(e){a.required=!1,e.setAttribute("_required","true")})}catch(e){}var f=r.element=n.createComment(":if"),p=a.nextSibling;r.recoverNode=function(){r.recoverNode=null,f.parentNode!==t&&(t.insertBefore(f,p),r.keep=a)},N.effect.apply(a,0,function(){r.recoverNode=null,o===r.stamp&&(a.parentNode.replaceChild(f,a),r.keep=a,i.appendChild(a),r.rollback=function(){a.parentNode===i&&i.removeChild(a)})},s)}}});var Ft=N.templateCache={};function Bt(e){for(var t=n.createDocumentFragment(),r=0,i=e.length;r=200&&this.status<400?m.resolve(this.response):m.reject(this))},v.send(null),m.promise).then(t=>{Ft[e]=t,y(t)}).catch(t=>{a(":include load ["+e+"] error\n%c%s","color:#f30",`获取网络资源出错, ${t.status} (${t.statusText})`)})}}});var It=/\(([^)]*)\)/,Rt=N.directive("on",{priority:3e3,init:function(e){var t=e.expr;e.type="on";var n=e.param.replace(/-\d+$/,"");if("function"==typeof Rt[n+"Hook"]&&Rt[n+"Hook"](e),t.indexOf("(")>0&&t.indexOf(")")>-1){var r=(t.match(It)||["",""])[1].trim();""!==r&&"$event"!==r||(t=t.replace(It,""))}e.expr=t},update:function(e){var t=this,n=this.element;e=function(e){return(t.getter||w).apply(t.args[0],t.args.concat(e))};var r=t.param.replace(/-\d+$/,"");if("scan"===r)e.call(n,{type:r});else if("function"==typeof t.specialBind)t.specialBind(n,e);else var i=N.bind(n,r,e);t.rollback=function(){"function"==typeof t.specialUnbind?t.specialUnbind():N.unbind(n,r,i)}}});function qt(e,t,n){for(var r,i=0;r=e[i++];)r.className===n.effectClass&&N.effect.apply(r,t,w,w,n)}function Vt(e,t,n){return e?setTimeout(t,++n*e):t(),n}function Wt(e,t,n){for(var r=$.cloneNode(!1),i=e,a=i.nodeValue,o=t&&Math.max(+t.staggerIndex,0),s=N.slice(i.parentNode.childNodes),c=s.indexOf(i);;){var l=s[--c];if(!l||0===String(l.nodeValue).indexOf(a))break;!n&&t&&l.className===t.effectClass?(e=l,function(e){t.staggerIndex=Vt(t.effectLeaveStagger,function(){N.effect.apply(e,0,w,function(){r.appendChild(e)},t)},o)}(l)):r.insertBefore(l,r.firstChild)}return r.appendChild(i),r}function zt(e,t,n,r,i){var a=e.template.cloneNode(!0),o=N.slice(a.childNodes);a.appendChild(n.$anchor),i&&t.appendChild(a);n[e.param||"el"];var s={nodes:o,vmodels:[n].concat(e.vmodels),content:a};r.push(s)}function Ut(e){var t=("object"===e.xtype?Kt:Jt)(e);return(t.$anchor||(t.$anchor=e.element.cloneNode(!1))).nodeValue=e.signature,t.$outer=e.$outer,t}function Yt(e,t,n){if("array"===n){e.$remove=function(){t.$repeat.removeAt(e.$index)};var r=t.param;e.$watch(r,function(n){var r=e.$index;t.$repeat[r]=n})}else{var i=t.vars[0],a=t.vars[1];e.$up.$watch(t.expr+"."+e[i],function(n){e[t.param][a]=n,e[a]=n})}}N.directive("for",{priority:90,init:function(e){var t=e.type;e.cache={},e.enterCount=0;var r=e.element;if(1===r.nodeType){var i=e.expr.split(" in ");e.expr=i.pop(),i.length&&(i=i.pop().split(/\s+/)),e.vars=i,r.removeAttribute(e.name),St(r,e);var a=Ue(r,"data-rendered",e.vmodels),o=A(t),s=n.createComment(o+":start"),c=e.element=n.createComment(o+":end");e.signature=o,e.start=s,e.template=$.cloneNode(!1);var l=r.parentNode;if(l.replaceChild(c,r),l.insertBefore(s,c),e.template.appendChild(r),e.element=c,a)var u=N.bind(l,"datasetchanged",function(){a.apply(l,l.args),N.unbind(l,"datasetchanged",u),l.msRendered=a})}},update:function(e,t){var n=this,r=this.xtype;"array"===r?(this.vars.length?1===this.vars.length&&this.vars.unshift("$index"):this.vars.push("$index","el"),this.param=this.vars[1]):(this.param="__el__",this.vars.length?1===this.vars.length&&this.vars.push("$val"):this.vars.push("$key","$val")),this.enterCount+=1;var i=!t;if(i){n.$outer={};var a=this.vars[0],o=this.vars[1];"array"===r&&(a="$first",o="$last");for(var s,c=0;s=n.vmodels[c++];)if(s.hasOwnProperty(a)&&s.hasOwnProperty(o)){n.$outer=s;break}}var l=this.track,u="move";n.$repeat=e;var f=[],p=i&&$.cloneNode(!1),d=[],h=this.param,v=N.mix({},this.cache),m=this.element,y=l.length,g=m.parentNode,b=0;for(c=0;c10,A=m.previousSibling,j=n.start;if(C)for(;A!==j;)g.removeChild(A),A=m.previousSibling;for(c=0;cP.maxRepeatSize&&i.pop(),delete e[t]}}function Qt(e,t){var r="_"+e;if(!Qt[r]){var i=n.createElement(e);b.appendChild(i),t=getComputedStyle(i,null).display,b.removeChild(i),Qt[r]=t}return Qt[r]}N.parseDisplay=Qt,N.directive("visible",{init:function(e){St(e.element,e)},update:function(e){var t,n=this,r=this.element,i=!this.effectName;if(!this.stamp)return t=this.stamp=Date.now(),void(e?(r.style.display=n.display||"","none"===N(r).css("display")&&(r.style.display=n.display=Qt(r.nodeName))):r.style.display="none");t=this.stamp=+new Date,e?N.effect.apply(r,1,function(){if(t===n.stamp){var e=r.getAttribute("data-effect-driver")||"a";i&&(r.style.display=n.display||""),"a"!==e&&"t"!==e||"none"===N(r).css("display")&&(r.style.display=n.display||Qt(r.nodeName))}}):N.effect.apply(r,0,function(){t===n.stamp&&(r.style.display="none")})}});var en=/]*>([\S\s]*?)<\/script\s*>/gim,tn=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,nn=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,rn={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},an=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,on=/([^\#-~| |!])/g;function sn(e,t,n,r){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var i=isFinite(+e)?+e:0,a=isFinite(+t)?Math.abs(t):3,o=r||",",s=n||".",c="";return(c=(a?function(e,t){var n=Math.pow(10,t);return""+(Math.round(e*n)/n).toFixed(t)}(i,a):""+Math.round(i)).split("."))[0].length>3&&(c[0]=c[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,o)),(c[1]||"").length>=0)%60,n=Math.floor(e/60),r=Math.floor(n/60);return n=(n%=60)<10?"0"+n:n,t=t<10?"0"+t:t,r>0?(r=r<10?"0"+r:r)+":"+n+":"+t:n+":"+t},$filter:function(e){for(var t=1,n=arguments.length;t/g,">")},currency:function(e,t,n){return(t||"¥")+sn(e,isFinite(n)?n:2)},number:sn,date:function(e,t){var n=e;if(!Date.isDate(n)){var r=+n;if(r==r&&(n=r),"Invalid Date"===(n=new Date(n)).toString())return"Invalid Date"}return n.format(t)}};let ln,un=[],fn=function(e){for(ln=!0;e=un.shift();)e(N)};return"complete"===n.readyState?setTimeout(fn):n.addEventListener("DOMContentLoaded",fn),window.addEventListener("load",fn),N.ready=function(e){ln?e(N):un.push(e)},window.Anot=N,N}();export default _Anot; \ No newline at end of file + const _Anot=function(){var e=1024,t=A(),n=window.document,r=n.head;r.insertAdjacentHTML("afterbegin",'');var i=r.firstChild;function a(){console.log.apply(console,arguments)}function o(){return Object.create(null)}var s=encodeURIComponent,c=decodeURIComponent,l="$"+t,u={},f=/[^, ]+/g,p=/\w+/g,d=/^\[object SVG\w*Element\]$/,h=Object.prototype,v=h.hasOwnProperty,m=h.toString,y=Array.prototype,g=y.slice,b=n.documentElement,x=n.createDocumentFragment(),$=(n.createElement("div"),{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object","[object Error]":"error","[object AsyncFunction]":"asyncfunction","[object Promise]":"promise","[object Generator]":"generator","[object GeneratorFunction]":"generatorfunction"});function w(){}function k(e){return Function.apply(w,e)}function C(e,t){"string"==typeof e&&(e=e.match(f)||[]);for(var n={},r=void 0!==t?t:1,i=0,a=e.length;i{e.resolve=t,e.reject=n}),e}),String.prototype.splice||Object.defineProperty(String.prototype,"splice",{value:function(e,t,n){let r=this.length,i=arguments.length;if(n=void 0===n?"":n,i<1)return this;if(e<0&&(e=Math.abs(e)>=r?0:r+e),1===i)return this.slice(0,e);return t-=0,this.slice(0,e)+n+this.slice(e+t)},enumerable:!1}),Date.prototype.getFullWeek||(Object.defineProperty(Date.prototype,"getFullWeek",{value:function(){let e=this.getFullYear(),t=new Date(e,0,1),n=t.getDay()||1,r=(this-t)/864e5;return Math.ceil((r+n)/7)},enumerable:!1}),Object.defineProperty(Date.prototype,"getWeek",{value:function(){let e=this.getDate(),t=this.getMonth(),n=this.getFullYear(),r=new Date(n,t,1).getDay();return Math.ceil((e+r)/7)},enumerable:!1})),Date.isDate||Object.defineProperty(Date,"isDate",{value:function(e){return!("object"!=typeof e||!e.getTime)},enumerable:!1}),Date.prototype.format||Object.defineProperty(Date.prototype,"format",{value:function(e){e=e||"Y-m-d H:i:s";let t,n={fullyear:this.getFullYear(),year:this.getYear(),fullweek:this.getFullWeek(),week:this.getWeek(),month:this.getMonth()+1,date:this.getDate(),day:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"][this.getDay()],hours:this.getHours(),minutes:this.getMinutes(),seconds:this.getSeconds()};n.g=n.hours>12?n.hours-12:n.hours,t={Y:n.fullyear,y:n.year,m:n.month<10?"0"+n.month:n.month,n:n.month,d:n.date<10?"0"+n.date:n.date,j:n.date,H:n.hours<10?"0"+n.hours:n.hours,h:n.g<10?"0"+n.g:n.g,G:n.hours,g:n.g,i:n.minutes<10?"0"+n.minutes:n.minutes,s:n.seconds<10?"0"+n.seconds:n.seconds,W:n.fullweek,w:n.week,D:n.day};for(let n in t)e=e.replace(new RegExp(n,"g"),t[n]);return e},enumerable:!1});let N=function(e){return new N.init(e)};N.nextTick=function(){let e=[];let t=document.createTextNode("\x3c!-- --\x3e");new MutationObserver((function(){let t=e.length;for(let n=0;n>>0)return!0}return!1}(e))for(let n=0,r=e.length;n1){if(!e)return;if(n=n||{},n=Object.assign({expires:"",path:"/",domain:document.domain,secure:""},n),"string"==this.type(t)&&""===t.trim()||null===t)return document.cookie=s(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain="+n.domain+"; path="+n.path,!0;if(n.expires)switch(n.expires.constructor){case Number:n.expires=n.expires===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+n.expires;break;case String:n.expires="; expires="+n.expires;break;case Date:n.expires="; expires="+n.expires.toUTCString()}return document.cookie=s(e)+"="+s(t)+n.expires+"; domain="+n.domain+"; path="+n.path+"; "+n.secure,!0}return e?c(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+s(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null:document.cookie},search:function(e){let t=location.search;if(!t)return null;t=c(t),t=t.slice(1),t=t.split("&");let n={};for(let e,r=0;e=t[r++];){let t=e.split("=");t[1]=t.length<2?null:t[1],t[1]=t[1],n.hasOwnProperty(t[0])?("object"==typeof n[t[0]]||(n[t[0]]=[n[t[0]]]),n[t[0]].push(t[1])):n[t[0]]=t[1]}return e?n.hasOwnProperty(e)?n[e]:null:n},copy:function(e){try{navigator.clipboard.writeText(e)}catch(e){a("复制到粘贴板失败",e)}}});let O=N.bindingHandlers={},E=N.bindingExecutors={},S=N.directives={};N.directive=function(e,t){return O[e]=t.init=t.init||w,E[e]=t.update=t.update||w,S[e]=t};let D=new function(){function e(e){this.size=0,this.limit=e,this.head=this.tail=void 0,this._keymap={}}let t=e.prototype;return t.put=function(e,t){let n={key:e,value:t};return this._keymap[e]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit?this.shift():this.size++,t},t.shift=function(){let e=this.head;e&&(this.head=this.head.newer,this.head.older=e.newer=e.older=this._keymap[e.key]=void 0,delete this._keymap[e.key])},t.get=function(e){let t=this._keymap[e];if(void 0!==t)return t===this.tail||(t.newer&&(t===this.head&&(this.head=t.newer),t.newer.older=t.older),t.older&&(t.older.newer=t.newer),t.newer=void 0,t.older=this.tail,this.tail&&(this.tail.newer=t),this.tail=t),t.value},e};n.contains||(Node.prototype.contains=function(e){return!!(16&this.compareDocumentPosition(e))}),N.contains=function(e,t){try{for(;t=t.parentNode;)if(t===e)return!0;return!1}catch(e){return!1}};let _=N.eventHooks;function P(e){for(var t in e)if(v.call(e,t)){var n=e[t];"function"==typeof P.plugins[t]?P.plugins[t](n):"object"==typeof P[t]?N.mix(P[t],n):P[t]=n}return this}void 0===n.onmousewheel&&(_.mousewheel={type:"wheel",fix:function(e,t){return function(n){n.wheelDeltaY=n.wheelDelta=n.deltaY>0?-120:120,n.wheelDeltaX=0,Object.defineProperty(n,"type",{value:"mousewheel"}),t.call(e,n)}}}),N.config=P;var L,M,H,F,B=/[-.*+?^${}()|[\]\/\\]/g;function I(e){return(e+"").replace(B,"\\$&")}var R={interpolate:function(e){if(L=e[0],M=e[1],L===M)throw new SyntaxError("openTag!==closeTag");P.openTag=L,P.closeTag=M;var t=I(L),n=I(M);H=new RegExp(t+"([\\s\\S]*)"+n),F=new RegExp(t+"([\\s\\S]*)"+n,"g"),new RegExp(t+"[\\s\\S]*"+n+"|\\s:")}};function q(t,r){var i=this.$events||(this.$events={}),a=i[t]||(i[t]=[]);if("function"==typeof r){var o=r;o.uuid="_"+ ++e,(r={element:b,type:"user-watcher",handler:w,vmodels:[this],expr:t,uuid:o.uuid}).wildcard=/\*/.test(t)}if(r.update)r.oneTime||N.Array.ensure(a,r);else{if(/\w\.*\B/.test(t)||"*"===t){r.getter=w;var s=this;r.update=function(){var e=this.fireArgs||[];e[2]&&r.handler.apply(s,e),delete this.fireArgs},a.sync=!0,N.Array.ensure(a,r)}else N.injectBinding(r);o&&(r.handler=o)}return function(){r.update=r.getter=r.handler=w,r.element=n.createElement("a")}}function V(t,n){var r=this.$events,i=null;if(r&&r[t]){n&&(n[2]=t);var a=r[t];if(function(t,n){if(!t)return;new Date-ue>444&&"object"==typeof t[0]&&pe();for(var r,i=[],a=[],o=0;r=t[o++];)"user-watcher"===r.type?i.push(r):a.push(r);if(P.async){for(gt.render(),o=0;r=a[o++];)if(r.update){r.uuid=r.uuid||"_"+ ++e;var s=r.uuid;gt.queue[s]||(gt.queue[s]="__",gt.queue.push(r))}}else for(o=0;r=a[o++];)r.update&&r.update();for(o=0;r=i[o++];)(n&&n[2]===r.expr||r.wildcard)&&(r.fireArgs=n),r.update()}(a,n),n&&r["*"]&&!/\./.test(t))for(var o,s=0;o=r["*"][s++];)try{o.handler.apply(this,n)}catch(e){}(i=this.$up)&&(this.$pathname&&V.call(i,this.$pathname+"."+t,n),V.call(i,"*."+t,n))}else{if(i=this.$up,this.$ups){for(var c in this.$ups)V.call(this.$ups[c],c+"."+t,n);return}if(i){var l=this.$pathname;""===l&&(l="*");var u=l+"."+t;a=u.split("."),n=n&&n.concat([u,t])||[u,t],-1===a.indexOf("*")?(V.call(i,u,n),a[1]="*",V.call(i,a.join("."),n)):V.call(i,u,n)}}}P.plugins=R,P.plugins.interpolate(["{{","}}"]),P.async=!0,P.paths={},P.shim={},P.maxRepeatSize=100;var W=C("$id,$watch,$fire,$events,$model,$active,$pathname,$up,$ups,$track,$accessors");function z(e,t){return(t=t||{}).watch=!0,Y(e,t)}function U(){}function Y(e,t){if(!e||e.$id&&e.$accessors||e.nodeName&&e.nodeType>0)return e;var n,r=(t=t||u).force||u,i=t.old,o=i&&i.$accessors||u,s=new U,c={},l={},f=[],p=[],d={},h=e.state,v=e.computed,m=e.methods,y=e.props,g=e.watch,b=e.mounted;if(delete e.state,delete e.computed,delete e.methods,delete e.props,delete e.watch,e.skip&&(d=C(e.skip),delete e.skip),h)for($ in e.$id&&delete h.props,h){var x=h[$];W[$]||(l[$]=!0),"function"==typeof x||x&&x.nodeName&&x.nodeType>0||!r[$]&&("$"===(n=$).charAt(0)||"__"===n.slice(0,2)||W[n]||d[$])?f.push($):G(x)?(a("warning:计算属性建议放在[computed]对象中统一定义"),v[$]=x):(p.push($),o[$]?c[$]=o[$]:c[$]=J($,x))}if(v)for(var $ in delete v.props,v)l[$]=!0,function(e,t){var n;"function"==typeof t&&(t={get:t,set:w}),"function"!=typeof t.set&&(t.set=w),c[e]={get:function(){return n=t.get.call(this)},set:function(r){var i,a=n;t.set.call(this,r),i=this[e],this.$fire&&i!==a&&this.$fire(e,i,a)},enumerable:!0,configurable:!0}}($,v[$]);if(m)for(var $ in delete m.props,m)l[$]=!0,f.push($);if(y)for(var $ in K(s,"props",{}),l.props=!!e.$id,y)s.props[$]=y[$];if(Object.assign(e,h,m),c.$model=Q,s=Object.defineProperties(s,c,e),f.forEach((function(t){s[t]=e[t]})),K(s,"$id","anonymous"),K(s,"$up",i?i.$up:null),K(s,"$track",Object.keys(l)),K(s,"$active",!1),K(s,"$pathname",i?i.$pathname:""),K(s,"$accessors",c),K(s,"$events",{}),K(s,"$refs",{}),K(s,"$children",[]),K(s,"hasOwnProperty",(function(e){return!0===l[e]})),K(s,"$mounted",b),t.watch&&(K(s,"$watch",(function(){return q.apply(s,arguments)})),K(s,"$fire",(function(e,t){if(0===e.indexOf("all!")){var n=e.slice(4);for(var r in N.vmodels){(i=N.vmodels[r]).$fire&&i.$fire.apply(i,[n,t])}}else if(0===e.indexOf("child!")){n="props."+e.slice(6);for(var r in s.$children){var i;(i=s.$children[r]).$fire&&i.$fire.apply(i,[n,t])}}else V.call(s,e,[t])}))),p.forEach((function(e){var t=i&&i[e],n=s[e]=h[e];n&&"object"==typeof n&&!Date.isDate(n)&&(n.$up=s,n.$pathname=e),V.call(s,e,[n,t])})),g)for(var k in delete g.props,g)if(Array.isArray(g[k]))for(var A;A=g[k].pop();)q.call(s,k,A);else q.call(s,k,g[k]);return s.$active=!0,"anonymous"!==s.$id&&i&&i.$up&&i.$up.$children&&i.$up.$children.push(s),s}function G(e){if(e&&"object"==typeof e){for(var t in e)if("get"!==t&&"set"!==t)return!1;return"function"==typeof e.get}}function J(e,t){var n;t=NaN;return{get:function(){return this.$active&&function(e,t){for(;;){if(e.$watch){var n=e.$events||(e.$events={}),r=n[t]||(n[t]=[]);return void ce.collectDependency(r)}if(!(e=e.$up))break;t=e.$pathname+"."+t}}(this,e),t},set:function(r){if(t!==r){var i=t;(n=X(r,t))?t=n:(n=void 0,t=r),Object(n)===n&&(n.$pathname=e,n.$up=this),this.$active&&V.call(this,e,[t,i])}},enumerable:!0,configurable:!0}}function X(e,t,n,r){if(Array.isArray(e))return function(e,t,n){if(t&&t.splice){var r=[0,t.length].concat(e);return t.splice.apply(t,r),t}for(var i in te)e[i]=te[i];K(e,"$up",null),K(e,"$pathname",""),K(e,"$track",ie(e.length)),e._=Y({state:{length:NaN}},{watch:!0}),e._.length=e.length,e._.$watch("length",(function(t,n){V.call(e.$up,e.$pathname+".length",[t,n])})),n&&K(e,"$watch",(function(){return q.apply(e,arguments)})),Object.defineProperty(e,"$model",Q);for(var a=0,o=e.length;a>>=0)>this.length)throw Error(e+"set方法的第一个参数不能大于原数组长度");if(this[e]!==t){var n=this[e];this.splice(e,1,t),V.call(this.$up,this.$pathname+".*",[t,n,null,e])}},contains:function(e){return this.indexOf(e)>-1},ensure:function(e){return this.contains(e)||this.push(e),this},pushArray:function(e){return this.push.apply(this,Z(e))},remove:function(e){return this.removeAt(this.indexOf(e))},removeAt:function(e){return e>>>=0,this.splice(e,1)},size:function(){return this._.length},removeAll:function(e){if(Array.isArray(e))for(var t=this.length-1;t>=0;t--)-1!==e.indexOf(this[t])&&(ne.call(this.$track,t,1),ne.call(this,t,1));else if("function"==typeof e)for(t=this.length-1;t>=0;t--){e(this[t],t)&&(ne.call(this.$track,t,1),ne.call(this,t,1))}else ne.call(this.$track,0,this.length),ne.call(this,0,this.length);this.notify(),this._.length=this.length},clear:function(){this.removeAll()}},ne=ee.splice;function re(e,t){for(var n={},r=0,i=t.length;r2){n[1],n.length;n=[n[0],n[1]].concat(ie(n.length-2))}}Array.prototype[t].apply(e,n)}["push","pop","shift","unshift","splice"].forEach((function(e){var t=ee[e];te[e]=function(){for(var n=[],r=0,i=arguments.length;r444&&pe())}(n,t)}}),t.getter=qe(t.expr,t.vmodels,t),t.observers.forEach((function(e){e.v.$watch(e.p,t)})),delete t.observers);try{var r,i,o=t.fireArgs;if(delete t.fireArgs,o)r=o[0],i=o[1];else if("on"===t.type)r=t.getter+"";else try{r=t.getter.apply(0,t.args)}catch(e){r=null}if(i=void 0===i?t.oldValue:i,t._filters&&(r=vn.$filter.apply(0,[r].concat(t._filters))),t.signature){var s=N.type(r);if("array"!==s&&"object"!==s)throw Error("warning:"+t.expr+"只能是对象或数组");t.xtype=s;var c=function(e,t){for(var n,r=[],i=0;n=e[i++];)r.push(t?n.$id:n.$key);return r.join(";")}(t.proxies||[],s),l=r.$track||("array"===s?ie(r.length):Object.keys(r));t.track=l,c!==l.join(";")&&(t.handler(r,i),t.oldValue=1)}else Array.isArray(r)&&r.length!==(i&&i.length)?(t.handler(r,i),t.oldValue=r.concat()):"oldValue"in t&&r===i||(t.handler(r,i),t.oldValue=Array.isArray(r)?r.concat():r)}catch(e){delete t.getter,a("warning:exception throwed in [Anot.injectBinding] ",e);var u=t.element;u&&3===u.nodeType&&(u.nodeValue=L+(t.oneTime?"::":"")+t.expr+M)}finally{n&&ce.end()}},t.update()};var le=N.$$subscribers=[],ue=new Date;var fe=0;function pe(e){for(var t=fe||le.length,n=0;e=le[--t];)if(e.i<7){if(null===e.element){le.splice(t,1),e.list&&(N.Array.remove(e.list,e),delete le[e.uuid]);continue}if(he(e.element)){if(le.splice(t,1),N.Array.remove(e.list,e),de(e),n++>500){fe=t;break}continue}e.i++,7===e.i&&(e.i=14)}else e.i--;ue=new Date}function de(e){for(var t in delete le[e.uuid],e.element=null,e.rollback&&e.rollback(),e)e[t]=null}function he(e){try{e.parentNode.nodeType}catch(e){return!0}return e.ifRemove&&!b.contains(e.ifRemove)&&i===e.parentNode?(e.parentNode&&e.parentNode.removeChild(e),!0):e.msRetain?0:1===e.nodeType?!b.contains(e):!N.contains(b,e)}var ve=new function(){N.mix(this,{option:n.createElement("select"),thead:n.createElement("table"),td:n.createElement("tr"),area:n.createElement("map"),tr:n.createElement("tbody"),col:n.createElement("colgroup"),legend:n.createElement("fieldset"),_default:n.createElement("div"),g:n.createElementNS("http://www.w3.org/2000/svg","svg")}),this.optgroup=this.option,this.tbody=this.tfoot=this.colgroup=this.caption=this.thead,this.th=this.td};String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(f,(function(e){ve[e]=ve.g}));var me=/<([\w:]+)/,ye=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,ge=C(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),be=n.createElement("script"),xe=/<|&#?\w+;/;function $e(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function we(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,(function(e){return e.charAt(1).toUpperCase()}))}N.parseHTML=function(e){var t=x.cloneNode(!1);if("string"!=typeof e)return t;if(!xe.test(e))return t.appendChild(n.createTextNode(e)),t;e=e.replace(ye,"<$1>").trim();var r,i=(me.exec(e)||["",""])[1].toLowerCase(),a=ve[i]||ve._default;a.innerHTML=e;var o=a.getElementsByTagName("script");if(o.length)for(var s,c=0;s=o[c++];)if(ge[s.type]){var l=be.cloneNode(!1);y.forEach.call(s.attributes,(function(e){l.setAttribute(e.name,e.value)})),l.text=s.text,s.parentNode.replaceChild(l,s)}for(;r=a.firstChild;)t.appendChild(r);return t},N.innerHTML=function(e,t){var n=this.parseHTML(t);this.clearHTML(e).appendChild(n)},N.clearHTML=function(e){for(e.textContent="";e.firstChild;)e.removeChild(e.firstChild);return e},"add,remove".replace(f,(function(e){N.fn[e+"Class"]=function(t){var n=this[0];return t&&"string"==typeof t&&n&&1===n.nodeType&&t.replace(/\S+/g,(function(t){n.classList[e](t)})),this}})),N.fn.mix({attr:function(e,t){return 2===arguments.length?(this[0].setAttribute(e,t),this):this[0].getAttribute(e)},data:function(e,t){var n=arguments.length,r=this[0].dataset;switch((e=$e(e||""))||(n=0),n){case 2:return r[e]=t,this;case 1:var i=r[e];return Ce(i);case 0:var a=o();for(var s in r)a[s]=Ce(r[s]);return a}},removeData:function(e){return e="data-"+$e(e),this[0].removeAttribute(e),this},css:function(e,t){if(N.isPlainObject(e))for(var n in e)N.css(this,n,e[n]);else var r=N.css(this,e,t);return void 0!==r?r:this},position:function(){var e,t,n=this[0],r={top:0,left:0};if(n)return"fixed"===this.css("position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),"HTML"!==e[0].tagName&&(r=e.offset()),r.top+=N.css(e[0],"borderTopWidth",!0),r.left+=N.css(e[0],"borderLeftWidth",!0),r.top-=e.scrollTop(),r.left-=e.scrollLeft()),{top:t.top-r.top-N.css(n,"marginTop",!0),left:t.left-r.left-N.css(n,"marginLeft",!0)}},offsetParent:function(){for(var e=this[0].offsetParent;e&&"static"===N.css(e,"position");)e=e.offsetParent;return N(e||b)},bind:function(e,t,n){if(this[0])return N.bind(this[0],e,t,n)},unbind:function(e,t,n){return this[0]&&N.unbind(this[0],e,t,n),this},val:function(e){var t=this[0];if(t&&1===t.nodeType){var n=0===arguments.length,r=n?":get":":set",i=De[Se(t)+r];if(i)var a=i(t,e);else{if(n)return(t.value||"").replace(/\r/g,"");t.value=e}}return n?a:this}}),N.parseJSON=JSON.parse;var ke=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/;function Ce(e){try{if("object"==typeof e)return e;e="true"===e||"false"!==e&&("null"===e?null:+e+""===e?+e:ke.test(e)?JSON.parse(e):e)}catch(e){}return e}function Ae(e){return e.window&&e.document?e:9===e.nodeType&&e.defaultView}N.fireDom=function(e,t,r){var i=n.createEvent("Events");i.initEvent(t,!0,!0),N.mix(i,r),e.dispatchEvent(i)},N.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},(function(e,t){N.fn[e]=function(n){var r=this[0]||{},i=Ae(r),a="scrollTop"===e;if(!arguments.length)return i?i[t]:r[e];i?i.scrollTo(a?i[t]:n,a?n:i[t]):r[e]=n}}));var Ne=N.cssHooks=o(),je=["","-webkit-","-moz-","-ms-"],Te={float:"cssFloat"};N.cssNumber=C("animationIterationCount,animationIterationCount,columnCount,order,flex,flexGrow,flexShrink,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),N.cssName=function(e,t,n){if(Te[e])return Te[e];t=t||b.style;for(var r=0,i=je.length;r-1)&&(n=!0);n||(e.selectedIndex=-1)}},_e={};["break,case,catch,continue,debugger,default,delete,do,else,false","finally,for,function,if,in,instanceof,new,null,return,switch,this","throw,true,try,typeof,var,void,while,with","abstract,boolean,byte,char,class,const,double,enum,export,extends","final,float,goto,implements,import,int,interface,long,native","package,private,protected,public,short,static,super,synchronized","throws,transient,volatile","arguments,let,yield,async,await,undefined"].join(",").replace(/\w+/g,(function(e){_e[e]=!0}));var Pe=/[a-z_$]/i,Le=/[\s\uFEFF\xA0]/;function Me(e,t){if(t&&!_e[t])return e.push(t),!0}function He(e,t,n,r){for(var i,a=[],o=" = "+n+".",s=e.length;i=e[--s];){var c=i.split(".")[0];t.hasOwnProperty(c)&&(a.push(c+o+c),r.observers.push({v:t,p:i,type:N.type(t[c])}),e.splice(s,1))}return a}var Fe=/(proxy\-[a-z]+)\-[\-0-9a-f]+$/,Be=new D(218),Ie=new D(128);function Re(e){e=e.trim();var t=Be.get(e);if(t)return t.concat();for(var n,r=function e(t,n){var r=[],i=!!n;n=n||0;for(var a="unknown",o="",s=0;s0){var t=e.replace(pt,(function(e){return Array(e.length+1).join("1")})).replace(ft,"ᄢ㍄").indexOf("|");if(t>-1)return{type:"text",filters:e.slice(t).trim(),expr:e.slice(0,t)}}return{type:"text",expr:e,filters:""}}function vt(e){for(var t,n,r=[],i=0;;){if(-1===(n=e.indexOf(L,i)))break;if((t=e.slice(i,n))&&r.push({expr:t}),i=n+L.length,-1===(n=e.indexOf(M,i)))break;(t=e.slice(i,n))&&r.push(ht(t.replace(dt,""))),i=n+M.length}return(t=e.slice(i))&&r.push({expr:t}),r}function mt(e,t,r){var i=[],a=vt(e.data);if(a.length){for(var o,s=0;o=a[s++];){var c=n.createTextNode(o.expr);o.type&&(o.expr=o.expr.replace(Qe,(function(){return o.oneTime=!0,""})),o.element=c,o.filters=o.filters.replace(ut,(function(){return o.type="html",""})),o.pos=1e3*r+s,i.push(o)),x.appendChild(c)}e.parentNode.replaceChild(x,e),i.length&&Ze(i,t)}}var yt=function(){this.queue=[]};yt.prototype={render:function(e){if(!this.locked){this.locked=e?b.offsetHeight+10:1;var t=this;N.nextTick((function(){t.flush()}))}},flush:function(){for(var e,t=0;e=this.queue[t++];)e.update&&e.update();this.locked=0,this.queue=[]}};var gt=new yt,bt=["autofocus,autoplay,async,allowTransparency,checked,controls","declare,disabled,defer,defaultChecked,defaultSelected","contentEditable,isMap,loop,multiple,noHref,noResize,noShade","open,readOnly,selected"].join(","),xt={};bt.replace(f,(function(e){xt[e.toLowerCase()]=e}));N.directive("attr",{init:function(e){if(e.expr=Ve(e.expr.trim()),"include"===e.type){var t=e.element;Ft(t,e),e.includeRendered=Ke(t,"data-rendered",e.vmodels),e.includeLoaded=Ke(t,"data-loaded",e.vmodels);var r=e.includeReplace=t.hasAttribute("replace");t.hasAttribute("cache")&&(e.templateCache={}),e.start=n.createComment(":include"),e.end=n.createComment(":include-end"),r?(e.element=e.end,e._element=t,t.parentNode.insertBefore(e.start,t),t.parentNode.insertBefore(e.end,t.nextSibling)):(t.insertBefore(e.start,t.firstChild),t.appendChild(e.end))}},update:function(e){var t=this.element,n=Object.create(null),r=d.test(t);if(e=Z(e),this.param)e&&"object"==typeof e?Array.isArray(e)?n[this.param]=e:Date.isDate(e)?n[this.param]=e.toISOString():n[this.param]=e:n[this.param]=e;else{if(!e||"object"!=typeof e||Array.isArray(e)||Date.isDate(e))return;n=e}for(var i in n)if("style"!==i){if("xlink:"===i.slice(0,6)){var a=i;n[i=i.slice(6)]=n[a],delete n[a]}if(!1!==n[i]&&null!==n[i]&&void 0!==n[i]||(n[i]=""),"boolean"==typeof t[i]||"boolean"==typeof t[xt[i]]){a=i;if(xt[i]&&a!==xt[i]&&(a=xt[i]),n[i]=!!n[i],t[a]=n[i],!n[i]){t.removeAttribute(a);continue}}!r&&i in t.cloneNode(!1)?t[i]=n[i]:("object"==typeof n[i]&&(n[i]=Date.isDate(n[i])?n[i].toISOString():JSON.stringify(n[i])),t.setAttribute(i,n[i]))}else t.style.cssText=n[i]}});N.directive("class",{init:function(e){if(e.expr=e.expr.replace(/\n/g," ").replace(/\s+/g," "),"hover"===e.type||"active"===e.type){var t=new Function("return "+e.expr)();if(!e.hasBindEvent){var n=e.element,r=N(n),i="mouseenter",a="mouseleave";if("active"===e.type){n.tabIndex=n.tabIndex||-1,i="mousedown",a="mouseup";var o=r.bind("mouseleave",(function(){r.removeClass(t)}))}}var s=r.bind(i,(function(){r.addClass(t)})),c=r.bind(a,(function(){r.removeClass(t)}));e.rollback=function(){r.unbind("mouseleave",o),r.unbind(i,s),r.unbind(a,c)},e.hasBindEvent=!0}},update:function(e){if("class"===this.type){var t=e;if(!t||this.param)return a('class指令语法错误 %c %s="%s"',"color:#f00",this.name,this.expr);for(var n in"string"==typeof t&&((t={})[e]=!0),N.isPlainObject(t)||(t=t.$model),t)this.element.classList.toggle(n,!!t[n])}}}),"hover,active".replace(f,(function(e){S[e]=S.class})),N.directive("css",{init:S.attr.init,update:function(e){var t=N(this.element);if(this.param)t.css(this.param,e);else{if("object"!=typeof e)return a(':css指令格式错误 %c %s="%s"',"color:#f00",this.name,this.expr);var n=e;N.isPlainObject(n)||(n=e.$model),t.css(n)}}}),N.directive("data",{priority:100,init:S.attr.init,update:function(e){var t=N(this.element);if(this.param)t.data(this.param,e);else{if("object"!=typeof e)return a(':data指令格式错误 %c %s="%s"',"color:#f00",this.name,this.expr);var n=e;for(var r in N.isPlainObject(n)||(n=e.$model),n)t.data(r,n[r])}}});var $t=/^(?:checkbox|radio)$/,wt=/^(?:radio|checked)$/,kt=/^(file|button|reset|submit|checkbox|radio|range)$/;N.directive("duplex",{priority:2e3,init:function(e,t){var n=e.element,r=e.vmodels;e.changed=Ke(n,"data-changed",r)||w;var i=[],o=C("string,number,boolean,checked");"radio"===n.type&&""===e.param&&(e.param="checked"),e.param.replace(p,(function(r){$t.test(n.type)&&wt.test(r)&&(r="checked",e.isChecked=!0,e.xtype="radio"),o[r]&&(t=!0),N.Array.ensure(i,r)})),t||i.push("string"),e.param=i.join("-"),e.xtype||(e.xtype="SELECT"===n.tagName?"select":"checkbox"===n.type?"checkbox":"radio"===n.type?"radio":/^change/.test(n.getAttribute("data-event"))?"change":"input"),n.expr=e.expr;var s=e.bound=function(t,r){n.addEventListener(t,r,!1);var i=e.rollback;e.rollback=function(){n.anotSetter=null,N.unbind(n,t,r),i&&i()}};function c(t){e.changed.call(this,t)}var l=!1;var u=function(t){var r=n.value;if(!l&&r!==e.oldValue&&null!==e.pipe){var i=e.pipe(r,e,"get");e.oldValue=r,e.setter(i),c.call(n,i),N.fireDom(n,"change")}};switch(e.xtype){case"radio":s("click",(function(){var t=e.pipe(n.value,e,"get");e.setter(t),c.call(n,t)}));break;case"checkbox":s("change",(function(){var t=n.checked?"ensure":"remove",r=e.getter.apply(0,e.vmodels);Array.isArray(r)||(a(":duplex应用于checkbox上要对应一个数组"),r=[r]);var i=e.pipe(n.value,e,"get");N.Array[t](r,i),c.call(n,r)}));break;case"change":s("change",u);break;case"input":s("input",u),s("keyup",u),s("compositionstart",(function(){l=!0})),s("compositionend",(function(){l=!1,setTimeout(u)})),s("DOMAutoComplete",u);break;case"select":s("change",(function(){var t=N(n).val();if((t=Array.isArray(t)?t.map((function(t){return e.pipe(t,e,"get")})):e.pipe(t,e,"get"))+""!==e.oldValue)try{e.setter(t)}catch(e){a(e)}})),s("datasetchanged",(function(t){if("selectDuplex"===t.bubble){var r=e._value,i=Array.isArray(r)?r.map(String):r+"";N(n).val(i),n.oldValue=i+"",c.call(n,i)}}))}"input"!==e.xtype||kt.test(n.type)||("hidden"!==n.type&&(s("focus",(function(){n.msFocus=!0})),s("blur",(function(){n.msFocus=!1}))),n.anotSetter=u,Ot((function(){if(b.contains(n))n.msFocus||u();else if(!n.msRetain)return!1})))},update:function(e){var t,n=this.element;this.init||((this.pipe||(this.pipe=At))(null,this,"init"),this.init=1);switch(this.xtype){case"input":n.value=e;break;case"change":if((t=this.pipe(e,this,"set"))!==this.oldValue){var r=!1;if(n.msFocus)try{var i=n.selectionStart;if(i===n.selectionEnd){var a=i;r=!0}}catch(e){}n.value=this.oldValue=t,r&&!n.readOnly&&(n.selectionStart=n.selectionEnd=a)}break;case"radio":t=this.isChecked?!!e:e+""===n.value,n.checked=t;break;case"checkbox":var o=[].concat(e);t=this.pipe(n.value,this,"get"),n.checked=o.indexOf(t)>-1;break;case"select":this._value=e,n.msHasEvent?N.fireDom(n,"datasetchanged",{bubble:n.msHasEvent}):n.msHasEvent="selectDuplex"}}});function Ct(e){return null==e?"":e}function At(e,t,n,r){return t.param.replace(p,(function(r){var i=N.duplexHooks[r];i&&"function"==typeof i[n]&&(e=i[n](e,t))})),e}N.duplexHooks={checked:{get:function(e,t){return!t.oldValue}},string:{get:function(e){return e},set:Ct},boolean:{get:function(e){return"true"===e},set:Ct},number:{get:function(e,t){var n=+e;return+e===n?n:0},set:Ct}};var Nt,jt=[];function Tt(){for(var e=jt.length-1;e>=0;e--){!1===(0,jt[e])()&&jt.splice(e,1)}jt.length||clearInterval(Nt)}N.tick=function(e){1===jt.push(e)&&(Nt=setInterval(Tt,60))};var Ot=w;new function(){try{var e={},t=HTMLInputElement.prototype,n=HTMLTextAreaElement.prototype;function r(t){e[this.tagName].call(this,t),!this.msFocus&&this.anotSetter&&this.anotSetter()}var i=HTMLInputElement.prototype;Object.getOwnPropertyNames(i),e.INPUT=Object.getOwnPropertyDescriptor(t,"value").set,Object.defineProperty(t,"value",{set:r}),e.TEXTAREA=Object.getOwnPropertyDescriptor(n,"value").set,Object.defineProperty(n,"value",{set:r})}catch(e){Ot=N.tick}},N.directive("effect",{priority:5,init:function(e){var t,n,r=e.expr,i=r.replace(F,(function(e){return e.replace(/./g,"0")})).indexOf(":");-1===i?(t=r,n=!0):(t=r.slice(0,i),n=r.slice(i+1)),t=H.test(r)?Ve(t):Je(t),e.expr="["+t+","+n+"]"},update:function(e){var t=e[0],n=this.element;if(n.getAttribute("data-effect-name")!==t){n.removeAttribute("data-effect-driver");var r=n.style,i=window.getComputedStyle?window.getComputedStyle(n):null,a=!1;if(i&&(Dt||_t)){var o=r[Pt]||i[Pt];o&&"0s"!==o&&(n.setAttribute("data-effect-driver","t"),a=!0),a||(o=r[Lt]||i[Lt])&&"0s"!==o&&(n.setAttribute("data-effect-driver","a"),a=!0)}a||N.effects[t]&&(n.setAttribute("data-effect-driver","j"),a=!0),a&&n.setAttribute("data-effect-name",t)}}}),N.effects={},N.effect=function(e,t){N.effects[e]=t};var Et,St,Dt=!1,_t=!1,Pt=N.cssName("transition-duration"),Lt=N.cssName("animation-duration");new function(){var e,t,n={TransitionEvent:"transitionend",WebKitTransitionEvent:"webkitTransitionEnd",OTransitionEvent:"oTransitionEnd",otransitionEvent:"otransitionEnd"};for(var r in n){if(window[r]){e=n[r];break}try{document.createEvent(r);e=n[r];break}catch(e){}}for(r in"string"==typeof e&&(Dt=!0,Et=e),n={AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"})if(window[r]){t=n[r];break}"string"==typeof t&&(Dt=!0,St=t)};var Mt=[];function Ht(e,t){if(!e||1!==e.nodeType)return null;if(t)var n=t.effectName,r=t.effectDriver;else n=e.getAttribute("data-effect-name"),r=e.getAttribute("data-effect-driver");if(!n||!r)return null;var i=Mt.pop()||new Rt;return i.el=e,i.driver=r,i.useCss="j"!==r,i.useCss&&(t&&N(e).addClass(t.effectClass),i.cssEvent="t"===r?Et:St),i.name=n,i.callbacks=N.effects[n]||{},i}function Ft(e,t){var n=e.getAttribute("data-effect-name");if(n){t.effectName=n,t.effectDriver=e.getAttribute("data-effect-driver");var r=+e.getAttribute("data-effect-stagger");t.effectLeaveStagger=+e.getAttribute("data-effect-leave-stagger")||r,t.effectEnterStagger=+e.getAttribute("data-effect-enter-stagger")||r,t.effectClass=e.className||NaN}}function Bt(e){return e.replace(/^[\S]/g,(function(e){return e.toUpperCase()}))}var It=new yt;function Rt(){}function qt(e,t){var n=e.callbacks[t+"Class"];return"string"==typeof n?n:"function"==typeof n?n():e.name+"-"+t}function Vt(e,t,n){var r=e.callbacks[t];r&&r.call(e,e.el,n)}Rt.prototype={contrustor:Rt,enterClass:function(){return qt(this,"enter")},leaveClass:function(){return qt(this,"leave")},actionFun:function(e,t,n){if(!document.hidden){var r=this,i=r.el,a="leave"===e;e=a?"leave":"enter",Vt(r,"abort"+Bt(a?"enter":"leave")),Vt(r,"before"+Bt(e)),a||t(i);var o=function(o){i.removeEventListener(r.cssEvent,r.cssCallback),a?(t(i),N(i).removeClass(r.cssClass)):"a"===r.driver&&N(i).removeClass(r.cssClass),!0!==o&&(Vt(r,"after"+Bt(e)),n&&n(i)),r.dispose()};r.useCss?(r.cssCallback&&r.cssCallback(!0),r.cssClass=qt(r,e),r.cssCallback=o,r.update=function(){i.addEventListener(r.cssEvent,r.cssCallback),a||"t"!==r.driver||N(i).removeClass(r.cssClass)},N(i).addClass(r.cssClass),It.render(!0),It.queue.push(r)):Vt(r,e,o)}},enter:function(e,t){this.actionFun.apply(this,["enter"].concat(N.slice(arguments)))},leave:function(e,t){this.actionFun.apply(this,["leave"].concat(N.slice(arguments)))},dispose:function(){this.update=this.cssCallback=null,Mt.unshift(this)>100&&Mt.pop()}};var Wt=function(e,t){var n=g.call(arguments,0);"function"!=typeof n[2]&&n.splice(2,0,w),"function"!=typeof n[3]&&n.splice(3,0,w);var r=n[2],i=n[3],a=n[4],o=Ht(e,a);if(!o)return r(),i(),!1;var s=t?"enter":"leave";o[s](r,i)};N.mix(N.effect,{apply:Wt,append:function(e,t,n,r){return Wt(e,1,(function(){t.appendChild(e)}),n,r)},before:function(e,t,n,r){return Wt(e,1,(function(){t.parentNode.insertBefore(e,t)}),n,r)},remove:function(e,t,n,r){return Wt(e,0,(function(){e.parentNode===t&&t.removeChild(e)}),n,r)}}),N.directive("html",{update:function(e){var t=this.element,r=1!==t.nodeType,i=r?t.parentNode:t;if(i){if(e=null==e?"":e,3===t.nodeType){var a=A("html");i.insertBefore(n.createComment(a),t),this.element=n.createComment(a+":end"),i.replaceChild(this.element,t),t=this.element}if("object"!=typeof e)var o=N.parseHTML(String(e));else if(11===e.nodeType)o=e;else if(1===e.nodeType||e.item){var s=1===e.nodeType?e.childNodes:e.item;for(o=x.cloneNode(!0);s[0];)o.appendChild(s[0])}if(s=N.slice(o.childNodes),r){for(var c=t.nodeValue.slice(0,-4);;){var l=t.previousSibling;if(!l||8===l.nodeType&&l.nodeValue===c)break;i.removeChild(l)}i.insertBefore(o,t)}else N.clearHTML(t).appendChild(o);ct(s,this.vmodels)}}}),N.directive("text",{update:function(e){var t=this.element;if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(e){}else t.textContent=e}}),N.directive("if",{priority:10,update:function(e){var t,r=this,a=this.element,o=r.stamp=Date.now(),s=function(){o===r.stamp&&(r.recoverNode=null)};r.recoverNode&&r.recoverNode();try{if(!a.parentNode)return;t=a.parentNode}catch(e){return}if(e){function c(){a.getAttribute(r.name)&&(a.removeAttribute(r.name),at(a,r.vmodels)),r.rollback=null}if(8===a.nodeType){var l=r.keep,u=N.effect.apply(l,1,(function(){o===r.stamp&&(a.parentNode.replaceChild(l,a),a=r.element=l,l.getAttribute("_required")&&(a.required=!0,a.removeAttribute("_required")),a.querySelectorAll&&N.each(a.querySelectorAll("[_required=true]"),(function(e){e.required=!0,e.removeAttribute("_required")})),c())}),s);u=!1===u}u||c()}else if(1===a.nodeType){!0===a.required&&(a.required=!1,a.setAttribute("_required","true"));try{N.each(a.querySelectorAll(":required"),(function(e){a.required=!1,e.setAttribute("_required","true")}))}catch(e){}var f=r.element=n.createComment(":if"),p=a.nextSibling;r.recoverNode=function(){r.recoverNode=null,f.parentNode!==t&&(t.insertBefore(f,p),r.keep=a)},N.effect.apply(a,0,(function(){r.recoverNode=null,o===r.stamp&&(a.parentNode.replaceChild(f,a),r.keep=a,i.appendChild(a),r.rollback=function(){a.parentNode===i&&i.removeChild(a)})}),s)}}});var zt=N.templateCache={};function Ut(e){for(var t=n.createDocumentFragment(),r=0,i=e.length;r=200&&this.status<400?m.resolve(this.response):m.reject(this))},v.send(null),m.promise).then(t=>{zt[e]=t,y(t)}).catch(t=>{a(":include load ["+e+"] error\n%c%s","color:#f30",`获取网络资源出错, ${t.status} (${t.statusText})`)})}}});var Yt=/\(([^)]*)\)/,Gt=N.directive("on",{priority:3e3,init:function(e){var t=e.expr;e.type="on";var n=e.param.replace(/-\d+$/,"");if("function"==typeof Gt[n+"Hook"]&&Gt[n+"Hook"](e),t.indexOf("(")>0&&t.indexOf(")")>-1){var r=(t.match(Yt)||["",""])[1].trim();""!==r&&"$event"!==r||(t=t.replace(Yt,""))}e.expr=t},update:function(e){var t=this,n=this.element;e=function(e){return(t.getter||w).apply(t.args[0],t.args.concat(e))};var r=t.param.replace(/-\d+$/,"");if("scan"===r)e.call(n,{type:r});else if("function"==typeof t.specialBind)t.specialBind(n,e);else var i=N.bind(n,r,e);t.rollback=function(){"function"==typeof t.specialUnbind?t.specialUnbind():N.unbind(n,r,i)}}});function Jt(e,t,n){for(var r,i=0;r=e[i++];)r.className===n.effectClass&&N.effect.apply(r,t,w,w,n)}function Xt(e,t,n){return e?setTimeout(t,++n*e):t(),n}function Kt(e,t,n){for(var r=x.cloneNode(!1),i=e,a=i.nodeValue,o=t&&Math.max(+t.staggerIndex,0),s=N.slice(i.parentNode.childNodes),c=s.indexOf(i);;){var l=s[--c];if(!l||0===String(l.nodeValue).indexOf(a))break;!n&&t&&l.className===t.effectClass?(e=l,function(e){t.staggerIndex=Xt(t.effectLeaveStagger,(function(){N.effect.apply(e,0,w,(function(){r.appendChild(e)}),t)}),o)}(l)):r.insertBefore(l,r.firstChild)}return r.appendChild(i),r}function Zt(e,t,n,r,i){var a=e.template.cloneNode(!0),o=N.slice(a.childNodes);a.appendChild(n.$anchor),i&&t.appendChild(a);n[e.param||"el"];var s={nodes:o,vmodels:[n].concat(e.vmodels),content:a};r.push(s)}function Qt(e){var t=("object"===e.xtype?an:nn)(e);return(t.$anchor||(t.$anchor=e.element.cloneNode(!1))).nodeValue=e.signature,t.$outer=e.$outer,t}function en(e,t,n){if("array"===n){e.$remove=function(){t.$repeat.removeAt(e.$index)};var r=t.param;e.$watch(r,(function(n){var r=e.$index;t.$repeat[r]=n}))}else{var i=t.vars[0],a=t.vars[1];e.$up.$watch(t.expr+"."+e[i],(function(n){e[t.param][a]=n,e[a]=n}))}}N.directive("for",{priority:90,init:function(e){var t=e.type;e.cache={},e.enterCount=0;var r=e.element;if(1===r.nodeType){var i=e.expr.split(" in ");e.expr=i.pop(),i.length&&(i=i.pop().split(/\s+/)),e.vars=i,r.removeAttribute(e.name),Ft(r,e);var a=Ke(r,"data-rendered",e.vmodels),o=A(t),s=n.createComment(o+":start"),c=e.element=n.createComment(o+":end");e.signature=o,e.start=s,e.template=x.cloneNode(!1);var l=r.parentNode;if(l.replaceChild(c,r),l.insertBefore(s,c),e.template.appendChild(r),e.element=c,a)var u=N.bind(l,"datasetchanged",(function(){a.apply(l,l.args),N.unbind(l,"datasetchanged",u),l.msRendered=a}))}},update:function(e,t){var n=this,r=this.xtype;"array"===r?(this.vars.length?1===this.vars.length&&this.vars.unshift("$index"):this.vars.push("$index","el"),this.param=this.vars[1]):(this.param="__el__",this.vars.length?1===this.vars.length&&this.vars.push("$val"):this.vars.push("$key","$val")),this.enterCount+=1;var i=!t;if(i){n.$outer={};var a=this.vars[0],o=this.vars[1];"array"===r&&(a="$first",o="$last");for(var s,c=0;s=n.vmodels[c++];)if(s.hasOwnProperty(a)&&s.hasOwnProperty(o)){n.$outer=s;break}}var l=this.track,u="move";n.$repeat=e;var f=[],p=i&&x.cloneNode(!1),d=[],h=this.param,v=N.mix({},this.cache),m=this.element,y=l.length,g=m.parentNode,b=0;for(c=0;c10,A=m.previousSibling,j=n.start;if(C)for(;A!==j;)g.removeChild(A),A=m.previousSibling;for(c=0;cP.maxRepeatSize&&i.pop(),delete e[t]}}function sn(e,t){var r="_"+e;if(!sn[r]){var i=n.createElement(e);b.appendChild(i),t=getComputedStyle(i,null).display,b.removeChild(i),sn[r]=t}return sn[r]}N.parseDisplay=sn,N.directive("visible",{init:function(e){Ft(e.element,e)},update:function(e){var t,n=this,r=this.element,i=!this.effectName;if(!this.stamp)return t=this.stamp=Date.now(),void(e?(r.style.display=n.display||"","none"===N(r).css("display")&&(r.style.display=n.display=sn(r.nodeName))):r.style.display="none");t=this.stamp=+new Date,e?N.effect.apply(r,1,(function(){if(t===n.stamp){var e=r.getAttribute("data-effect-driver")||"a";i&&(r.style.display=n.display||""),"a"!==e&&"t"!==e||"none"===N(r).css("display")&&(r.style.display=n.display||sn(r.nodeName))}})):N.effect.apply(r,0,(function(){t===n.stamp&&(r.style.display="none")}))}});var cn=/]*>([\S\s]*?)<\/script\s*>/gim,ln=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,un=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,fn={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},pn=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,dn=/([^\#-~| |!])/g;function hn(e,t,n,r){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var i=isFinite(+e)?+e:0,a=isFinite(+t)?Math.abs(t):3,o=r||",",s=n||".",c="";return(c=(a?function(e,t){var n=Math.pow(10,t);return""+(Math.round(e*n)/n).toFixed(t)}(i,a):""+Math.round(i)).split("."))[0].length>3&&(c[0]=c[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,o)),(c[1]||"").length>=0)%60,n=Math.floor(e/60),r=Math.floor(n/60);return n=(n%=60)<10?"0"+n:n,t=t<10?"0"+t:t,r>0?(r=r<10?"0"+r:r)+":"+n+":"+t:n+":"+t},$filter:function(e){for(var t=1,n=arguments.length;t/g,">")},currency:function(e,t,n){return(t||"¥")+hn(e,isFinite(n)?n:2)},number:hn,date:function(e,t){var n=e;if(!Date.isDate(n)){var r=+n;if(r==r&&(n=r),"Invalid Date"===(n=new Date(n)).toString())return"Invalid Date"}return n.format(t)}};let mn,yn=[],gn=function(e){for(mn=!0;e=yn.shift();)e(N)};return"complete"===n.readyState?setTimeout(gn):n.addEventListener("DOMContentLoaded",gn),window.addEventListener("load",gn),N.ready=function(e){mn?e(N):yn.push(e)},window.Anot=N,N}();export default _Anot; \ No newline at end of file diff --git a/src/lib/drag/core.js b/src/lib/drag/core.js index 2470449..2e2a9f0 100644 --- a/src/lib/drag/core.js +++ b/src/lib/drag/core.js @@ -1 +1 @@ -"use strict";import $ from"../utils.js";const DEF_OPT={axis:"",limit:!1,overflow:!0};export default class Drag{constructor(t){this.$elem=t,this._init()}_init(){this.$elem.style.transform="";var{x:t,y:s}=this.$elem.getBoundingClientRect();this.pos={x:t,y:s,_x:0,_y:0}}by(t,s={}){return this.$drag=t,this.opt=Object.assign(Object.create(null),DEF_OPT,s),!1!==this.opt.limit&&(this.opt.overflow=!1),t.style.cursor="move",this._handleResize=$.bind(window,"resize",this._init.bind(this)),this._handleMousedown=$.bind(t,"mousedown",t=>{if(this.disabled)return;var s=this.$elem.getBoundingClientRect();s.x-this.pos._x!==this.pos.x&&(this.pos.x=s.x-this.pos._x),s.y-this.pos._y!==this.pos.y&&(this.pos.y=s.y-this.pos._y);let e=t.pageX,i=t.pageY,o=document.documentElement.clientWidth,n=document.documentElement.clientHeight,h=s.width,p=s.height,d=[0,o-h,n-p,0];if("parent"===this.opt.limit){let t=this.$elem.parentNode.getBoundingClientRect();d=[t.top,t.right-h,t.bottom-p,t.left]}let l=$.bind(document,"mousemove",t=>{t.preventDefault();let o=t.pageX-e+(s.x-this.pos.x),n=t.pageY-i+(s.y-this.pos.y);"x"===this.opt.axis&&(n=0),"y"===this.opt.axis&&(o=0),!1===this.opt.overflow&&(od[1]-this.pos.x&&(o=d[1]-this.pos.x),nd[2]-this.pos.y&&(n=d[2]-this.pos.y)),this.pos._x=o,this.pos._y=n,this.$elem.dispatchEvent(new CustomEvent("dragging",{detail:{offset:{x:this.pos.x+o,y:this.pos.y+n},move:{x:o,y:n}}})),this.$elem.style.transform=`translate(${o}px, ${n}px)`}),m=$.bind(document,"mouseup",t=>{this.$elem.dispatchEvent(new CustomEvent("dragged",{detail:{offset:{x:this.pos.x+this.pos._x,y:this.pos.y+this.pos._y},move:{x:this.pos._x,y:this.pos._y}}})),$.unbind(document,"mousemove",l),$.unbind(document,"mouseup",m)})}),this}on(t,s){if(t&&"function"==typeof s)return $.bind(this,t,s)}off(t,s){$.unbind(this,t,s)}destroy(){$.unbind(window,"resize",this._handleResize),$.unbind(this.$drag,"mousedown",this._handleMousedown),delete this.$elem,delete this.$drag}}; \ No newline at end of file +import $ from"../utils.js";const DEF_OPT={axis:"",limit:!1,overflow:!0};export default class Drag{constructor(t){this.$elem=t,this._init()}_init(){this.$elem.style.transform="";var{x:t,y:s}=this.$elem.getBoundingClientRect();this.pos={x:t,y:s,_x:0,_y:0}}by(t,s={}){return this.$drag=t,this.opt=Object.assign(Object.create(null),DEF_OPT,s),!1!==this.opt.limit&&(this.opt.overflow=!1),t.style.cursor="move",this._handleResize=$.bind(window,"resize",this._init.bind(this)),this._handleMousedown=$.bind(t,"mousedown",t=>{if(this.disabled)return;var s=this.$elem.getBoundingClientRect();s.x-this.pos._x!==this.pos.x&&(this.pos.x=s.x-this.pos._x),s.y-this.pos._y!==this.pos.y&&(this.pos.y=s.y-this.pos._y);let e=t.pageX,i=t.pageY,o=document.documentElement.clientWidth,n=document.documentElement.clientHeight,h=s.width,p=s.height,d=[0,o-h,n-p,0];if("parent"===this.opt.limit){let t=this.$elem.parentNode.getBoundingClientRect();d=[t.top,t.right-h,t.bottom-p,t.left]}let l=$.bind(document,"mousemove",t=>{t.preventDefault();let o=t.pageX-e+(s.x-this.pos.x),n=t.pageY-i+(s.y-this.pos.y);"x"===this.opt.axis&&(n=0),"y"===this.opt.axis&&(o=0),!1===this.opt.overflow&&(od[1]-this.pos.x&&(o=d[1]-this.pos.x),nd[2]-this.pos.y&&(n=d[2]-this.pos.y)),this.pos._x=o,this.pos._y=n,this.$elem.dispatchEvent(new CustomEvent("dragging",{detail:{offset:{x:this.pos.x+o,y:this.pos.y+n},move:{x:o,y:n}}})),this.$elem.style.transform=`translate(${o}px, ${n}px)`}),m=$.bind(document,"mouseup",t=>{this.$elem.dispatchEvent(new CustomEvent("dragged",{detail:{offset:{x:this.pos.x+this.pos._x,y:this.pos.y+this.pos._y},move:{x:this.pos._x,y:this.pos._y}}})),$.unbind(document,"mousemove",l),$.unbind(document,"mouseup",m)})}),this}on(t,s){if(t&&"function"==typeof s)return $.bind(this,t,s)}off(t,s){$.unbind(this,t,s)}destroy(){$.unbind(window,"resize",this._handleResize),$.unbind(this.$drag,"mousedown",this._handleMousedown),delete this.$elem,delete this.$drag}} \ No newline at end of file diff --git a/src/lib/drag/index.js b/src/lib/drag/index.js index ed1d3ef..36f957b 100644 --- a/src/lib/drag/index.js +++ b/src/lib/drag/index.js @@ -1 +1 @@ -"use strict";import Drag from"./core.js";Anot.directive("drag",{priority:1500,init:function(e){e.expr='"'+e.expr+'"',e.overflow=!0,e.axis="xy",e.element.dataset.axis&&(e.axis=e.element.dataset.axis,delete e.element.dataset.axis),e.limit=!1,e.element.dataset.limit&&(e.limit=e.element.dataset.limit,e.overflow=!1,delete e.element.dataset.limit)},update:function(e){var t=this.element;if(e)for(t=this.element.parentNode;t;){if(t.classList||Anot.error(`${this.name}=${this.expr}, 解析异常[元素不存在]`),"WC-LAYER"===t.tagName&&"layer"===e){t=t.root.children[1];break}if(t.classList.contains(e)||t.id===e)break;t=t.parentNode}new Drag(t).by(this.element,{limit:this.limit,axis:this.axis,overflow:this.overflow})}}); \ No newline at end of file +import Drag from"./core.js";Anot.directive("drag",{priority:1500,init:function(e){e.expr='"'+e.expr+'"',e.overflow=!0,e.axis="xy",e.element.dataset.axis&&(e.axis=e.element.dataset.axis,delete e.element.dataset.axis),e.limit=!1,e.element.dataset.limit&&(e.limit=e.element.dataset.limit,e.overflow=!1,delete e.element.dataset.limit)},update:function(e){var t=this.element;if(e)for(t=this.element.parentNode;t;){if(t.classList||Anot.error(`${this.name}=${this.expr}, 解析异常[元素不存在]`),"WC-LAYER"===t.tagName&&"layer"===e){t=t.root.children[1];break}if(t.classList.contains(e)||t.id===e)break;t=t.parentNode}new Drag(t).by(this.element,{limit:this.limit,axis:this.axis,overflow:this.overflow})}}); \ No newline at end of file diff --git a/src/lib/icon/index.js b/src/lib/icon/index.js index 7f1e547..bc7c49f 100644 --- a/src/lib/icon/index.js +++ b/src/lib/icon/index.js @@ -1,14 +1,12 @@ /** - * - * @authors yutent (yutent@doui.cc) - * @date 2020-07-07 16:27:17 - * @version v2.0.1 - * - */ + * + * @authors yutent (yutent.io@gmail.com) + * @date 2020-12-23 15:31:02 + * @version v1.0.0 + * + */ -'use strict' - -import SVG_DICT from"./svg.js";let dict=SVG_DICT;window.EXT_SVG_DICT&&Object.assign(dict,EXT_SVG_DICT);export default class Icon extends HTMLElement{static get observedAttributes(){return["is"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{is:""},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__ICO__=this.root.lastElementChild,this.drawPath()}get is(){return this.props.is}set is(o){o&&this.setAttribute("is",o)}drawPath(){var{is:o}=this.props,t=dict[o];this.__ICO__&&o&&t&&(this.__ICO__.innerHTML="loading"===o?t:``,this.__ICO__.classList.toggle("load","loading"===o))}attributeChangedCallback(o,t,e){if(null!==e&&t!==e)switch(o){case"is":this.props.is=e,e?this.drawPath():this.removeAttribute("is")}}}; +import SVG_DICT from"./svg.js";let dict=SVG_DICT;window.EXT_SVG_DICT&&Object.assign(dict,EXT_SVG_DICT);export default class Icon extends HTMLElement{static get observedAttributes(){return["is"]}props={is:""};constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__ICO__=this.root.lastElementChild,this.drawPath()}get is(){return this.props.is}set is(o){o&&this.setAttribute("is",o)}drawPath(){var{is:o}=this.props,r=dict[o];this.__ICO__&&o&&r&&(this.__ICO__.innerHTML="loading"===o?r:``,this.__ICO__.classList.toggle("load","loading"===o))}attributeChangedCallback(o,r,e){if(null!==e&&r!==e)switch(o){case"is":this.props.is=e,e?this.drawPath():this.removeAttribute("is")}}} if(!customElements.get('wc-icon')){ customElements.define('wc-icon', Icon) diff --git a/src/lib/layer/index.js b/src/lib/layer/index.js index fe89d75..c720c9a 100644 --- a/src/lib/layer/index.js +++ b/src/lib/layer/index.js @@ -1,14 +1,12 @@ /** - * - * @authors yutent (yutent.io@gmail.com) - * @date 2020-07-24 13:55:26 - * @version v2.0.1 - * - */ + * + * @authors yutent (yutent.io@gmail.com) + * @date 2020-12-23 15:31:02 + * @version v1.0.0 + * + */ -'use strict' - -import"../form/input.js";import Drag from"../drag/core.js";import $ from"../utils.js";const LANGUAGES={en:{TITLE:"Dialog",BTNS:["Cancel","OK"]},zh:{TITLE:"提示",BTNS:["取消","确定"]}};LANGUAGES["zh-CN"]=LANGUAGES.zh;const lang=LANGUAGES[window.__ENV_LANG__||navigator.language]||LANGUAGES.en;let uniqueInstance=null,toastInstance=null;const UNIQUE_TYPES=["alert","confirm","prompt"];function renderBtns(t){var e="";return t.forEach((t,s)=>{e+=``}),e}class Layer extends HTMLElement{static get observedAttributes(){return["left","right","top","bottom","from","to","btns","type","title","blur","background","mask","radius","mask-close","mask-color","fixed"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{left:"auto",right:"auto",top:"auto",bottom:"auto",from:Object.create(null),to:Object.create(null),btns:[],type:"",title:"",blur:!1,background:null,mask:!1,radius:null,"mask-close":!1,"mask-color":null,fixed:!0},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML='
',this.__TITLE__=this.root.children[1].firstElementChild,this.__BODY__=this.root.children[1].children[1],this.__CTRL__=this.root.children[1].lastElementChild,this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}set title(t){this.props.title=t,t?(this.__TITLE__.firstElementChild?this.__TITLE__.insertBefore(document.createTextNode(t),this.__TITLE__.firstElementChild):this.__TITLE__.textContent=t,this.__TITLE__.style.display="flex"):this.__TITLE__.style.display=""}set type(t){var{btns:e}=this.props;if(t&&!this._handleBtnClick){switch(t){case"alert":for(;e.length>1;)e.splice(0,1);break;case"confirm":case"prompt":for(;e.length>2;)e.splice(0,1);break;case"toast":case"notify":case"frame":if("notify"===t){var s=document.createElement("wc-icon");s.setAttribute("is","close"),this.__TITLE__.appendChild(s)}e=[];break;default:t="common"}this.props.type=t,e.length?(this.__CTRL__.innerHTML=renderBtns(e),this.__CTRL__.style.display="flex"):this.__CTRL__.style.display="",this.setAttribute(t,"")}}set fixed(t){this.props.fixed=!!t,this._updateFixedStat()}_updateFixedStat(){UNIQUE_TYPES.includes(this.props.type)||(this.props.fixed?this._dragIns&&(this._dragIns.destroy(),this._dragIns=null):(this._dragIns=new Drag(this.root.children[1]).by(this.__TITLE__,{overflow:!!this.props.hasOwnProperty("overflow")&&this.props.overflow}),this.removeAttribute("fixed")))}_intercept(t){this.props.intercept?this.props.intercept(t,e=>{delete this.props.intercept,this.resolve(t),this.close()}):(this.resolve(t),this.close())}close(t){if(!1===this.wrapped)if(this._dragIns&&this._dragIns.destroy(),UNIQUE_TYPES.includes(this.props.type)&&(uniqueInstance=null),delete this.promise,$.unbind(this.__CTRL__,"click",this._handleBtnClick),this.props.from&&!t){let t="opacity:0;";for(let e in this.props.from)t+=`${e}:${this.props.from[e]};`;this.root.children[1].style.cssText+=t,this.timer=setTimeout(()=>{this.parentNode.removeChild(this),this.dispatchEvent(new CustomEvent("close"))},200)}else clearTimeout(this.timer),this.parentNode.removeChild(this),this.dispatchEvent(new CustomEvent("close"));else this.removeAttribute("common"),this.dispatchEvent(new CustomEvent("close"))}show(){!1!==this.wrapped&&this.setAttribute("common","")}moveTo(t={}){var e="";for(var s in t)e+=`${s}:${t[s]};`;this.root.children[1].style.cssText+=e}connectedCallback(){this.type=this.props.type,this.title=this.props.title,this._handleBtnClick=$.bind(this.__CTRL__,"click",t=>{if("BUTTON"===t.target.tagName){var e=+t.target.dataset.idx,{type:s}=this.props;switch(s){case"alert":this.resolve(),this.close();break;case"confirm":case"prompt":if(0===e)this.reject(),this.close();else{let t="prompt"===s?this.__INPUT__.value:null;this._intercept(t)}break;default:this._intercept(e)}}}),"prompt"===this.props.type&&(this.__INPUT__=this.__BODY__.firstElementChild.assignedNodes().pop(),this._handleSubmit=$.bind(this.__INPUT__,"submit",t=>{this._intercept(t.detail)})),this.props.mask&&this.setAttribute("mask",""),this._updateFixedStat(),this.props.mask&&(this._handlMask=$.outside(this.root.children[1],t=>{t.target===this&&(this.props["mask-close"]?(!1===this.wrapped&&this.reject(null),this.close()):UNIQUE_TYPES.includes(this.props.type)&&(this.root.children[1].classList.toggle("scale",!0),setTimeout(t=>{this.root.children[1].classList.remove("scale")},100)))}),this.props["mask-color"]&&(this.style.backgroundColor=this.props["mask-color"])),this.props.blur&&this.root.children[1].classList.toggle("blur",!0);let t=this.props.from?"":"opacity:1;";if(this.props.background&&(t+=`background: ${this.props.background};`),(this.props.radius||0===this.props.radius)&&(t+=`border-radius: ${this.props.radius};`),this.props.size)for(let e in this.props.size)t+=`${e}:${this.props.size[e]};`;if(this.props.from){for(let e in this.props.from)t+=`${e}:${this.props.from[e]};`;setTimeout(t=>{let e="opacity:1;";for(let t in this.props.to)e+=`${t}:${this.props.to[t]};`;this.root.children[1].style.cssText+=e},50)}t&&(this.root.children[1].style.cssText+=t),"toast"===this.props.type&&(this.timer=setTimeout(()=>{toastInstance=null,this.close()},3e3)),"notify"===this.props.type&&(this._handleClose=$.bind(this.__TITLE__,"click",t=>{"WC-ICON"===t.target.tagName&&this.close()}))}disconnectedCallback(){$.clearOutside(this._handlMask),$.unbind(this.__TITLE__,"click",this._handleClose)}attributeChangedCallback(t,e,s){if(null!==s&&e!==s)switch(t){case"title":case"type":this[t]=s,this.removeAttribute(t);break;case"mask-color":case"background":this.props[t]=s;break;case"mask":case"mask-close":case"blur":this.props[t]=!0;break;case"radius":this.props.radius=s;break;case"left":case"right":case"top":case"bottom":this.props.from[t]=s,this.props.to=this.props.from,this.removeAttribute(t);break;case"fixed":this.fixed=!0}}}function _layer(t){var e=document.createElement("wc-layer");if(t.type||(t.type="common"),"toast"===t.type){var{type:s,content:o}=t;t={type:s,content:o,from:{top:0},to:{top:"30px"}},toastInstance&&toastInstance.close(!0),toastInstance=e}else e.props.mask=t.mask,!1===t.btns?e.props.btns=[]:t.btns&&t.btns.length?e.props.btns=t.btns:e.props.btns=lang.BTNS.concat(),t.intercept&&"function"==typeof t.intercept&&(e.props.intercept=t.intercept),e.props.mask=t.mask,e.props["mask-close"]=t["mask-close"],t.hasOwnProperty("overflow")&&(e.props.overflow=t.overflow),e.props["mask-color"]=t["mask-color"],e.props.blur=t.blur,e.props.radius=t.radius,e.props.background=t.background,t.size&&"object"==typeof t.size&&(e.props.size=t.size),UNIQUE_TYPES.includes(t.type)&&(uniqueInstance&&uniqueInstance.close(!0),uniqueInstance=e);return t.to&&"object"==typeof t.to&&(e.props.to=t.to,t.from&&"object"==typeof t.from?e.props.from=t.from:e.props.from=t.to),e.props.type=t.type,e.props.title=t.title,t.hasOwnProperty("fixed")&&(e.props.fixed=t.fixed),e.innerHTML=t.content,e.wrapped=!1,document.body.appendChild(e),e.promise}Object.assign(_layer,{alert(t,e=lang.TITLE){return this({type:"alert",title:e,content:t,mask:!0})},confirm(t,e=lang.TITLE,s){return"function"==typeof e&&(s=e,e=lang.TITLE),this({type:"confirm",title:e,content:t,mask:!0,intercept:s})},prompt(t=lang.TITLE,e){return this({type:"prompt",title:t,content:'',mask:!0,intercept:e})},frame(t,e={}){return this({...e,type:"frame",content:``,mask:!0,"mask-close":!0})},notify(t){return this({type:"notify",title:"通知",content:t,blur:!0,from:{right:"-300px",top:0},to:{right:0}})},toast(t,e="info"){var s=e;switch(e){case"info":case"warn":break;case"error":s="deny";break;case"success":s="get";break;default:s="info"}return this({content:`\n
\n \n ${t}\n
`,type:"toast"})}}),window.layer=_layer;export default _layer; +import"../form/input.js";import Drag from"../drag/core.js";import $ from"../utils.js";const LANGUAGES={en:{TITLE:"Dialog",BTNS:["Cancel","OK"]},zh:{TITLE:"提示",BTNS:["取消","确定"]}};LANGUAGES["zh-CN"]=LANGUAGES.zh;const lang=LANGUAGES[window.__ENV_LANG__||navigator.language]||LANGUAGES.en;let uniqueInstance=null,toastInstance=null;const UNIQUE_TYPES=["alert","confirm","prompt"];function renderBtns(t){var e="";return t.forEach((t,o)=>{e+=``}),e}export default class Layer extends HTMLElement{static get observedAttributes(){return["left","right","top","bottom","from","to","btns","type","title","blur","background","mask","radius","'mask-close'","'mask-color'","fixed"]}props={left:"auto",right:"auto",top:"auto",bottom:"auto",from:Object.create(null),to:Object.create(null),btns:[],type:"",title:"",blur:!1,background:null,mask:!1,radius:null,"mask-close":!1,"mask-color":null,fixed:!0};constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML='
',this.__TITLE__=this.root.children[1].firstElementChild,this.__BODY__=this.root.children[1].children[1],this.__CTRL__=this.root.children[1].lastElementChild,this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}set title(t){this.props.title=t,t?(this.__TITLE__.firstElementChild?this.__TITLE__.insertBefore(document.createTextNode(t),this.__TITLE__.firstElementChild):this.__TITLE__.textContent=t,this.__TITLE__.style.display="flex"):this.__TITLE__.style.display=""}set type(t){var{btns:e}=this.props;if(t&&!this._handleBtnClick){switch(t){case"alert":for(;e.length>1;)e.splice(0,1);break;case"confirm":case"prompt":for(;e.length>2;)e.splice(0,1);break;case"toast":case"notify":case"frame":if("notify"===t){var o=document.createElement("wc-icon");o.setAttribute("is","close"),this.__TITLE__.appendChild(o)}e=[];break;default:t="common"}this.props.type=t,e.length?(this.__CTRL__.innerHTML=renderBtns(e),this.__CTRL__.style.display="flex"):this.__CTRL__.style.display="",this.setAttribute(t,"")}}set fixed(t){this.props.fixed=!!t,this._updateFixedStat()}_updateFixedStat(){UNIQUE_TYPES.includes(this.props.type)||(this.props.fixed?this._dragIns&&(this._dragIns.destroy(),this._dragIns=null):(this._dragIns=new Drag(this.root.children[1]).by(this.__TITLE__,{overflow:!!this.props.hasOwnProperty("overflow")&&this.props.overflow}),this.removeAttribute("fixed")))}_intercept(t){this.props.intercept?this.props.intercept(t,e=>{delete this.props.intercept,this.resolve(t),this.close()}):(this.resolve(t),this.close())}close(t){if(!1===this.wrapped)if(this._dragIns&&this._dragIns.destroy(),UNIQUE_TYPES.includes(this.props.type)&&(uniqueInstance=null),delete this.promise,$.unbind(this.__CTRL__,"click",this._handleBtnClick),this.props.from&&!t){let t="opacity:0;";for(let e in this.props.from)t+=`${e}:${this.props.from[e]};`;this.root.children[1].style.cssText+=t,this.timer=setTimeout(()=>{this.parentNode.removeChild(this),this.dispatchEvent(new CustomEvent("close"))},200)}else clearTimeout(this.timer),this.parentNode.removeChild(this),this.dispatchEvent(new CustomEvent("close"));else this.removeAttribute("common"),this.dispatchEvent(new CustomEvent("close"))}show(){!1!==this.wrapped&&this.setAttribute("common","")}moveTo(t={}){var e="";for(var o in t)e+=`${o}:${t[o]};`;this.root.children[1].style.cssText+=e}connectedCallback(){this.type=this.props.type,this.title=this.props.title,this._handleBtnClick=$.bind(this.__CTRL__,"click",t=>{if("BUTTON"===t.target.tagName){var e=+t.target.dataset.idx,{type:o}=this.props;switch(o){case"alert":this.resolve(),this.close();break;case"confirm":case"prompt":if(0===e)this.reject(),this.close();else{let t="prompt"===o?this.__INPUT__.value:null;this._intercept(t)}break;default:this._intercept(e)}}}),"prompt"===this.props.type&&(this.__INPUT__=this.__BODY__.firstElementChild.assignedNodes().pop(),this._handleSubmit=$.bind(this.__INPUT__,"submit",t=>{this._intercept(t.detail)})),this.props.mask&&this.setAttribute("mask",""),this._updateFixedStat(),this.props.mask&&(this._handlMask=$.outside(this.root.children[1],t=>{t.target===this&&(this.props["mask-close"]?(!1===this.wrapped&&this.reject(null),this.close()):UNIQUE_TYPES.includes(this.props.type)&&(this.root.children[1].classList.toggle("scale",!0),setTimeout(t=>{this.root.children[1].classList.remove("scale")},100)))}),this.props["mask-color"]&&(this.style.backgroundColor=this.props["mask-color"])),this.props.blur&&this.root.children[1].classList.toggle("blur",!0);let t=this.props.from?"":"opacity:1;";if(this.props.background&&(t+=`background: ${this.props.background};`),(this.props.radius||0===this.props.radius)&&(t+=`border-radius: ${this.props.radius};`),this.props.size)for(let e in this.props.size)t+=`${e}:${this.props.size[e]};`;if(this.props.from){for(let e in this.props.from)t+=`${e}:${this.props.from[e]};`;setTimeout(t=>{let e="opacity:1;";for(let t in this.props.to)e+=`${t}:${this.props.to[t]};`;this.root.children[1].style.cssText+=e},50)}t&&(this.root.children[1].style.cssText+=t),"toast"===this.props.type&&(this.timer=setTimeout(()=>{toastInstance=null,this.close()},3e3)),"notify"===this.props.type&&(this._handleClose=$.bind(this.__TITLE__,"click",t=>{"WC-ICON"===t.target.tagName&&this.close()}))}disconnectedCallback(){$.clearOutside(this._handlMask),$.unbind(this.__TITLE__,"click",this._handleClose)}attributeChangedCallback(t,e,o){if(null!==o&&e!==o)switch(t){case"title":case"type":this[t]=o,this.removeAttribute(t);break;case"mask-color":case"background":this.props[t]=o;break;case"mask":case"mask-close":case"blur":this.props[t]=!0;break;case"radius":this.props.radius=o;break;case"left":case"right":case"top":case"bottom":this.props.from[t]=o,this.props.to=this.props.from,this.removeAttribute(t);break;case"fixed":this.fixed=!0}}}function _layer(t){var e=document.createElement("wc-layer");if(t.type||(t.type="common"),"toast"===t.type){var{type:o,content:r}=t;t={type:o,content:r,from:{top:0},to:{top:"30px"}},toastInstance&&toastInstance.close(!0),toastInstance=e}else e.props.mask=t.mask,!1===t.btns?e.props.btns=[]:t.btns&&t.btns.length?e.props.btns=t.btns:e.props.btns=lang.BTNS.concat(),t.intercept&&"function"==typeof t.intercept&&(e.props.intercept=t.intercept),e.props.mask=t.mask,e.props["mask-close"]=t["mask-close"],t.hasOwnProperty("overflow")&&(e.props.overflow=t.overflow),e.props["mask-color"]=t["mask-color"],e.props.blur=t.blur,e.props.radius=t.radius,e.props.background=t.background,t.size&&"object"==typeof t.size&&(e.props.size=t.size),UNIQUE_TYPES.includes(t.type)&&(uniqueInstance&&uniqueInstance.close(!0),uniqueInstance=e);return t.to&&"object"==typeof t.to&&(e.props.to=t.to,t.from&&"object"==typeof t.from?e.props.from=t.from:e.props.from=t.to),e.props.type=t.type,e.props.title=t.title,t.hasOwnProperty("fixed")&&(e.props.fixed=t.fixed),e.innerHTML=t.content,e.wrapped=!1,document.body.appendChild(e),e.promise}Object.assign(_layer,{alert(t,e=lang.TITLE){return this({type:"alert",title:e,content:t,mask:!0})},confirm(t,e=lang.TITLE,o){return"function"==typeof e&&(o=e,e=lang.TITLE),this({type:"confirm",title:e,content:t,mask:!0,intercept:o})},prompt(t=lang.TITLE,e){return this({type:"prompt",title:t,content:'',mask:!0,intercept:e})},frame(t,e={}){return this({...e,type:"frame",content:``,mask:!0,"mask-close":!0})},notify(t){return this({type:"notify",title:"通知",content:t,blur:!0,from:{right:"-300px",top:0},to:{right:0}})},toast(t,e="info"){var o=e;switch(e){case"info":case"warn":break;case"error":o="deny";break;case"success":o="get";break;default:o="info"}return this({content:`\n
\n \n ${t}\n
`,type:"toast"})}}),window.layer=_layer; if(!customElements.get('wc-layer')){ customElements.define('wc-layer', Layer) diff --git a/src/lib/md5.js b/src/lib/md5.js new file mode 100644 index 0000000..04bd4ef --- /dev/null +++ b/src/lib/md5.js @@ -0,0 +1,764 @@ +/* + * Fastest md5 implementation around (JKM md5). + * Credits: Joseph Myers + * + * @see http://www.myersdaily.org/joseph/javascript/md5-text.html + * @see http://jsperf.com/md5-shootout/7 + */ + +/* this function is much faster, + so if possible we use it. Some IEs + are the only ones I know of that + need the idiotic second function, + generated by an if clause. */ +var add32 = function(a, b) { + return (a + b) & 0xffffffff + }, + hex_chr = [ + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + 'a', + 'b', + 'c', + 'd', + 'e', + 'f' + ] + +function cmn(q, a, b, x, s, t) { + a = add32(add32(a, q), add32(x, t)) + return add32((a << s) | (a >>> (32 - s)), b) +} + +function md5cycle(x, k) { + var a = x[0], + b = x[1], + c = x[2], + d = x[3] + + a += (((b & c) | (~b & d)) + k[0] - 680876936) | 0 + a = (((a << 7) | (a >>> 25)) + b) | 0 + d += (((a & b) | (~a & c)) + k[1] - 389564586) | 0 + d = (((d << 12) | (d >>> 20)) + a) | 0 + c += (((d & a) | (~d & b)) + k[2] + 606105819) | 0 + c = (((c << 17) | (c >>> 15)) + d) | 0 + b += (((c & d) | (~c & a)) + k[3] - 1044525330) | 0 + b = (((b << 22) | (b >>> 10)) + c) | 0 + a += (((b & c) | (~b & d)) + k[4] - 176418897) | 0 + a = (((a << 7) | (a >>> 25)) + b) | 0 + d += (((a & b) | (~a & c)) + k[5] + 1200080426) | 0 + d = (((d << 12) | (d >>> 20)) + a) | 0 + c += (((d & a) | (~d & b)) + k[6] - 1473231341) | 0 + c = (((c << 17) | (c >>> 15)) + d) | 0 + b += (((c & d) | (~c & a)) + k[7] - 45705983) | 0 + b = (((b << 22) | (b >>> 10)) + c) | 0 + a += (((b & c) | (~b & d)) + k[8] + 1770035416) | 0 + a = (((a << 7) | (a >>> 25)) + b) | 0 + d += (((a & b) | (~a & c)) + k[9] - 1958414417) | 0 + d = (((d << 12) | (d >>> 20)) + a) | 0 + c += (((d & a) | (~d & b)) + k[10] - 42063) | 0 + c = (((c << 17) | (c >>> 15)) + d) | 0 + b += (((c & d) | (~c & a)) + k[11] - 1990404162) | 0 + b = (((b << 22) | (b >>> 10)) + c) | 0 + a += (((b & c) | (~b & d)) + k[12] + 1804603682) | 0 + a = (((a << 7) | (a >>> 25)) + b) | 0 + d += (((a & b) | (~a & c)) + k[13] - 40341101) | 0 + d = (((d << 12) | (d >>> 20)) + a) | 0 + c += (((d & a) | (~d & b)) + k[14] - 1502002290) | 0 + c = (((c << 17) | (c >>> 15)) + d) | 0 + b += (((c & d) | (~c & a)) + k[15] + 1236535329) | 0 + b = (((b << 22) | (b >>> 10)) + c) | 0 + + a += (((b & d) | (c & ~d)) + k[1] - 165796510) | 0 + a = (((a << 5) | (a >>> 27)) + b) | 0 + d += (((a & c) | (b & ~c)) + k[6] - 1069501632) | 0 + d = (((d << 9) | (d >>> 23)) + a) | 0 + c += (((d & b) | (a & ~b)) + k[11] + 643717713) | 0 + c = (((c << 14) | (c >>> 18)) + d) | 0 + b += (((c & a) | (d & ~a)) + k[0] - 373897302) | 0 + b = (((b << 20) | (b >>> 12)) + c) | 0 + a += (((b & d) | (c & ~d)) + k[5] - 701558691) | 0 + a = (((a << 5) | (a >>> 27)) + b) | 0 + d += (((a & c) | (b & ~c)) + k[10] + 38016083) | 0 + d = (((d << 9) | (d >>> 23)) + a) | 0 + c += (((d & b) | (a & ~b)) + k[15] - 660478335) | 0 + c = (((c << 14) | (c >>> 18)) + d) | 0 + b += (((c & a) | (d & ~a)) + k[4] - 405537848) | 0 + b = (((b << 20) | (b >>> 12)) + c) | 0 + a += (((b & d) | (c & ~d)) + k[9] + 568446438) | 0 + a = (((a << 5) | (a >>> 27)) + b) | 0 + d += (((a & c) | (b & ~c)) + k[14] - 1019803690) | 0 + d = (((d << 9) | (d >>> 23)) + a) | 0 + c += (((d & b) | (a & ~b)) + k[3] - 187363961) | 0 + c = (((c << 14) | (c >>> 18)) + d) | 0 + b += (((c & a) | (d & ~a)) + k[8] + 1163531501) | 0 + b = (((b << 20) | (b >>> 12)) + c) | 0 + a += (((b & d) | (c & ~d)) + k[13] - 1444681467) | 0 + a = (((a << 5) | (a >>> 27)) + b) | 0 + d += (((a & c) | (b & ~c)) + k[2] - 51403784) | 0 + d = (((d << 9) | (d >>> 23)) + a) | 0 + c += (((d & b) | (a & ~b)) + k[7] + 1735328473) | 0 + c = (((c << 14) | (c >>> 18)) + d) | 0 + b += (((c & a) | (d & ~a)) + k[12] - 1926607734) | 0 + b = (((b << 20) | (b >>> 12)) + c) | 0 + + a += ((b ^ c ^ d) + k[5] - 378558) | 0 + a = (((a << 4) | (a >>> 28)) + b) | 0 + d += ((a ^ b ^ c) + k[8] - 2022574463) | 0 + d = (((d << 11) | (d >>> 21)) + a) | 0 + c += ((d ^ a ^ b) + k[11] + 1839030562) | 0 + c = (((c << 16) | (c >>> 16)) + d) | 0 + b += ((c ^ d ^ a) + k[14] - 35309556) | 0 + b = (((b << 23) | (b >>> 9)) + c) | 0 + a += ((b ^ c ^ d) + k[1] - 1530992060) | 0 + a = (((a << 4) | (a >>> 28)) + b) | 0 + d += ((a ^ b ^ c) + k[4] + 1272893353) | 0 + d = (((d << 11) | (d >>> 21)) + a) | 0 + c += ((d ^ a ^ b) + k[7] - 155497632) | 0 + c = (((c << 16) | (c >>> 16)) + d) | 0 + b += ((c ^ d ^ a) + k[10] - 1094730640) | 0 + b = (((b << 23) | (b >>> 9)) + c) | 0 + a += ((b ^ c ^ d) + k[13] + 681279174) | 0 + a = (((a << 4) | (a >>> 28)) + b) | 0 + d += ((a ^ b ^ c) + k[0] - 358537222) | 0 + d = (((d << 11) | (d >>> 21)) + a) | 0 + c += ((d ^ a ^ b) + k[3] - 722521979) | 0 + c = (((c << 16) | (c >>> 16)) + d) | 0 + b += ((c ^ d ^ a) + k[6] + 76029189) | 0 + b = (((b << 23) | (b >>> 9)) + c) | 0 + a += ((b ^ c ^ d) + k[9] - 640364487) | 0 + a = (((a << 4) | (a >>> 28)) + b) | 0 + d += ((a ^ b ^ c) + k[12] - 421815835) | 0 + d = (((d << 11) | (d >>> 21)) + a) | 0 + c += ((d ^ a ^ b) + k[15] + 530742520) | 0 + c = (((c << 16) | (c >>> 16)) + d) | 0 + b += ((c ^ d ^ a) + k[2] - 995338651) | 0 + b = (((b << 23) | (b >>> 9)) + c) | 0 + + a += ((c ^ (b | ~d)) + k[0] - 198630844) | 0 + a = (((a << 6) | (a >>> 26)) + b) | 0 + d += ((b ^ (a | ~c)) + k[7] + 1126891415) | 0 + d = (((d << 10) | (d >>> 22)) + a) | 0 + c += ((a ^ (d | ~b)) + k[14] - 1416354905) | 0 + c = (((c << 15) | (c >>> 17)) + d) | 0 + b += ((d ^ (c | ~a)) + k[5] - 57434055) | 0 + b = (((b << 21) | (b >>> 11)) + c) | 0 + a += ((c ^ (b | ~d)) + k[12] + 1700485571) | 0 + a = (((a << 6) | (a >>> 26)) + b) | 0 + d += ((b ^ (a | ~c)) + k[3] - 1894986606) | 0 + d = (((d << 10) | (d >>> 22)) + a) | 0 + c += ((a ^ (d | ~b)) + k[10] - 1051523) | 0 + c = (((c << 15) | (c >>> 17)) + d) | 0 + b += ((d ^ (c | ~a)) + k[1] - 2054922799) | 0 + b = (((b << 21) | (b >>> 11)) + c) | 0 + a += ((c ^ (b | ~d)) + k[8] + 1873313359) | 0 + a = (((a << 6) | (a >>> 26)) + b) | 0 + d += ((b ^ (a | ~c)) + k[15] - 30611744) | 0 + d = (((d << 10) | (d >>> 22)) + a) | 0 + c += ((a ^ (d | ~b)) + k[6] - 1560198380) | 0 + c = (((c << 15) | (c >>> 17)) + d) | 0 + b += ((d ^ (c | ~a)) + k[13] + 1309151649) | 0 + b = (((b << 21) | (b >>> 11)) + c) | 0 + a += ((c ^ (b | ~d)) + k[4] - 145523070) | 0 + a = (((a << 6) | (a >>> 26)) + b) | 0 + d += ((b ^ (a | ~c)) + k[11] - 1120210379) | 0 + d = (((d << 10) | (d >>> 22)) + a) | 0 + c += ((a ^ (d | ~b)) + k[2] + 718787259) | 0 + c = (((c << 15) | (c >>> 17)) + d) | 0 + b += ((d ^ (c | ~a)) + k[9] - 343485551) | 0 + b = (((b << 21) | (b >>> 11)) + c) | 0 + + x[0] = (a + x[0]) | 0 + x[1] = (b + x[1]) | 0 + x[2] = (c + x[2]) | 0 + x[3] = (d + x[3]) | 0 +} + +function md5blk(s) { + var md5blks = [], + i /* Andy King said do it this way. */ + + for (i = 0; i < 64; i += 4) { + md5blks[i >> 2] = + s.charCodeAt(i) + + (s.charCodeAt(i + 1) << 8) + + (s.charCodeAt(i + 2) << 16) + + (s.charCodeAt(i + 3) << 24) + } + return md5blks +} + +function md5blk_array(a) { + var md5blks = [], + i /* Andy King said do it this way. */ + + for (i = 0; i < 64; i += 4) { + md5blks[i >> 2] = + a[i] + (a[i + 1] << 8) + (a[i + 2] << 16) + (a[i + 3] << 24) + } + return md5blks +} + +function md51(s) { + var n = s.length, + state = [1732584193, -271733879, -1732584194, 271733878], + i, + length, + tail, + tmp, + lo, + hi + + for (i = 64; i <= n; i += 64) { + md5cycle(state, md5blk(s.substring(i - 64, i))) + } + s = s.substring(i - 64) + length = s.length + tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + for (i = 0; i < length; i += 1) { + tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3) + } + tail[i >> 2] |= 0x80 << (i % 4 << 3) + if (i > 55) { + md5cycle(state, tail) + for (i = 0; i < 16; i += 1) { + tail[i] = 0 + } + } + + // Beware that the final length might not fit in 32 bits so we take care of that + tmp = n * 8 + tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/) + lo = parseInt(tmp[2], 16) + hi = parseInt(tmp[1], 16) || 0 + + tail[14] = lo + tail[15] = hi + + md5cycle(state, tail) + return state +} + +function md51_array(a) { + var n = a.length, + state = [1732584193, -271733879, -1732584194, 271733878], + i, + length, + tail, + tmp, + lo, + hi + + for (i = 64; i <= n; i += 64) { + md5cycle(state, md5blk_array(a.subarray(i - 64, i))) + } + + // Not sure if it is a bug, however IE10 will always produce a sub array of length 1 + // containing the last element of the parent array if the sub array specified starts + // beyond the length of the parent array - weird. + // https://connect.microsoft.com/IE/feedback/details/771452/typed-array-subarray-issue + a = i - 64 < n ? a.subarray(i - 64) : new Uint8Array(0) + + length = a.length + tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + for (i = 0; i < length; i += 1) { + tail[i >> 2] |= a[i] << (i % 4 << 3) + } + + tail[i >> 2] |= 0x80 << (i % 4 << 3) + if (i > 55) { + md5cycle(state, tail) + for (i = 0; i < 16; i += 1) { + tail[i] = 0 + } + } + + // Beware that the final length might not fit in 32 bits so we take care of that + tmp = n * 8 + tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/) + lo = parseInt(tmp[2], 16) + hi = parseInt(tmp[1], 16) || 0 + + tail[14] = lo + tail[15] = hi + + md5cycle(state, tail) + + return state +} + +function rhex(n) { + var s = '', + j + for (j = 0; j < 4; j += 1) { + s += hex_chr[(n >> (j * 8 + 4)) & 0x0f] + hex_chr[(n >> (j * 8)) & 0x0f] + } + return s +} + +function hex(x) { + var i + for (i = 0; i < x.length; i += 1) { + x[i] = rhex(x[i]) + } + return x.join('') +} + +// In some cases the fast add32 function cannot be used.. +if (hex(md51('hello')) !== '5d41402abc4b2a76b9719d911017c592') { + add32 = function(x, y) { + var lsw = (x & 0xffff) + (y & 0xffff), + msw = (x >> 16) + (y >> 16) + (lsw >> 16) + return (msw << 16) | (lsw & 0xffff) + } +} + +// --------------------------------------------------- + +/** + * ArrayBuffer slice polyfill. + * + * @see https://github.com/ttaubert/node-arraybuffer-slice + */ + +if (typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) { + ;(function() { + function clamp(val, length) { + val = val | 0 || 0 + + if (val < 0) { + return Math.max(val + length, 0) + } + + return Math.min(val, length) + } + + ArrayBuffer.prototype.slice = function(from, to) { + var length = this.byteLength, + begin = clamp(from, length), + end = length, + num, + target, + targetArray, + sourceArray + + if (to !== undefined) { + end = clamp(to, length) + } + + if (begin > end) { + return new ArrayBuffer(0) + } + + num = end - begin + target = new ArrayBuffer(num) + targetArray = new Uint8Array(target) + + sourceArray = new Uint8Array(this, begin, num) + targetArray.set(sourceArray) + + return target + } + })() +} + +// --------------------------------------------------- + +/** + * Helpers. + */ + +function toUtf8(str) { + str += '' + if (/[\u0080-\uFFFF]/.test(str)) { + str = unescape(encodeURIComponent(str)) + } + + return str +} + +function utf8Str2ArrayBuffer(str, returnUInt8Array) { + var length = str.length, + buff = new ArrayBuffer(length), + arr = new Uint8Array(buff), + i + + for (i = 0; i < length; i += 1) { + arr[i] = str.charCodeAt(i) + } + + return returnUInt8Array ? arr : buff +} + +function arrayBuffer2Utf8Str(buff) { + return String.fromCharCode.apply(null, new Uint8Array(buff)) +} + +function concatenateArrayBuffers(first, second, returnUInt8Array) { + var result = new Uint8Array(first.byteLength + second.byteLength) + + result.set(new Uint8Array(first)) + result.set(new Uint8Array(second), first.byteLength) + + return returnUInt8Array ? result : result.buffer +} + +function hexToBinaryString(hex) { + var bytes = [], + length = hex.length, + x + + for (x = 0; x < length - 1; x += 2) { + bytes.push(parseInt(hex.substr(x, 2), 16)) + } + + return String.fromCharCode.apply(String, bytes) +} + +// --------------------------------------------------- + +/** + * SparkMD5 OOP implementation. + * + * Use this class to perform an incremental md5, otherwise use the + * static methods instead. + */ + +function SparkMD5() { + // call reset to init the instance + this.reset() +} + +/** + * Appends a string. + * A conversion will be applied if an utf8 string is detected. + * + * @param {String} str The string to be appended + * + * @return {SparkMD5} The instance itself + */ +SparkMD5.prototype.append = function(str) { + // Converts the string to utf8 bytes if necessary + // Then append as binary + this.appendBinary(toUtf8(str)) + + return this +} + +/** + * Appends a binary string. + * + * @param {String} contents The binary string to be appended + * + * @return {SparkMD5} The instance itself + */ +SparkMD5.prototype.appendBinary = function(contents) { + this._buff += contents + this._length += contents.length + + var length = this._buff.length, + i + + for (i = 64; i <= length; i += 64) { + md5cycle(this._hash, md5blk(this._buff.substring(i - 64, i))) + } + + this._buff = this._buff.substring(i - 64) + + return this +} + +/** + * Finishes the incremental computation, reseting the internal state and + * returning the result. + * + * @param {Boolean} raw True to get the raw string, false to get the hex string + * + * @return {String} The result + */ +SparkMD5.prototype.end = function(raw) { + var buff = this._buff, + length = buff.length, + i, + tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + ret + + for (i = 0; i < length; i += 1) { + tail[i >> 2] |= buff.charCodeAt(i) << (i % 4 << 3) + } + + this._finish(tail, length) + ret = hex(this._hash) + + if (raw) { + ret = hexToBinaryString(ret) + } + + this.reset() + + return ret +} + +/** + * Resets the internal state of the computation. + * + * @return {SparkMD5} The instance itself + */ +SparkMD5.prototype.reset = function() { + this._buff = '' + this._length = 0 + this._hash = [1732584193, -271733879, -1732584194, 271733878] + + return this +} + +/** + * Gets the internal state of the computation. + * + * @return {Object} The state + */ +SparkMD5.prototype.getState = function() { + return { + buff: this._buff, + length: this._length, + hash: this._hash + } +} + +/** + * Gets the internal state of the computation. + * + * @param {Object} state The state + * + * @return {SparkMD5} The instance itself + */ +SparkMD5.prototype.setState = function(state) { + this._buff = state.buff + this._length = state.length + this._hash = state.hash + + return this +} + +/** + * Releases memory used by the incremental buffer and other additional + * resources. If you plan to use the instance again, use reset instead. + */ +SparkMD5.prototype.destroy = function() { + delete this._hash + delete this._buff + delete this._length +} + +/** + * Finish the final calculation based on the tail. + * + * @param {Array} tail The tail (will be modified) + * @param {Number} length The length of the remaining buffer + */ +SparkMD5.prototype._finish = function(tail, length) { + var i = length, + tmp, + lo, + hi + + tail[i >> 2] |= 0x80 << (i % 4 << 3) + if (i > 55) { + md5cycle(this._hash, tail) + for (i = 0; i < 16; i += 1) { + tail[i] = 0 + } + } + + // Do the final computation based on the tail and length + // Beware that the final length may not fit in 32 bits so we take care of that + tmp = this._length * 8 + tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/) + lo = parseInt(tmp[2], 16) + hi = parseInt(tmp[1], 16) || 0 + + tail[14] = lo + tail[15] = hi + md5cycle(this._hash, tail) +} + +/** + * Performs the md5 hash on a string. + * A conversion will be applied if utf8 string is detected. + * + * @param {String} str The string + * @param {Boolean} [raw] True to get the raw string, false to get the hex string + * + * @return {String} The result + */ +SparkMD5.hash = function(str, raw) { + // Converts the string to utf8 bytes if necessary + // Then compute it using the binary function + return SparkMD5.hashBinary(toUtf8(str), raw) +} + +/** + * Performs the md5 hash on a binary string. + * + * @param {String} content The binary string + * @param {Boolean} [raw] True to get the raw string, false to get the hex string + * + * @return {String} The result + */ +SparkMD5.hashBinary = function(content, raw) { + var hash = md51(content), + ret = hex(hash) + + return raw ? hexToBinaryString(ret) : ret +} + +// --------------------------------------------------- + +/** + * SparkMD5 OOP implementation for array buffers. + * + * Use this class to perform an incremental md5 ONLY for array buffers. + */ +SparkMD5.ArrayBuffer = function() { + // call reset to init the instance + this.reset() +} + +/** + * Appends an array buffer. + * + * @param {ArrayBuffer} arr The array to be appended + * + * @return {SparkMD5.ArrayBuffer} The instance itself + */ +SparkMD5.ArrayBuffer.prototype.append = function(arr) { + var buff = concatenateArrayBuffers(this._buff.buffer, arr, true), + length = buff.length, + i + + this._length += arr.byteLength + + for (i = 64; i <= length; i += 64) { + md5cycle(this._hash, md5blk_array(buff.subarray(i - 64, i))) + } + + this._buff = + i - 64 < length + ? new Uint8Array(buff.buffer.slice(i - 64)) + : new Uint8Array(0) + + return this +} + +/** + * Finishes the incremental computation, reseting the internal state and + * returning the result. + * + * @param {Boolean} raw True to get the raw string, false to get the hex string + * + * @return {String} The result + */ +SparkMD5.ArrayBuffer.prototype.end = function(raw) { + var buff = this._buff, + length = buff.length, + tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + i, + ret + + for (i = 0; i < length; i += 1) { + tail[i >> 2] |= buff[i] << (i % 4 << 3) + } + + this._finish(tail, length) + ret = hex(this._hash) + + if (raw) { + ret = hexToBinaryString(ret) + } + + this.reset() + + return ret +} + +/** + * Resets the internal state of the computation. + * + * @return {SparkMD5.ArrayBuffer} The instance itself + */ +SparkMD5.ArrayBuffer.prototype.reset = function() { + this._buff = new Uint8Array(0) + this._length = 0 + this._hash = [1732584193, -271733879, -1732584194, 271733878] + + return this +} + +/** + * Gets the internal state of the computation. + * + * @return {Object} The state + */ +SparkMD5.ArrayBuffer.prototype.getState = function() { + var state = SparkMD5.prototype.getState.call(this) + + // Convert buffer to a string + state.buff = arrayBuffer2Utf8Str(state.buff) + + return state +} + +/** + * Gets the internal state of the computation. + * + * @param {Object} state The state + * + * @return {SparkMD5.ArrayBuffer} The instance itself + */ +SparkMD5.ArrayBuffer.prototype.setState = function(state) { + // Convert string to buffer + state.buff = utf8Str2ArrayBuffer(state.buff, true) + + return SparkMD5.prototype.setState.call(this, state) +} + +SparkMD5.ArrayBuffer.prototype.destroy = SparkMD5.prototype.destroy + +SparkMD5.ArrayBuffer.prototype._finish = SparkMD5.prototype._finish + +/** + * Performs the md5 hash on an array buffer. + * + * @param {ArrayBuffer} arr The array buffer + * @param {Boolean} [raw] True to get the raw string, false to get the hex one + * + * @return {String} The result + */ +SparkMD5.ArrayBuffer.hash = function(arr, raw) { + var hash = md51_array(new Uint8Array(arr)), + ret = hex(hash) + + return raw ? hexToBinaryString(ret) : ret +} + +var _sparkIns = new SparkMD5() + +export function md5(str) { + _sparkIns.append(str) + return _sparkIns.end() +} + +export function md5Sum(binStr) { + _sparkIns.appendBinary(binStr) + return _sparkIns.end() +} + +export default _sparkIns diff --git a/src/lib/scroll/index.js b/src/lib/scroll/index.js index d73c9d8..cc153f0 100644 --- a/src/lib/scroll/index.js +++ b/src/lib/scroll/index.js @@ -1,14 +1,12 @@ /** - * - * @authors yutent (yutent@doui.cc) - * @date 2020-07-07 10:57:15 - * @version v2.0.1 - * - */ + * + * @authors yutent (yutent.io@gmail.com) + * @date 2020-12-23 15:31:02 + * @version v1.0.0 + * + */ -'use strict' - -import $ from"../utils.js";const IS_FF=!!window.sidebar;export default class Scroll extends HTMLElement{static get observedAttributes(){return["thumbX","thumbY","disabled","axis"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{thumbX:0,thumbY:0,disabled:!1,axis:"xy"},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML='
',this.__BOX__=this.root.children[1],this.__X__=this.root.children[2].children[0],this.__Y__=this.root.children[3].children[0]}get scrollTop(){return this.__BOX__.scrollTop}set scrollTop(t){if((t=+t)==t){var{sh:s,oh:i,yh:e}=this.props;this.__BOX__.scrollTop=t;var o=this.__BOX__.scrollTop/(s-i)*(i-e);this.props.thumbY=o,this.__Y__.style.transform=`translateY(${o}px)`}}get scrollLeft(){return this.__BOX__.scrollLeft}set scrollLeft(t){if((t=+t)==t){var{sw:s,ow:i,xw:e}=this.props;this.__BOX__.scrollLeft=t;var o=this.__BOX__.scrollLeft/(s-i)*(i-e);this.props.thumbX=o,this.__X__.style.transform=`translateX(${o}px)`}}get scrollHeight(){return this.__BOX__.scrollHeight}get disabled(){return this.props.disabled}set disabled(t){var s=typeof t;t!==this.props.disabled&&("boolean"===s&&t||"boolean"!==s?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}_fetchScrollX(t){var{sw:s,ow:i,xw:e}=this.props;return t<0?t=0:t>i-e&&(t=i-e),this.__BOX__.scrollLeft=t/(i-e)*(s-i),this.__X__.style.transform=`translateX(${t}px)`,t}_fetchScrollY(t){var{sh:s,oh:i,yh:e}=this.props;return t<0?t=0:t>i-e&&(t=i-e),this.__BOX__.scrollTop=t/(i-e)*(s-i),this.__Y__.style.transform=`translateY(${t}px)`,t}connectedCallback(){this._initFn=$.bind(this.__BOX__,"mouseenter",t=>{if(!this.disabled){var s=this.__BOX__.offsetWidth,i=this.__BOX__.scrollWidth,e=this.__BOX__.offsetHeight,o=this.__BOX__.scrollHeight,h=e*e/o>>0,r=s*s/i>>0;h<50&&(h=50),r<50&&(r=50),r===s&&(r=0),h===e&&(h=0),this.props.oh=e,this.props.sh=o,this.props.ow=s,this.props.sw=i,this.props.yh=h,this.props.xw=r,this.__X__.style.width=r+"px",this.__Y__.style.height=h+"px"}}),this._wheelFn=$.bind(this.__BOX__,"wheel",t=>{if(!this.disabled){var{sh:s,oh:i,yh:e,sw:o,ow:h,xw:r}=this.props;if(r||e){var l,a,_=Date.now();if((!this.stamp||_-this.stamp>800)&&(this.stamp=_,this.times=1),IS_FF)l=t.deltaMode?10*t.deltaX:t.deltaX,a=t.deltaMode?10*t.deltaY:t.deltaY;else{var n=Math.abs(t.wheelDelta);n<120?(l=t.deltaX,a=t.deltaY):(l=t.deltaX/(n/120),a=t.deltaY/(n/120))}if(_-this.stamp<20&&(this.times+=.05,this.times>3&&(this.times=3)),l*=this.times,a*=this.times,"x"!==this.props.axis&&(this.__BOX__.scrollTop+=a,e)){var p=this.__BOX__.scrollTop/(s-i)*(i-e);if((0===(p>>=0)||i-e===p)&&p===this.props.thumbY)return;t.preventDefault(),t.stopPropagation(),this.props.thumbY=p,this.__Y__.style.transform=`translateY(${p}px)`}if("y"!==this.props.axis&&(this.__BOX__.scrollLeft+=l,r)){var d=this.__BOX__.scrollLeft/(o-h)*(h-r);if((0===(d>>=0)||h-r===d)&&d===this.props.thumbX)return;t.preventDefault(),t.stopPropagation(),this.props.thumbX=d,this.__X__.style.transform=`translateX(${d}px)`}this.stamp=_,this.dispatchEvent(new CustomEvent("scroll",{detail:{x:this.props.thumbX,y:this.props.thumbY}}))}}});var t,s,i,e,o=o=>{var{thumbY:h,thumbX:r}=this.props;null!==t&&(i=this._fetchScrollX(r+o.pageX-t)),null!==s&&(e=this._fetchScrollY(h+o.pageY-s))},h=r=>{t=null,s=null,this.props.thumbX=i,this.props.thumbY=e,$.unbind(document,"mousemove",o),$.unbind(document,"mouseup",h)};$.bind(this.__Y__,"mousedown",t=>{s=t.pageY,this.props.thumbY||(this.props.thumbY=0),this.disabled||($.bind(document,"mousemove",o),$.bind(document,"mouseup",h))}),$.bind(this.__X__,"mousedown",s=>{t=s.pageX,this.props.thumbX||(this.props.thumbX=0),this.disabled||($.bind(document,"mousemove",o),$.bind(document,"mouseup",h))}),this.__observer=new MutationObserver(this._initFn),this.__observer.observe(this,{childList:!0,subtree:!0,characterData:!0})}disconnectedCallback(){this.__observer.disconnect(),$.unbind(this.__BOX__,"mouseenter",this._initFn),$.unbind(this.__BOX__,"wheel",this._wheelFn)}attributeChangedCallback(t,s,i){if(null!==i&&s!==i)switch(t){case"axis":this.props.axis=i;break;case"disabled":this[t]=!0}}}; +import $ from"../utils.js";const IS_FF=!!window.sidebar;export default class Scroll extends HTMLElement{static get observedAttributes(){return["thumbX","thumbY","disabled","axis","delay","distance"]}props={thumbX:0,thumbY:0,disabled:!1,axis:"xy",delay:1e3,distance:1};constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML='
',this.__BOX__=this.root.children[1],this.__X__=this.root.children[2].children[0],this.__Y__=this.root.children[3].children[0],this.__last__=0}get scrollTop(){return this.__BOX__.scrollTop}set scrollTop(t){if((t=+t)==t){var{sh:s,oh:i,yh:e}=this.props;this.__BOX__.scrollTop=t;var o=this.__BOX__.scrollTop/(s-i)*(i-e);this.props.thumbY=o,this.__Y__.style.transform=`translateY(${o}px)`}}get scrollLeft(){return this.__BOX__.scrollLeft}set scrollLeft(t){if((t=+t)==t){var{sw:s,ow:i,xw:e}=this.props;this.__BOX__.scrollLeft=t;var o=this.__BOX__.scrollLeft/(s-i)*(i-e);this.props.thumbX=o,this.__X__.style.transform=`translateX(${o}px)`}}get scrollHeight(){return this.__BOX__.scrollHeight}get scrollWidth(){return this.__BOX__.scrollWidth}get disabled(){return this.props.disabled}set disabled(t){var s=typeof t;t!==this.props.disabled&&("boolean"===s&&t||"boolean"!==s?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}_fetchScrollX(t){var{sw:s,ow:i,xw:e}=this.props;return t<0?t=0:t>i-e&&(t=i-e),this.__BOX__.scrollLeft=t/(i-e)*(s-i),this.__X__.style.transform=`translateX(${t}px)`,t}_fetchScrollY(t){var{sh:s,oh:i,yh:e}=this.props;return t<0?t=0:t>i-e&&(t=i-e),this.__BOX__.scrollTop=t/(i-e)*(s-i),this.__Y__.style.transform=`translateY(${t}px)`,t}_fireReachEnd(t="reach-bottom"){var{sh:s,oh:i,delay:e,disabled:o}=this.props,r=this.__BOX__.scrollTop,h=Date.now();if(!o&&h-this.__last__>e){if("reach-bottom"===t){if(i+r0)return;this.__last__=h,this.dispatchEvent(new CustomEvent(t))}}connectedCallback(){this._initFn=$.bind(this.__BOX__,"mouseenter",t=>{if(!this.disabled){var s=this.__BOX__.offsetWidth,i=this.__BOX__.scrollWidth,e=this.__BOX__.offsetHeight,o=this.__BOX__.scrollHeight,r=e*e/o>>0,h=s*s/i>>0;r<50&&(r=50),h<50&&(h=50),h===s&&(h=0),r===e&&(r=0),this.props.oh=e,this.props.sh=o,this.props.ow=s,this.props.sw=i,this.props.yh=r,this.props.xw=h,this.__X__.style.width=h+"px",this.__Y__.style.height=r+"px"}}),this._inactiveFn=$.bind(this.__BOX__,"mouseleave",t=>{delete this._active}),this._wheelFn=$.bind(this.__BOX__,"wheel",t=>{if(!this.disabled){var{sh:s,oh:i,yh:e,sw:o,ow:r,xw:h}=this.props;if(h||e){var l,a,_=Date.now();if((!this.stamp||_-this.stamp>800)&&(this.stamp=_,this.times=1),IS_FF)l=t.deltaMode?10*t.deltaX:t.deltaX,a=t.deltaMode?10*t.deltaY:t.deltaY;else{var n=Math.abs(t.wheelDelta);n<120?(l=t.deltaX,a=t.deltaY):(l=t.deltaX/(n/120),a=t.deltaY/(n/120))}if(_-this.stamp<20&&(this.times+=.05,this.times>3&&(this.times=3)),l*=this.times,a*=this.times,"x"!==this.props.axis&&(this.__BOX__.scrollTop+=a,e)){var c=this.__BOX__.scrollTop/(s-i)*(i-e);if((0===(c>>=0)||i-e===c)&&c===this.props.thumbY)return;t.preventDefault(),t.stopPropagation(),this.props.thumbY=c,this.__Y__.style.transform=`translateY(${c}px)`,Math.abs(a)>this.props.distance&&this._fireReachEnd(a>0?"reach-bottom":"reach-top")}if("y"!==this.props.axis&&(this.__BOX__.scrollLeft+=l,h)){var p=this.__BOX__.scrollLeft/(o-r)*(r-h);if((0===(p>>=0)||r-h===p)&&p===this.props.thumbX)return;t.preventDefault(),t.stopPropagation(),this.props.thumbX=p,this.__X__.style.transform=`translateX(${p}px)`}this._active=!0,this.stamp=_,this.dispatchEvent(new CustomEvent("scroll",{detail:{x:this.props.thumbX,y:this.props.thumbY}}))}}});var t,s,i,e,o=o=>{var{thumbY:r,thumbX:h}=this.props;null!==t&&(i=this._fetchScrollX(h+o.pageX-t)),null!==s&&(this._active=!0,e=this._fetchScrollY(r+o.pageY-s))},r=h=>{Math.abs(h.pageY-s)>this.props.distance&&this._fireReachEnd(h.pageY>s?"reach-bottom":"reach-top"),t=null,s=null,this.props.thumbX=i,this.props.thumbY=e,$.unbind(document,"mousemove",o),$.unbind(document,"mouseup",r)};$.bind(this.__Y__,"mousedown",t=>{s=t.pageY,this.props.thumbY||(this.props.thumbY=0),this.disabled||($.bind(document,"mousemove",o),$.bind(document,"mouseup",r))}),$.bind(this.__X__,"mousedown",s=>{t=s.pageX,this.props.thumbX||(this.props.thumbX=0),this.disabled||($.bind(document,"mousemove",o),$.bind(document,"mouseup",r))}),$.catch(document,"keydown",t=>{if(this._active){var{oh:s,sh:i}=this.props,e=!1;switch(t.keyCode){case 33:e=!0,this.scrollTop-=s;break;case 34:e=!0,this.scrollTop+=s;break;case 35:e=!0,this.scrollTop=i;break;case 36:e=!0,this.scrollTop=0}e&&t.preventDefault()}}),this.__observer=new MutationObserver(this._initFn),this.__observer.observe(this,{childList:!0,subtree:!0,characterData:!0})}disconnectedCallback(){this.__observer.disconnect(),$.unbind(this.__BOX__,"mouseenter",this._initFn),$.unbind(this.__BOX__,"mouseleave",this._inactiveFn),$.unbind(this.__BOX__,"wheel",this._wheelFn)}attributeChangedCallback(t,s,i){if(null!==i&&s!==i)switch(t){case"axis":this.props.axis=i;break;case"disabled":this[t]=!0;break;case"delay":this.props.delay=+i||1e3;break;case"distance":this.props.distance=+i||1}}} if(!customElements.get('wc-scroll')){ customElements.define('wc-scroll', Scroll) diff --git a/src/lib/utils.js b/src/lib/utils.js index 752ccd5..5d4efdb 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -1 +1 @@ -function noop(){}export default{nextTick:function(){let t=[];let e=document.createTextNode("\x3c!-- --\x3e");new MutationObserver(function(){let e=t.length;for(let n=0;n{if(n)if(n.path){for(var i=n.path.concat();i.length>3;)if(i.shift()===t)return}else{var o=n.explicitOriginalTarget||n.target;if(t===o||t.contains(o)||t.root&&t.root.contains(o))return}e(n)})},clearOutside(t=noop){this.unbind(document,"mousedown",t)}}; \ No newline at end of file +function noop(){}export default{nextTick:function(){let t=[];let e=document.createTextNode("\x3c!-- --\x3e");new MutationObserver((function(){let e=t.length;for(let n=0;n{if(n)if(n.path){for(var i=n.path.concat();i.length>3;)if(i.shift()===t)return}else{var o=n.explicitOriginalTarget||n.target;if(t===o||t.contains(o)||t.root&&t.root.contains(o))return}e(n)})},clearOutside(t=noop){this.unbind(document,"mousedown",t)}}; \ No newline at end of file diff --git a/src/main.js b/src/main.js index c6a5ffc..c262347 100644 --- a/src/main.js +++ b/src/main.js @@ -50,9 +50,9 @@ protocol.registerSchemesAsPrivileged([ app.once('ready', () => { // 注册协议 protocol.registerStreamProtocol('app', function(req, cb) { - var file = decodeURIComponent( - req.url.replace(/^app:\/\/local\//, '') - ).replace(/\#.*$/, '') + var file = decodeURIComponent(req.url.replace(/^app:\/\/local\//, '')) + .replace(/\#.*$/, '') + .replace(/\?.*$/, '') var ext = path.extname(file) file = path.resolve(ROOT, file) @@ -71,6 +71,7 @@ app.once('ready', () => { var ext = path.extname(file) file = path.resolve(CACHE_DIR, file) + cb({ data: fs.origin.createReadStream(file), mimeType: MIME_TYPES[ext] || MIME_TYPES.all, @@ -82,10 +83,9 @@ app.once('ready', () => { // 创建浏览器窗口 app.__main__ = createMainWindow(path.resolve(ROOT, './images/app.png')) - app.__view__ = createViewWindow() createMenu(app.__main__) - Socket(app) + Socket(app, createViewWindow) app.__main__.on('closed', () => { app.__main__ = null diff --git a/src/tools/socket.js b/src/tools/socket.js index 104bf1e..77acf86 100644 --- a/src/tools/socket.js +++ b/src/tools/socket.js @@ -4,7 +4,7 @@ * @date 2021/01/04 14:58:46 */ -const { app, ipcMain, net } = require('electron') +const { app, ipcMain } = require('electron') const fs = require('iofs') const path = require('path') const Epub = require('epub') @@ -13,42 +13,39 @@ const HOME = path.resolve(app.getPath('userData')) const DB_FILE = path.join(HOME, 'app.cache') const CACHE_DIR = path.join(HOME, 'book_cache') -function fetch(url) { - return new Promise((y, n) => { - var conn = net.request(url) - var r = [] - - conn.on('response', res => { - res.on('data', c => { - r.push(c) - }) - - res.on('end', _ => { - y(Buffer.concat(r).toString()) - }) - }) - - conn.on('error', e => { - n(e) - }) - - conn.end() - }) -} - -module.exports = function(app) { +module.exports = function(app, createViewWindow) { ipcMain.on('app', (ev, conn) => { switch (conn.type) { - case 'fetch': - fetch(conn.data).then(r => { - ev.returnValue = r - }) - break - case 'get-books': ev.returnValue = JSON.parse(fs.cat(DB_FILE)) break + case 'save-books': + fs.echo(JSON.stringify(conn.data), DB_FILE) + ev.returnValue = true + break + + case 'read': + if (app.__view__) { + // 打开同一个文档, 直接忽略 + if (app.__view__.__title__ === conn.data.title) { + app.__view__.focus() + ev.returnValue = true + return + } + app.__view__.destroy() + } + app.__view__ = createViewWindow(conn.data) + app.__view__.__title__ = conn.data.title + ev.returnValue = true + break + + case 'delete-book': + let dir = path.join(CACHE_DIR, conn.data) + fs.rm(dir, true) + ev.returnValue = true + break + case 'parse-book': let { book, cate } = conn.data let eb = new Epub(book.path) diff --git a/src/tools/window.js b/src/tools/window.js index 864afc0..a2a0780 100644 --- a/src/tools/window.js +++ b/src/tools/window.js @@ -4,7 +4,7 @@ * @date 2020/12/10 14:57:49 */ -const { BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron') /** * 应用主窗口 @@ -27,21 +27,23 @@ exports.createMainWindow = function(icon) { win.loadURL('app://local/index.html') - // win.on('ready-to-show', _ => { - // win.show() - // win.openDevTools() - // }) + win.on('ready-to-show', _ => { + win.show() + // win.openDevTools() + }) win.on('close', ev => { - ev.preventDefault() - win.hide() + if (app.__view__) { + ev.preventDefault() + win.hide() + } }) return win } // 创建悬浮窗口 -exports.createViewWindow = function() { +exports.createViewWindow = function(params) { var win = new BrowserWindow({ width: 1024, height: 768, @@ -56,9 +58,13 @@ exports.createViewWindow = function() { } }) - win.openDevTools() + // win.openDevTools() - win.loadURL('app://local/view.html') + win.loadURL('app://local/view.html?' + params) + + win.on('closed', ev => { + app.__view__ = null + }) return win } diff --git a/src/view.html b/src/view.html index 5bee159..449e5f8 100644 --- a/src/view.html +++ b/src/view.html @@ -12,7 +12,7 @@
- +