diff --git a/src/css/common.css b/src/css/common.css index 27bbeca..a4f88f4 100644 --- a/src/css/common.css +++ b/src/css/common.css @@ -1 +1 @@ -@font-face{font-family:"sonist font";src:url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAysAAsAAAAAFOAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFY9ikkYY21hcAAAAYAAAACpAAACRLbi0KRnbHlmAAACLAAACAwAAA0QU/XrjmhlYWQAAAo4AAAALwAAADYTt0/UaGhlYQAACmgAAAAcAAAAJAfeA5FobXR4AAAKhAAAAA8AAABAQAAAAGxvY2EAAAqUAAAAIgAAACIcSBmSbWF4cAAACrgAAAAfAAAAIAElAK5uYW1lAAAK2AAAAVAAAAKRbYZNvnBvc3QAAAwoAAAAgwAAAL22eIcreJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWCcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGByeizxXY27438AQw9zA0AAUZgTJAQDhxQwfeJztkcsRwkAMQ7UkhF8gFyCTQ/iTE7VQECeKoxeVEeQVZWDP2/Has5+RAEwBFOIhSiC9kRDxUjflfoFl7pd4aj9XTgC27DiMo6qtqj6qHEnzjTKqic6WeqHCTN2F7lmhxlrTRuMK/6jz+vntmlDThPbcmaz33oRXbE34xc6Ej+yN9AYPRsqDRyMPwJORG+DZhL+8GDkEXk38jjcj18C7CXc5GDRf39Ms5gAAAHiclRZbbBvHcWfveLf34JFHHo+iJFI6HnUXWzQlPkTKkkxJ1sOO3Ypx7FSGU6dw8+FXArewEyNwP+SiQIPCbSC0QeG/Bkb91SAN0jfqxA5a9KdG0aAoarQoAjQpnI8WSYD2yzx3lkdKsgMZKMGb3Z2dnZ2ZnRcRCP6ENfoT4pIFskgIlMB3J2peDCR7COz6HqjmIG3Jkp22q5V6o457gu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3pwVKghILHBFgoNWnTYYY8DehxZpa1VdCvGmidFcSEds3AlmZOarH4M1qTM3VxH7a8yGX+mKBcfgxNRjyZ8NkttCn4pB0/3vPoUae5W1yX9ovcxYy/tJyzCAA==") format("woff")}[class^="s-icon-"],[class*=" s-icon-"]{display:inline-block;font-family:"sonist font" !important;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.s-icon-all:before{content:"\e714"}.s-icon-eq:before{content:"\e715"}.s-icon-heart:before{content:"\e716"}.s-icon-music:before{content:"\e717"}.s-icon-play-list:before{content:"\e719"}.s-icon-mv:before{content:"\e71d"}.s-icon-rank:before{content:"\e71e"}.s-icon-singer:before{content:"\e71f"}.s-icon-random:before{content:"\e720"}.s-icon-radio:before{content:"\e721"}.s-icon-single:before{content:"\e722"}.s-icon-next:before{content:"\e723"}.s-icon-prev:before{content:"\e724"}.s-icon-pause:before{content:"\e725"}.s-icon-play:before{content:"\e726"}.do-fn-drag{-webkit-app-region:drag;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.do-fn-nodrag{-webkit-app-region:no-drag}html{font-size:62.5%}body{position:fixed;left:0;top:0;display:flex;width:100%;height:100%;line-height:1.5;background:#fff;font-size:1.4rem;color:#62778d;background-size:cover;background-repeat:no-repeat}table{overflow:auto;display:table;width:100%;line-height:2.5rem}table thead tr{height:4.5rem;border-bottom:0.1rem solid rgba(200,200,200,0.15)}table thead th{padding:1rem .8rem;border:0}table tbody tr{height:auto;transition:background .3s ease-in-out}table tbody tr:hover{background:rgba(29,35,44,0.08)}table tbody td{padding:.9rem .8rem}table .ac{text-align:center}table .idx{color:#dae1e9;text-shadow:0 0.1rem 0 rgba(255,255,255,0.6)}table .active{color:#3fc2a7;background:rgba(255,255,255,0.6);font-weight:bold}::-webkit-scrollbar{width:.6rem;height:.6rem;background:none}::-webkit-scrollbar:hover{background:rgba(255,255,255,0.1)}::-webkit-scrollbar-button{display:none}::-webkit-scrollbar-thumb{background:#dae1e9}::-webkit-scrollbar-thumb:hover{background:#3fc2a7} +@font-face{font-family:"sonist font";src:url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAysAAsAAAAAFOAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFY9ikkYY21hcAAAAYAAAACpAAACRLbi0KRnbHlmAAACLAAACAwAAA0QU/XrjmhlYWQAAAo4AAAALwAAADYTt0/UaGhlYQAACmgAAAAcAAAAJAfeA5FobXR4AAAKhAAAAA8AAABAQAAAAGxvY2EAAAqUAAAAIgAAACIcSBmSbWF4cAAACrgAAAAfAAAAIAElAK5uYW1lAAAK2AAAAVAAAAKRbYZNvnBvc3QAAAwoAAAAgwAAAL22eIcreJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWCcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGByeizxXY27438AQw9zA0AAUZgTJAQDhxQwfeJztkcsRwkAMQ7UkhF8gFyCTQ/iTE7VQECeKoxeVEeQVZWDP2/Has5+RAEwBFOIhSiC9kRDxUjflfoFl7pd4aj9XTgC27DiMo6qtqj6qHEnzjTKqic6WeqHCTN2F7lmhxlrTRuMK/6jz+vntmlDThPbcmaz33oRXbE34xc6Ej+yN9AYPRsqDRyMPwJORG+DZhL+8GDkEXk38jjcj18C7CXc5GDRf39Ms5gAAAHiclRZbbBvHcWfveLf34JFHHo+iJFI6HnUXWzQlPkTKkkxJ1sOO3Ypx7FSGU6dw8+FXArewEyNwP+SiQIPCbSC0QeG/Bkb91SAN0jfqxA5a9KdG0aAoarQoAjQpnI8WSYD2yzx3lkdKsgMZKMGb3Z2dnZ2ZnRcRCP6ENfoT4pIFskgIlMB3J2peDCR7COz6HqjmIG3Jkp22q5V6o457gu9JcspBSlyXQJKllJWjVSdl2bNQr/nClLtavmeoF1RQLqjGv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ZOarH4M1qTM3VxH7a8yGX+mKBcfgxNRjyZ8NkttCn4pB0/3vPoUae5W1yX9ovcxYy/tJyzCAA==") format("woff")}[class^="s-icon-"],[class*=" s-icon-"]{display:inline-block;font-family:"sonist font" !important;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.s-icon-all:before{content:"\e714"}.s-icon-eq:before{content:"\e715"}.s-icon-heart:before{content:"\e716"}.s-icon-music:before{content:"\e717"}.s-icon-play-list:before{content:"\e719"}.s-icon-mv:before{content:"\e71d"}.s-icon-rank:before{content:"\e71e"}.s-icon-singer:before{content:"\e71f"}.s-icon-random:before{content:"\e720"}.s-icon-radio:before{content:"\e721"}.s-icon-single:before{content:"\e722"}.s-icon-next:before{content:"\e723"}.s-icon-prev:before{content:"\e724"}.s-icon-pause:before{content:"\e725"}.s-icon-play:before{content:"\e726"}.do-fn-drag{-webkit-app-region:drag;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.do-fn-nodrag{-webkit-app-region:no-drag}html{font-size:62.5%}body{position:fixed;left:0;top:0;width:100%;height:100%;line-height:1.5;background:#fff;font-size:1.4rem;color:#62778d;background-size:cover;background-repeat:no-repeat}table{overflow:auto;display:table;width:100%;line-height:2.5rem}table thead tr{height:4.5rem;border-bottom:0.1rem solid rgba(200,200,200,0.15)}table thead th{padding:1rem .8rem;border:0}table tbody tr{height:auto;transition:background .3s ease-in-out}table tbody tr:hover{background:rgba(29,35,44,0.08)}table tbody td{padding:.9rem .8rem}table .ac{text-align:center}table .idx{color:#dae1e9;text-shadow:0 0.1rem 0 rgba(255,255,255,0.6)}table .active{color:#3fc2a7;background:rgba(255,255,255,0.6);font-weight:bold}::-webkit-scrollbar{width:.6rem;height:.6rem;background:none}::-webkit-scrollbar:hover{background:rgba(255,255,255,0.1)}::-webkit-scrollbar-button{display:none}::-webkit-scrollbar-thumb{background:#dae1e9}::-webkit-scrollbar-thumb:hover{background:#3fc2a7} diff --git a/src/css/common.scss b/src/css/common.scss index 3e97aed..3fa82bc 100644 --- a/src/css/common.scss +++ b/src/css/common.scss @@ -33,7 +33,7 @@ .do-fn-nodrag {-webkit-app-region:no-drag;} html {font-size:62.5%} -body {position:fixed;left:0;top:0;display:flex;width:100%;height:100%;line-height:1.5;background:#fff;font-size:1.4rem;color:nth($cd, 1);background-size:cover;background-repeat:no-repeat;} +body {position:fixed;left:0;top:0;width:100%;height:100%;line-height:1.5;background:#fff;font-size:1.4rem;color:nth($cd, 1);background-size:cover;background-repeat:no-repeat;} table {overflow:auto;display:table;width:100%;line-height:2.5rem; thead tr {height:4.5rem;border-bottom:.1rem solid rgba(200, 200, 200, .15)} diff --git a/src/js/api.js b/src/js/api.js index 1dba151..9154311 100644 --- a/src/js/api.js +++ b/src/js/api.js @@ -12,6 +12,8 @@ const log = console.log const BASE_API_URI = 'http://mobilecdnbj.kugou.com' +request.init({ dataType: 'json' }) + const get = uri => { return request.get(BASE_API_URI + uri) } @@ -22,8 +24,8 @@ const post = uri => { export default { getLastHot100Artists() { - return get('/api/v5/singer/list') - .send({ + return get('/api/v5/singer/list', { + data: { sort: 1, showtype: 1, sextype: 0, @@ -32,108 +34,106 @@ export default { plat: 2, type: 0, page: 1 - }) - .then(res => { - if (res.status === 200) { - return JSON.parse(res.text) - } - }) + } + }).then(res => { + if (res.status === 200) { + return res.body + } + }) }, getArtistList(sextype = 1, type = 1) { - return get('/api/v5/singer/list') - .send({ + return get('/api/v5/singer/list', { + data: { showtype: 2, musician: 0, type, sextype - }) - .then(res => { - if (res.status === 200) { - return JSON.parse(res.text) - } - }) + } + }).then(res => { + if (res.status === 200) { + return res.body + } + }) }, getArtistInfo(singerid) { - return get('/api/v3/singer/info') - .send({ singerid }) - .then(res => { - if (res.status === 200) { - return JSON.parse(res.text) - } - }) + return get('/api/v3/singer/info', { data: { singerid } }).then(res => { + if (res.status === 200) { + return res.body + } + }) }, getArtistInfo(singerid) { - return get('/api/v3/singer/info') - .send({ singerid }) - .then(res => { - if (res.status === 200) { - return JSON.parse(res.text) - } - }) + return get('/api/v3/singer/info', { data: { singerid } }).then(res => { + if (res.status === 200) { + return res.body + } + }) }, getArtistSongs(singerid, page = 1) { - return get('/api/v3/singer/song') - .send({ + return get('/api/v3/singer/song', { + data: { sorttype: 2, pagesize: 50, singerid, area_code: 1, page - }) - .then(res => { - if (res.status === 200) { - return JSON.parse(res.text) - } - }) + } + }).then(res => { + if (res.status === 200) { + return res.body + } + }) }, getArtistAlbums(singerid, page = 1) { - return get('/api/v3/singer/album') - .send({ + return get('/api/v3/singer/album', { + data: { pagesize: 50, singerid, area_code: 1, page - }) - .then(res => { - if (res.status === 200) { - return JSON.parse(res.text) - } - }) + } + }).then(res => { + if (res.status === 200) { + return res.body + } + }) }, search(keyword, page = 1, pagesize = 20) { return request - .get('https://songsearch.kugou.com/song_search_v2') - .send({ - keyword, - platform: 'WebFilter', - tag: '', - page, - pagesize + .get('https://songsearch.kugou.com/song_search_v2', { + data: { + keyword, + platform: 'WebFilter', + tag: '', + page, + pagesize + } }) .then(res => { if (res.status === 200) { - return JSON.parse(res.text).data.lists + return res.body.data.lists } }) }, getSongInfoByHash(hash, album_id = '') { return request - .get('https://wwwapi.kugou.com/yy') - .send({ - r: 'play/getdata', - hash, - album_id + .get('https://wwwapi.kugou.com/yy', { + data: { + r: 'play/getdata', + hash, + album_id + } }) .then(res => { if (res.status === 200) { - return JSON.parse(res.text).data + return res.body.data } }) } diff --git a/src/js/app.js b/src/js/app.js index c50f514..44e2458 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -59,7 +59,7 @@ Anot({ state: { theme: appInit.theme || 1, // 1:macos, 2: deepin winFocus: false, - mod: 'profile', + mod: 'local', searchTxt: '', playMode: Anot.ls('play-mode') >>> 0, // 0:all | 1:single | 2:random ktvMode: 0, diff --git a/src/js/modules/search.js b/src/js/modules/search.js index 6f2d4e9..02a0070 100644 --- a/src/js/modules/search.js +++ b/src/js/modules/search.js @@ -93,27 +93,23 @@ export default Anot({ ipcRenderer.send('save-lrc', { id: song.id, lrc: json.lyrics }) - fetch(json.play_url) - .then(res => { - return res.arrayBuffer() + request.get(json.play_url, { dataType: 'arraybuffer' }).then(res => { + song.path = ipcRenderer.sendSync('save-cache', { + buff: Buffer.from(res.body), + file: song.kgHash }) - .then(blob => { - song.path = ipcRenderer.sendSync('save-cache', { - buff: Buffer.from(blob), - file: song.kgHash - }) - log(song) - TS.insert(song) - dict.audition.push(song) + log(song) + TS.insert(song) + dict.audition.push(song) - SONIST.push([song]) - SONIST.play(dict.audition.length - 1).then(it => { - this.__APP__.play(it) - this.curr = it.id - }) - - ipcRenderer.send('set-temp', TS.getAll()) + SONIST.push([song]) + SONIST.play(dict.audition.length - 1).then(it => { + this.__APP__.play(it) + this.curr = it.id }) + + ipcRenderer.send('set-temp', TS.getAll()) + }) }) }, delThis(it, ev) { @@ -130,7 +126,7 @@ export default Anot({ return } - let load = layer.load(1) + let load = layer.load(2) this.list.clear() Api.search(txt, 1, 50).then(list => { diff --git a/src/lib/css/elem-ui.css b/src/lib/css/elem-ui.css index 8080069..a0f7d6a 100644 --- a/src/lib/css/elem-ui.css +++ b/src/lib/css/elem-ui.css @@ -1 +1 @@ -.do-ui-button{display:inline-block;height:16px;padding:2px 5px;line-height:12px;border-radius:2px;text-align:center;font-size:12px;background:#e8ebf4;color:#98acae;cursor:pointer;transition:all .2s ease-in-out}.do-ui-button.medium{min-width:80px;height:30px;padding:0 8px;line-height:30px;font-size:14px}.do-ui-button.large{min-width:130px;height:45px;padding:0 13px;line-height:45px;border-radius:3px;font-size:18px}.do-ui-button:hover{background:#f3f5fb}.do-ui-button:active{background:#dae1e9}.do-ui-button.teal{background:#19b491;color:#fff}.do-ui-button.teal:hover{background:#3fc2a7}.do-ui-button.teal:active{background:#16967a}.do-ui-button.green{background:#2ecc71;color:#fff}.do-ui-button.green:hover{background:#58d68d}.do-ui-button.green:active{background:#27ae60}.do-ui-button.blue{background:#2d8dd6;color:#fff}.do-ui-button.blue:hover{background:#52a3de}.do-ui-button.blue:active{background:#2776b1}.do-ui-button.purple{background:#9b59b6;color:#fff}.do-ui-button.purple:hover{background:#ac61ce}.do-ui-button.purple:active{background:#8e44ad}.do-ui-button.red{background:#eb3b48;color:#fff}.do-ui-button.red:hover{background:#ff5061}.do-ui-button.red:active{background:#ce3742}.do-ui-button.orange{background:#f39c12;color:#fff}.do-ui-button.orange:hover{background:#ffb618}.do-ui-button.orange:active{background:#e67e22}.do-ui-button.grey{background:#8a9b9c;color:#fff}.do-ui-button.grey:hover{background:#98acae}.do-ui-button.grey:active{background:#748182}.do-ui-button.dark{background:#526273;color:#fff}.do-ui-button.dark:hover{background:#62778d}.do-ui-button.dark:active{background:#425064}.do-ui-button.disabled{background:#f3f5fb;color:#dae1e9;cursor:not-allowed}.do-ui-input{width:auto;height:30px;padding:0 5px;background:#f3f5fb;border:2px solid transparent;border-radius:5px;font-size:13px;transition:all .2s ease-in-out;color:#526273}.do-ui-input:focus{background:#fff;border-color:#526273}.do-ui-input::placeholder{color:#98acae}.do-ui-input:disabled{border-color:transparent;background:#fff8ed;color:#98acae;cursor:not-allowed}.do-ui-textarea{width:auto;height:120px;padding:5px 8px;background:#f3f5fb;border:2px solid transparent;border-radius:5px;font-size:14px;transition:all .2s ease-in-out;color:#526273}.do-ui-textarea:focus{background:#fff;border-color:#526273}.do-ui-textarea:disabled{border-color:transparent;background:#fff8ed;color:#98acae;cursor:not-allowed}.do-ui-select{position:relative;display:inline-block;width:auto;min-width:100px;height:30px;color:#98acae}.do-ui-select select{width:100%;height:100%;padding:5px 13px;line-height:1;background:#f3f5fb;border-radius:5px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:2px solid transparent;outline:none;color:#526273;font-size:13px}.do-ui-select select:focus{background:#fff;border-color:#526273}.do-ui-select select::-ms-expand{display:none}.do-ui-select select:disabled{border-color:transparent;background:#fff8ed;color:#dae1e9}.do-ui-select .trigon{position:absolute;right:7px;top:0;width:15px;height:30px;padding:7px 0;font-size:12px;text-align:center}.do-ui-select .trigon i{float:left;width:15px;height:12px;line-height:12px}.do-ui-select .trigon i:nth-child(2){margin-top:-6px}.do-ui-radio,.do-ui-checkbox{display:inline-block;position:relative;width:auto;height:auto;padding:0 5px 0 35px;line-height:30px;color:#62778d;font-size:13px}.do-ui-radio>input,.do-ui-checkbox>input{position:absolute;left:7px;top:5px;width:20px;height:20px;border-radius:50%;border:1px solid #dae1e9;background:#fff;-webkit-appearance:none;-moz-appearance:none;appearance:none}.do-ui-radio>input:checked,.do-ui-checkbox>input:checked{box-shadow:0 0 5px #52a3de}.do-ui-radio>input:checked::after,.do-ui-checkbox>input:checked::after{display:block;width:12px;height:12px;margin:3px;border-radius:50%;background:#98acae;content:""}.do-ui-radio>input:disabled,.do-ui-checkbox>input:disabled{background:#fff8ed;box-shadow:none;cursor:not-allowed}.do-ui-radio>input:disabled:checked::after,.do-ui-checkbox>input:disabled:checked::after{background:#98acae}.do-ui-radio.disabled,.do-ui-checkbox.disabled{color:#dae1e9;cursor:not-allowed}.do-ui-checkbox>input{border-radius:3px}.do-ui-checkbox>input:checked::after{width:100%;height:100%;margin:0;line-height:18px;font-size:18px;text-align:center;color:#98acae;background:none;content:"✓"}.do-ui-checkbox>input:disabled:checked::after{color:#98acae;background:none}.do-ui-quote{display:inline-block;position:relative;min-height:60px;margin:10px 0;padding:15px 10px 5px 50px;border:1px solid #dae1e9;border-radius:10px;background:#f3f5fb;color:#98acae;font-size:14px;word-break:break-all}.do-ui-quote i{position:absolute;left:8px;top:0;font-size:30px;line-height:1.5;color:#dae1e9}.do-ui-warn,.do-ui-mark{display:inline-block;position:relative;min-height:40px;margin:5px 0;padding:5px 8px 5px 30px;border:1px solid #ffb618;border-radius:5px;background:#fffbed;color:#e67e22;font-size:14px;word-break:break-all}.do-ui-warn p,.do-ui-mark p{margin:0 !important}.do-ui-warn i,.do-ui-mark i{position:absolute;left:5px;top:2px;font-size:20px;line-height:1.5}.do-ui-mark{border-color:#19b491;color:#16967a;background:#edfbf8} +.do-ui-button{display:inline-block;height:16px;padding:2px 5px;line-height:12px;border:0;border-radius:2px;text-align:center;font-size:12px;background:#e8ebf4;color:#98acae;cursor:pointer;transition:all .2s ease-in-out}.do-ui-button.medium{min-width:80px;height:30px;padding:0 8px;line-height:30px;font-size:14px}.do-ui-button.large{min-width:130px;height:45px;padding:0 13px;line-height:45px;border-radius:3px;font-size:18px}.do-ui-button:hover{background:#f3f5fb}.do-ui-button:active{background:#dae1e9}.do-ui-button.teal{background:#19b491;color:#fff}.do-ui-button.teal:hover{background:#3fc2a7}.do-ui-button.teal:active{background:#16967a}.do-ui-button.green{background:#2ecc71;color:#fff}.do-ui-button.green:hover{background:#58d68d}.do-ui-button.green:active{background:#27ae60}.do-ui-button.blue{background:#2d8dd6;color:#fff}.do-ui-button.blue:hover{background:#52a3de}.do-ui-button.blue:active{background:#2776b1}.do-ui-button.purple{background:#9b59b6;color:#fff}.do-ui-button.purple:hover{background:#ac61ce}.do-ui-button.purple:active{background:#8e44ad}.do-ui-button.red{background:#eb3b48;color:#fff}.do-ui-button.red:hover{background:#ff5061}.do-ui-button.red:active{background:#ce3742}.do-ui-button.orange{background:#f39c12;color:#fff}.do-ui-button.orange:hover{background:#ffb618}.do-ui-button.orange:active{background:#e67e22}.do-ui-button.grey{background:#8a9b9c;color:#fff}.do-ui-button.grey:hover{background:#98acae}.do-ui-button.grey:active{background:#748182}.do-ui-button.dark{background:#526273;color:#fff}.do-ui-button.dark:hover{background:#62778d}.do-ui-button.dark:active{background:#425064}.do-ui-button.disabled{background:#f3f5fb;color:#dae1e9;cursor:not-allowed}.do-ui-input{width:auto;height:30px;padding:0 5px;background:#f3f5fb;border:2px solid transparent;border-radius:5px;font-size:13px;transition:all .2s ease-in-out;color:#526273}.do-ui-input:focus{background:#fff;border-color:#526273}.do-ui-input::placeholder{color:#98acae}.do-ui-input:disabled{border-color:transparent;background:#fff8ed;color:#98acae;cursor:not-allowed}.do-ui-textarea{width:auto;height:120px;padding:5px 8px;background:#f3f5fb;border:2px solid transparent;border-radius:5px;font-size:14px;transition:all .2s ease-in-out;color:#526273}.do-ui-textarea:focus{background:#fff;border-color:#526273}.do-ui-textarea:disabled{border-color:transparent;background:#fff8ed;color:#98acae;cursor:not-allowed}.do-ui-select{position:relative;display:inline-block;width:auto;min-width:100px;height:30px;color:#98acae}.do-ui-select select{width:100%;height:100%;padding:5px 13px;line-height:1;background:#f3f5fb;border-radius:5px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:2px solid transparent;outline:none;color:#526273;font-size:13px}.do-ui-select select:focus{background:#fff;border-color:#526273}.do-ui-select select::-ms-expand{display:none}.do-ui-select select:disabled{border-color:transparent;background:#fff8ed;color:#dae1e9}.do-ui-select .trigon{position:absolute;right:7px;top:0;width:15px;height:30px;padding:7px 0;font-size:12px;text-align:center}.do-ui-select .trigon i{float:left;width:15px;height:12px;line-height:12px}.do-ui-select .trigon i:nth-child(2){margin-top:-6px}.do-ui-radio,.do-ui-checkbox{display:inline-block;position:relative;width:auto;height:auto;padding:0 5px 0 35px;line-height:30px;color:#62778d;font-size:13px}.do-ui-radio>input,.do-ui-checkbox>input{position:absolute;left:7px;top:5px;width:20px;height:20px;border-radius:50%;border:1px solid #dae1e9;background:#fff;-webkit-appearance:none;-moz-appearance:none;appearance:none}.do-ui-radio>input:checked,.do-ui-checkbox>input:checked{box-shadow:0 0 5px #52a3de}.do-ui-radio>input:checked::after,.do-ui-checkbox>input:checked::after{display:block;width:12px;height:12px;margin:3px;border-radius:50%;background:#98acae;content:""}.do-ui-radio>input:disabled,.do-ui-checkbox>input:disabled{background:#fff8ed;box-shadow:none;cursor:not-allowed}.do-ui-radio>input:disabled:checked::after,.do-ui-checkbox>input:disabled:checked::after{background:#98acae}.do-ui-radio.disabled,.do-ui-checkbox.disabled{color:#dae1e9;cursor:not-allowed}.do-ui-checkbox>input{border-radius:3px}.do-ui-checkbox>input:checked::after{width:100%;height:100%;margin:0;line-height:18px;font-size:18px;text-align:center;color:#98acae;background:none;content:"✓"}.do-ui-checkbox>input:disabled:checked::after{color:#98acae;background:none}.do-ui-quote{display:inline-block;position:relative;min-height:60px;margin:10px 0;padding:15px 10px 5px 50px;border:1px solid #dae1e9;border-radius:10px;background:#f3f5fb;color:#98acae;font-size:14px;word-break:break-all}.do-ui-quote i{position:absolute;left:8px;top:0;font-size:30px;line-height:1.5;color:#dae1e9}.do-ui-warn,.do-ui-mark{display:inline-block;position:relative;min-height:40px;margin:5px 0;padding:5px 8px 5px 30px;border:1px solid #ffb618;border-radius:5px;background:#fffbed;color:#e67e22;font-size:14px;word-break:break-all}.do-ui-warn p,.do-ui-mark p{margin:0 !important}.do-ui-warn i,.do-ui-mark i{position:absolute;left:5px;top:2px;font-size:20px;line-height:1.5}.do-ui-mark{border-color:#19b491;color:#16967a;background:#edfbf8} diff --git a/src/lib/css/layer-normal.css b/src/lib/css/layer-normal.css index f1fcf30..8c5438a 100644 --- a/src/lib/css/layer-normal.css +++ b/src/lib/css/layer-normal.css @@ -1 +1 @@ -.do-layer{width:auto;height:auto}.do-layer a{text-decoration:none}.do-layer .layer-box{position:absolute;z-index:65535;opacity:0}.do-layer .layer-box.shift{transition:all .5s ease-out}.do-layer .layer-box.__tc{top:0;left:50%}.do-layer .layer-box.__tl{top:0;left:0}.do-layer .layer-box.__tr{top:0;left:100%}.do-layer .layer-box.__ct{top:50%;left:50%}.do-layer .layer-box.__cc{top:47.5%;left:50%}.do-layer .layer-box.__bc{top:100%;left:50%}.do-layer .layer-box.__bl{top:100%;left:0}.do-layer .layer-box.__br{top:100%;left:100%}.do-layer .layer-box.scale{transform:scale(1.02);transition:transform .1s linear}.do-layer .layer-box.skin-normal{padding:15px 10px;border-radius:3px;color:#666;font-size:14px;box-shadow:0 5px 20px rgba(0,0,0,0.3)}.do-layer .layer-box.skin-normal .layer-title{width:100%;height:43px;padding:0 10px;line-height:43px;font-size:16px;color:#526273}.do-layer .layer-box.skin-normal .layer-content{position:relative;width:100%;height:auto;min-height:50px;word-break:break-all;word-wrap:break-word}.do-layer .layer-box.skin-normal .layer-content .prompt-value{width:100%;height:30px;padding:0 8px;border:1px solid #ddd;border-radius:3px}.do-layer .layer-box.skin-normal .layer-content .prompt-value.alert{border-color:#eb3b48}.do-layer .layer-box.skin-normal .layer-content .prompt-value:focus{border-color:#19b491}.do-layer .layer-box.skin-normal .layer-content .msg-box{line-height:30px}.do-layer .layer-box.skin-normal .layer-ctrl{width:100%;height:40px;padding:5px 0;line-height:30px;font-size:14px;color:#454545;text-align:right}.do-layer .layer-box.skin-normal .layer-ctrl a{overflow:hidden;position:relative;display:inline-block;width:auto;min-width:60px;height:30px;margin-left:5px;padding:0 10px;color:#19b491;text-align:center;cursor:pointer}.do-layer .layer-box.skin-normal .layer-ctrl a::before{position:absolute;left:-50%;top:-50%;z-index:-1;display:block;width:200%;height:200%;border-radius:50%;background:#f3f5fb;content:"";opacity:0;transform:scale(0, 0);transition:opacity 1.3s cubic-bezier(0.23, 1, 0.32, 1),transform 1.3s cubic-bezier(0.23, 1, 0.32, 1)}.do-layer .layer-box.skin-normal .layer-ctrl a:hover::before{opacity:1;transform:scale(1, 0.8)}.do-layer .layer-box.skin-normal .layer-ctrl a:active{background:#e8ebf4}.do-layer .layer-box.type-1,.do-layer .layer-box.type-2,.do-layer .layer-box.type-3{max-width:600px;min-width:300px}.do-layer .layer-box.type-1 .layer-content,.do-layer .layer-box.type-2 .layer-content,.do-layer .layer-box.type-3 .layer-content{padding:10px}.do-layer .layer-box.type-4{padding:0}.do-layer .layer-box.type-4 .frame-box{display:block;width:100%;height:100%;margin:0;padding:0;border:0;resize:none}.do-layer .layer-box.type-5{visibility:hidden;position:fixed;z-index:65534;min-width:75px;max-width:600px;padding:10px;line-height:1.5;color:#fff;background:rgba(0,0,0,0.5);box-shadow:none}.do-layer .layer-box.type-5 i.arrow{position:absolute;width:0;height:0;border:6px solid transparent;content:""}.do-layer .layer-box.type-5 i.offset-top{left:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 i.offset-bottom{left:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 i.offset-top-left{right:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 i.offset-bottom-left{right:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 .layer-content{min-height:20px;margin:0}.do-layer .layer-box.type-6{z-index:65539;box-shadow:none;background:transparent}.do-layer .layer-box.type-toast{position:fixed;min-width:10px;padding:0;background:transparent}.do-layer .layer-box.type-toast .layer-content{min-height:40px;height:40px}.do-layer .layer-box.type-toast .toast-box{display:inline-block;position:relative;min-height:40px;padding:5px 12px 5px 50px;line-height:28px;border-radius:3px;word-break:break-all}.do-layer .layer-box.type-toast .toast-box.style-info{border:1px solid #19b491;background:#edfbf8;color:#16967a}.do-layer .layer-box.type-toast .toast-box.style-warn{border:1px solid #f39c12;background:#fffbed;color:#e67e22}.do-layer .layer-box.type-toast .toast-box.style-deny{border:1px solid #eb3b48;background:#fffbed;color:#ce3742}.do-layer .layer-box.type-toast .toast-box>i{position:absolute;left:12px;top:5px;line-height:28px;font-size:26px}.do-layer .layer-box .loading{position:relative;width:100px;height:100px;margin:auto}.do-layer .layer-box .loading .dot-box{position:absolute;display:block}.do-layer .layer-box .loading.style-1 .dot-box{width:70%;height:70%;margin:15%;line-height:70px;font-size:70px;text-align:center}.do-layer .layer-box .loading.style-1 .dot-box i{display:block;width:100%;height:100%}.do-layer .layer-box .loading.style-1 .dot-box{animation:circle .8s infinite linear}.do-layer .layer-box .loading.style-2{height:50px}.do-layer .layer-box .loading.style-2 .dot-box{width:100%;height:100%}.do-layer .layer-box .loading.style-2 .dot-box i{float:left;display:block;width:10px;height:100%;margin:0 5px;background:#16967a;animation:bounce 1s infinite ease-in-out;transform:scaleY(0.6)}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(2){animation-delay:.1s}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(3){animation-delay:.2s}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(4){animation-delay:.3s}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(5){animation-delay:.4s}.do-layer .layer-box .loading.style-3 .dot-box{width:60%;height:60%;margin:20%}.do-layer .layer-box .loading.style-3 .dot-box i{position:absolute;display:block;width:60px;height:60px;animation:circle2 2s infinite ease-in-out;transform:rotate(45deg)}.do-layer .layer-box .loading.style-3 .dot-box i::before{display:block;width:8px;height:8px;background:#16967a;border-radius:50%;content:""}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(2){animation-delay:.1s}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(3){animation-delay:.2s}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(4){animation-delay:.3s}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(5){animation-delay:.4s}.do-layer .layer-box .loading.style-4 .dot-box{width:90%;height:90%;margin:5%}.do-layer .layer-box .loading.style-4 .dot-box i{float:left;display:block;width:30px;height:30px;background:#16967a;animation:grid 1.5s infinite linear}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(4),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(8){animation-delay:.2s}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(1),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(5),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(9){animation-delay:.3s}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(2),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(6){animation-delay:.4s}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(3){animation-delay:.5s}.do-layer.mask{position:fixed;z-index:65534;left:0;top:0;width:100%;height:100%;background:transparent}.do-layer.mask.shift{transition:all .5s ease-out}.do-layer.mask.inner{position:absolute}.do-layer:active{z-index:65536}.do-layer__tips{visibility:hidden;position:fixed;z-index:65534;min-width:75px;max-width:600px;padding:10px;line-height:1.5;border-radius:3px;font-size:14px;color:#fff;background:rgba(0,0,0,0.5)}.do-layer__tips i.arrow{position:absolute;width:0;height:0;border:6px solid transparent;content:""}.do-layer__tips i.offset-top{left:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer__tips i.offset-bottom{left:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer__tips i.offset-top-left{right:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer__tips i.offset-bottom-left{right:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer__tips .layer-content{min-height:20px;margin:0}@keyframes circle{to{transform:rotate(360deg)}}@keyframes circle2{70%,to{transform:rotate(405deg)}}@keyframes bounce{25%{transform:scaleY(1.3)}50%{transform:scaleY(0.6)}}@keyframes grid{36%{transform:scale(0.1);opacity:.3}60%{transform:scale(1);opacity:1}}@media screen and (max-width: 480px){.do-layer .layer-box.type-1,.do-layer .layer-box.type-2,.do-layer .layer-box.type-3,.do-layer .layer-box.type-4,.do-layer .layer-box.type-7{width:90%}} +.do-layer{display:flex;justify-content:center;align-items:center;width:auto;height:auto}.do-layer a{text-decoration:none}.do-layer .layer-box{flex:0 auto;position:absolute;z-index:65535;opacity:0}.do-layer .layer-box.shift{transition:all .5s ease-out}.do-layer .layer-box.scale{transform:scale(1.02);transition:transform .1s linear}.do-layer .layer-box.skin-normal{padding:15px 10px;border-radius:3px;color:#666;font-size:14px;box-shadow:0 5px 20px rgba(0,0,0,0.3)}.do-layer .layer-box.skin-normal .layer-title{width:100%;height:43px;padding:0 10px;line-height:43px;font-size:16px;color:#526273}.do-layer .layer-box.skin-normal .layer-content{position:relative;width:100%;height:auto;min-height:50px;word-break:break-all;word-wrap:break-word}.do-layer .layer-box.skin-normal .layer-content .prompt-value{width:100%;height:30px;padding:0 8px;border:1px solid #ddd;border-radius:3px}.do-layer .layer-box.skin-normal .layer-content .prompt-value.alert{border-color:#eb3b48}.do-layer .layer-box.skin-normal .layer-content .prompt-value:focus{border-color:#19b491}.do-layer .layer-box.skin-normal .layer-content .msg-box{line-height:30px}.do-layer .layer-box.skin-normal .layer-ctrl{width:100%;height:40px;padding:5px 0;line-height:30px;font-size:14px;color:#454545;text-align:right}.do-layer .layer-box.skin-normal .layer-ctrl a{overflow:hidden;position:relative;display:inline-block;width:auto;min-width:60px;height:30px;margin-left:5px;padding:0 10px;color:#19b491;text-align:center;cursor:pointer}.do-layer .layer-box.skin-normal .layer-ctrl a::before{position:absolute;left:-50%;top:-50%;z-index:-1;display:block;width:200%;height:200%;border-radius:50%;background:#f3f5fb;content:"";opacity:0;transform:scale(0, 0);transition:opacity 1.3s cubic-bezier(0.23, 1, 0.32, 1),transform 1.3s cubic-bezier(0.23, 1, 0.32, 1)}.do-layer .layer-box.skin-normal .layer-ctrl a:hover::before{opacity:1;transform:scale(1, 0.8)}.do-layer .layer-box.skin-normal .layer-ctrl a:active{background:#e8ebf4}.do-layer .layer-box.type-1,.do-layer .layer-box.type-2,.do-layer .layer-box.type-3{max-width:600px;min-width:300px}.do-layer .layer-box.type-1 .layer-content,.do-layer .layer-box.type-2 .layer-content,.do-layer .layer-box.type-3 .layer-content{padding:10px}.do-layer .layer-box.type-4{padding:0}.do-layer .layer-box.type-4 .frame-box{display:block;width:100%;height:100%;margin:0;padding:0;border:0;resize:none}.do-layer .layer-box.type-5{visibility:hidden;position:fixed;z-index:65534;min-width:75px;max-width:600px;padding:10px;line-height:1.5;color:#fff;background:rgba(0,0,0,0.5);box-shadow:none}.do-layer .layer-box.type-5 i.arrow{position:absolute;width:0;height:0;border:6px solid transparent;content:""}.do-layer .layer-box.type-5 i.offset-top{left:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 i.offset-bottom{left:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 i.offset-top-left{right:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 i.offset-bottom-left{right:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 .layer-content{min-height:20px;margin:0}.do-layer .layer-box.type-6{z-index:65539;box-shadow:none;background:transparent}.do-layer .layer-box.type-6 .layer-content{display:flex;justify-content:center;align-items:center}.do-layer .layer-box.type-toast{position:fixed;min-width:10px;padding:0;background:transparent}.do-layer .layer-box.type-toast .layer-content{min-height:40px;height:40px}.do-layer .layer-box.type-toast .toast-box{display:inline-block;position:relative;min-height:40px;padding:5px 12px 5px 50px;line-height:28px;border-radius:3px;word-break:break-all}.do-layer .layer-box.type-toast .toast-box.style-info{border:1px solid #19b491;background:#edfbf8;color:#16967a}.do-layer .layer-box.type-toast .toast-box.style-warn{border:1px solid #f39c12;background:#fffbed;color:#e67e22}.do-layer .layer-box.type-toast .toast-box.style-deny{border:1px solid #eb3b48;background:#fffbed;color:#ce3742}.do-layer .layer-box.type-toast .toast-box>i{position:absolute;left:12px;top:5px;line-height:28px;font-size:26px}.do-layer .layer-box .loading{position:relative;width:100px;height:100px;margin:auto}.do-layer .layer-box .loading .dot-box{position:absolute;display:block}.do-layer .layer-box .loading.style-1 .dot-box{width:70%;height:70%;margin:15%;line-height:70px;font-size:70px;text-align:center;animation:circle .8s infinite linear}.do-layer .layer-box .loading.style-1 .dot-box i{display:block;width:100%;height:100%}.do-layer .layer-box .loading.style-2{height:40px}.do-layer .layer-box .loading.style-2 .dot-box{display:flex;justify-content:center;width:100%;height:100%}.do-layer .layer-box .loading.style-2 .dot-box i{float:left;display:block;width:6px;height:100%;margin:0 3px;background:#16967a;animation:bounce 1s infinite ease-in-out;transform:scaleY(0.6)}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(2){animation-delay:.1s}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(3){animation-delay:.2s}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(4){animation-delay:.3s}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(5){animation-delay:.4s}.do-layer .layer-box .loading.style-3{width:50px;height:50px}.do-layer .layer-box .loading.style-3 .dot-box{width:100%;height:100%}.do-layer .layer-box .loading.style-3 .dot-box i{position:absolute;display:block;width:100%;height:100%;animation:circle2 2s infinite ease-in-out;transform:rotate(45deg);opacity:.5}.do-layer .layer-box .loading.style-3 .dot-box i::before{display:block;width:8px;height:8px;background:#16967a;border-radius:50%;content:""}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(2){animation-delay:.1s}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(3){animation-delay:.2s}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(4){animation-delay:.3s}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(5){animation-delay:.4s}.do-layer .layer-box .loading.style-4{width:60px;height:60px}.do-layer .layer-box .loading.style-4 .dot-box i{float:left;display:block;width:20px;height:20px;background:#16967a;animation:grid 1.5s infinite linear}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(4),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(8){animation-delay:.2s}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(1),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(5),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(9){animation-delay:.3s}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(2),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(6){animation-delay:.4s}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(3){animation-delay:.5s}.do-layer.mask{position:fixed;z-index:65534;left:0;top:0;width:100%;height:100%;background:transparent}.do-layer.mask.shift{transition:all .5s ease-out}.do-layer.mask.inner{position:absolute}.do-layer:active{z-index:65536}.do-layer__tips{visibility:hidden;position:absolute;z-index:65534;min-width:75px;max-width:600px;padding:10px;line-height:1.5;border-radius:3px;font-size:14px;color:#fff;background:rgba(0,0,0,0.5)}.do-layer__tips i.arrow{position:absolute;width:0;height:0;border:6px solid transparent;content:""}.do-layer__tips i.offset-top{left:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer__tips i.offset-bottom{left:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer__tips i.offset-top-left{right:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer__tips i.offset-bottom-left{right:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer__tips .layer-content{min-height:20px;margin:0}@keyframes circle{to{transform:rotate(360deg)}}@keyframes circle2{70%,to{transform:rotate(405deg);opacity:1}}@keyframes bounce{25%{transform:scaleY(1)}50%{transform:scaleY(0.6)}}@keyframes grid{36%{transform:scale(0.1);opacity:.3}60%{transform:scale(1);opacity:1}}@media screen and (max-width: 480px){.do-layer .layer-box.type-1,.do-layer .layer-box.type-2,.do-layer .layer-box.type-3,.do-layer .layer-box.type-4,.do-layer .layer-box.type-7{width:90%}} diff --git a/src/lib/layer/index.js b/src/lib/layer/index.js index fc808e9..e9c256c 100644 --- a/src/lib/layer/index.js +++ b/src/lib/layer/index.js @@ -1 +1 @@ -"use strict";import "../drag/index.js";importCss("/css/layer-normal.css");Anot.ui.layer="1.0.0-normal";const LANGUAGES={en:{TITLE:"Dialog",YES_BTN:"OK",NO_BTN:"Cancel",ERROR:"The layer instance is not exists",NEED_CONTAINER:'layer "tips" require a DOM object as container'},zh:{TITLE:"提示",YES_BTN:"确定",NO_BTN:"取消",ERROR:"要关闭的layer实例不存在",NEED_CONTAINER:"tips类型需要指定一个元素节点作为容器"},"zh-TW":{TITLE:"提示",YES_BTN:"確定",NO_BTN:"取消",ERROR:"要關閉的layer實例不存在",NEED_CONTAINER:"tips类型需要指定一個元素節點作爲容器"}};LANGUAGES["zh-CN"]=LANGUAGES.zh;const lang=LANGUAGES[window.__ENV_LANG__||navigator.language]||LANGUAGES.en;let layerDom={},layerObj={},unique=null,lid=0,defconf={type:1,background:"#fff",mask:!0,maskClose:!1,maskColor:null,radius:"0px",area:["auto","auto"],title:lang.TITLE,menubar:!0,content:"",fixed:!1,shift:"cc",offset:[],btns:[lang.YES_BTN,lang.NO_BTN]};const $doc=Anot(document),uuid=function(){return"layer-"+lid++},close=function(e){if("string"!=typeof e&&"number"!=typeof e)return Anot.error(lang.ERROR);if(/^layerwrap\-/.test(e)||layerObj["layerwrap-"+e])try{if(e=(layerObj["layerwrap-"+e]?"layerwrap-":"")+e,!layerObj[e].show)return;layerObj[e].parentElem.replaceChild(layerObj[e].wrap,layerDom[e][0]),layerObj[e].wrap.style.display="none",layerObj[e].show=!1}catch(e){}else{unique=null;try{layerDom[e][0].classList.add("shift"),layerDom[e][1].classList.add("shift"),layerDom[e][0].style.opacity="",layerDom[e][1].style.opacity=0,setTimeout(function(){layerDom[e][0].parentNode.removeChild(layerDom[e][0]),delete layerDom[e],delete Anot.vmodels[e]},200)}catch(e){}}document.body.style.overflow=""},repeat=function(e,t){let o=0,s="";for(;o{this.$refs.layer.classList.remove("scale")},100)},onMaskClick:function(){this.type<4&&!this.maskClose?this.shake():this.maskClose&&this.close()},handleConfirm:function(){if(3===this.type&&!this.prompt)return this.shake();if("function"==typeof this.props.yes){let e=[this.$id];3===this.type&&e.unshift(this.prompt),this.props.yes.apply(this,e)}else this.close()},handleCancel:function(){"function"==typeof this.props.no?this.props.no.call(this,this.$id):this.close()},close:function(){close(this.$id)},cancelBubble:function(e){e.cancelBubble=!0}},mounted:function(){"function"==typeof this.props.success&&this.props.success.call(this)}},4===this.init.state.type&&(this.init.methods.autoSize=function(){let{layer:e,frame:t}=this.$refs;t.onload=function(){setTimeout(function(){try{let o=t.contentWindow.document.body,{clientWidth:s,clientHeight:n}=o;Anot(e).css({width:s,height:n,marginLeft:-s/2,marginTop:-n/2}),Anot(t).css({height:n})}catch(e){}},500)}}),this}create(){let{state:e,$id:t}=this.init,o=document.createElement("div"),s=document.createElement("div");if(o.setAttribute("anot",t),o.setAttribute(":click","onMaskClick"),o.classList.add("do-layer"),e.mask&&(o.classList.add("mask"),e.container&&e.container!==document.body&&o.classList.add("inner")),e.maskColor&&(o.style.background=e.maskColor),s.classList.add("layer-box"),s.classList.add("skin-normal"),e.extraClass&&(s.classList.add(e.extraClass),delete e.extraClass),"string"==typeof e.shift)s.classList.add("__"+e.shift);else for(let t in e.shift){let o=e.shift[t];o+=isFinite(o)?"px":"",s.style.cssText+=`${t}: ${o};`}e.toast?s.classList.add("type-toast"):s.classList.add("type-"+e.type),s.setAttribute("ref","layer"),s.setAttribute(":click","cancelBubble"),s.style.cssText+="border-radius:"+e.radius+"px",e.menubar||e.fixed||(s.setAttribute(":drag",""),s.setAttribute("data-limit","window"));var n="";"auto"!==e.area[0]&&(n+="width: "+e.area[0]+";"),"auto"!==e.area[1]&&(n+="height: "+e.area[1]+";");let i="";return 5===e.type&&(i+=''),s.innerHTML=`\n ${this.mkMenubar()}\n \n\n ${6===e.type?this.mkLoading(e.load):""}\n \n ${this.mkCtrl()}\n ${i}\n `,delete e.wrap,o.appendChild(s),[o,s]}mkLoading(e){return`\n
\n \n ${repeat(1===e?'':"",this.dot[e])}\n \n
\n `}mkMenubar(){let{menubar:e,fixed:t}=this.init.state,o="";return e&&(o=`\n
\n
\n `),o}mkCtrl(){let{type:e}=this.init.state;if(e>3)return"";{let t="",o='\n \n ';return e>1&&(o='\n \n '+o),t=`\n
\n ${o}\n
\n `}}append(){let{state:e,$id:t}=this.init,o=e.container;return e.type<4&&(unique&&close(unique),unique=t),layerDom[t]=this.create(),delete e.toast,this.toast=!0,o||(o=document.body),o.appendChild(layerDom[t][0]),this.vm=Anot(this.init),this}show(){let{state:e,$id:t}=this.init,o=(this.vm,e.container);setTimeout(function(){let s={background:e.background},n=getComputedStyle(layerDom[t][1]);if(5===e.type){s.color=e.color,s.opacity=1;let i=Anot(o),a=i[0].querySelector(".arrow"),r=i.innerWidth(),l=i.innerHeight(),c=i.offset().left-$doc.scrollLeft(),d=i.offset().top-$doc.scrollTop(),p=parseInt(n.width),f=parseInt(n.height),y=["top"];Anot(layerDom[t][1]).css(s),i.bind("mouseenter",o=>{let s={visibility:"visible"};c=i.offset().left-$doc.scrollLeft(),(d=i.offset().top-$doc.scrollTop())+18window.innerWidth?(s.left=c+.3*r-p,y[1]="left"):s.left=c+.7*r,a.classList.add("offset-"+y.join("-")),Anot(layerDom[t][1]).css(s)}),i.bind("mouseleave",()=>{setTimeout(()=>{a.classList.remove("offset-"+y.join("-")),y=["top"],a.style.borderBottomColor="",a.style.borderTopColor="",layerDom[t][1].style.visibility="hidden"},100)})}else{let o={opacity:1};e.offset?(o.top=fixOffset(e.offset[0]),o.right=fixOffset(e.offset[1]),o.bottom=fixOffset(e.offset[2]),o.left=fixOffset(e.offset[3]),"auto"===o.left&&"auto"===o.right&&(o.left="50%",s.marginLeft=-parseInt(n.width)/2),"auto"===o.top&&"auto"===o.bottom&&(o.top="50%",s.marginTop=-parseInt(n.height)/2)):s=Object.assign(s,{marginLeft:-parseInt(n.width)/2,marginTop:-parseInt(n.height)/2}),Anot(layerDom[t][1]).css(s),setTimeout(()=>{document.body.style.overflow="hidden",layerDom[t][1].classList.add("shift"),setTimeout(s=>{Anot(layerDom[t][1]).css(o),setTimeout(o=>{try{layerDom[t][1].classList.remove("shift"),layerDom[t][1].classList.remove("__"+e.shift)}catch(e){}},500)},50)},50)}},4),e.type>3&&(e.timeout>0?(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{clearTimeout(this.timeout),close(t),6===e.type&&this.vm.props.yes.call(this.vm,t)},e.timeout)):6===e.type&&this.vm.props.yes.call(this.vm,t))}}const _layer={alert(e,t,o){let s={content:e,fixed:!0};return"function"==typeof t?s.yes=t:(t&&(s.title=t+""),o&&"function"==typeof o&&(s.yes=o)),_layer.open(s)},confirm(e,t,o,s){let n={content:e,fixed:!0,type:2};return"function"==typeof t?(n.yes=t,"function"==typeof o&&(n.no=o)):(t&&(n.title=t+""),o&&"function"==typeof o&&(n.yes=o),s&&"function"==typeof s&&(n.no=s)),_layer.open(n)},frame(e,t={}){let o={content:``,menubar:!1,maskClose:!0,type:4,...t};return _layer.open(o)},toast(e,t="info",o=2500){switch("number"==typeof t&&(o=t,t="info"),t){case"info":case"warn":break;case"error":t="deny";break;default:t="info"}let s={content:`\n \n \n ${e}\n `,menubar:!1,mask:!1,type:7,shift:"tc",timeout:o,offset:[50,"auto"],fixed:!0,toast:!0};return _layer.open(s)},load:(e,t,o)=>(e=(e>>>=0)<1?1:e>4?4:e,"function"==typeof t?(o=t,t=null):(t instanceof HTMLElement||(t=null),"function"!=typeof o&&(o=Anot.noop)),_layer.open({container:t,type:6,load:e,yes:o,menubar:!1,background:"none",shift:"ct",fixed:!0})),tips:(e,t,o={})=>t instanceof HTMLElement?(o.background||(o.background="rgba(0,0,0,.5)"),o.color||(o.color="#fff"),Object.assign(o,{container:t,content:e,type:5,fixed:!0,mask:!1,menubar:!1,timeout:0}),_layer.open(o)):Anot.error(lang.NEED_CONTAINER),prompt(e,t){if("function"!=typeof t)return console.error("argument [callback] requires a function, but "+typeof t+" given");let o={type:3,prompt:"",title:e,content:'',fixed:!0,yes:t};return _layer.open(o)},close:close,open(e){if("string"==typeof e){if(layerObj[e="layerwrap-"+e])return layerObj[e].show?e:(layerObj[e].show=!0,layerObj[e].parentElem.appendChild(layerDom[e][0]),layerDom[e][0].querySelector(".layer-content").appendChild(layerObj[e].wrap),layerObj[e].wrap.style.display="",Anot.vmodels[e]||Anot(layerObj[e].obj.init),layerObj[e].obj.show(),e);throw new Error(lang.ERROR)}return new __layer__(e).init.$id},version:Anot.ui.layer};Anot.directive("layer",{priority:8090,init:function(e){e.element.removeAttribute(e.name),e.param&&"tips"===e.param||(e.param="",e.element.style.display="none")},update:function(e){if(!e)return console.error(this),console.error(`SyntaxError: Unexpected [${this.name}=${this.expr}]`);let t=Object.assign({type:7,wrap:!0},this.element.dataset);if(this.param){if("tips"===this.param){let o=document.createElement("div"),s=document.createElement("span"),n=document.createElement("i");o.className="do-layer__tips",s.className="layer-content",n.className="arrow",s.textContent=e,o.appendChild(s),o.appendChild(n),this.element.appendChild(o),t.color&&(i.color=t.color),t.color&&(i.background=t.background);let i={},a=getComputedStyle(o),r=Anot(this.element),l=r.innerWidth(),c=r.innerHeight(),d=r.offset().left-$doc.scrollLeft(),p=r.offset().top-$doc.scrollTop(),f=parseInt(a.width),y=parseInt(a.height),u=["top"];Anot(o).css(i),r.bind("mouseenter",e=>{let s={visibility:"visible"};d=r.offset().left-$doc.scrollLeft(),(p=r.offset().top-$doc.scrollTop())+18window.innerWidth?(s.left=d+.3*l-f,u[1]="left"):s.left=d+.7*l,n.classList.add("offset-"+u.join("-")),Anot(o).css(s)}),r.bind("mouseleave",()=>{setTimeout(()=>{n.classList.remove("offset-"+u.join("-")),u=["top"],n.style.borderBottomColor="",n.style.borderTopColor="",o.style.visibility="hidden"},100)})}}else{let o={$id:"layerwrap-"+e,state:t,props:{}};t.hasOwnProperty("area")&&(t.area=t.area.split(",")),t.hasOwnProperty("offset")&&(t.offset=t.offset.split(",")),t.hasOwnProperty("btns")&&(t.btns=t.btns.split(",")),t.hasOwnProperty("menubar")||(t.menubar=!1);let s=(new __layer__).__init__(o);for(let e in this.element.dataset)delete this.element.dataset[e];layerObj[s.init.$id]={obj:s,parentElem:this.element.parentNode,wrap:this.element,show:!1},layerDom[s.init.$id]=s.create()}}}),window.layer=_layer;export default _layer; \ No newline at end of file +"use strict";import "../drag/index.js";importCss("/css/layer-normal.css");Anot.ui.layer="1.0.0-normal";const log=console.log,LANGUAGES={en:{TITLE:"Dialog",YES_BTN:"OK",NO_BTN:"Cancel",ERROR:"The layer instance is not exists",NEED_CONTAINER:'layer "tips" require a DOM object as container'},zh:{TITLE:"提示",YES_BTN:"确定",NO_BTN:"取消",ERROR:"要关闭的layer实例不存在",NEED_CONTAINER:"tips类型需要指定一个元素节点作为容器"},"zh-TW":{TITLE:"提示",YES_BTN:"確定",NO_BTN:"取消",ERROR:"要關閉的layer實例不存在",NEED_CONTAINER:"tips类型需要指定一個元素節點作爲容器"}};LANGUAGES["zh-CN"]=LANGUAGES.zh;const lang=LANGUAGES[window.__ENV_LANG__||navigator.language]||LANGUAGES.en;let layerDom={},layerObj={},unique=null,lid=0,defconf={type:1,background:"#fff",mask:!0,maskClose:!1,maskColor:null,radius:"0px",area:["auto","auto"],title:lang.TITLE,menubar:!0,content:"",fixed:!1,shift:{},offset:{},btns:[lang.YES_BTN,lang.NO_BTN]};const $doc=Anot(document),uuid=function(){return"layer-"+lid++},close=function(e){if("string"!=typeof e&&"number"!=typeof e)return Anot.error(lang.ERROR);if(/^layerwrap\-/.test(e)||layerObj["layerwrap-"+e])try{if(e=(layerObj["layerwrap-"+e]?"layerwrap-":"")+e,!layerObj[e].show)return;layerObj[e].parentElem.replaceChild(layerObj[e].wrap,layerDom[e][0]),layerObj[e].wrap.style.display="none",layerObj[e].show=!1}catch(e){}else{unique=null;try{layerDom[e][0].classList.add("shift"),layerDom[e][1].classList.add("shift"),layerDom[e][0].style.opacity="",layerDom[e][1].style.opacity=0,setTimeout(function(){layerDom[e][0].parentNode.removeChild(layerDom[e][0]),delete layerDom[e],delete Anot.vmodels[e]},200)}catch(e){}}document.body.style.overflow=""},fixOffset=function(e){for(let t in e)"auto"===e[t]||!e[t]&&0!==e[t]?delete e[t]:isFinite(e[t])&&(e[t]+="px");return e};class __layer__{get dot(){return{1:1,2:5,3:5,4:9}}constructor(e){if(e){let{yes:t,no:o,success:s}=e;delete e.yes,delete e.no,delete e.success,this.__init__({state:{...e},props:{yes:t,no:o,success:s}}).append().show()}this.timeout=null}__init__(e){let t=e.$id||uuid();return this.init={$id:t,state:{...defconf,...e.state},props:e.props,skip:["area","shift","offset","mask","maskClose","container","follow"],methods:{shake(){this.$refs.layer.classList.add("scale"),setTimeout(()=>{this.$refs.layer.classList.remove("scale")},100)},onMaskClick:function(){this.type<4&&!this.maskClose?this.shake():this.maskClose&&this.close()},handleConfirm:function(){if(3===this.type&&!this.prompt)return this.shake();if("function"==typeof this.props.yes){let e=[this.$id];3===this.type&&e.unshift(this.prompt),this.props.yes.apply(this,e)}else this.close()},handleCancel:function(){"function"==typeof this.props.no?this.props.no.call(this,this.$id):this.close()},close:function(){close(this.$id)},cancelBubble:function(e){e.cancelBubble=!0}},mounted:function(){"function"==typeof this.props.success&&this.props.success.call(this)}},4===this.init.state.type&&(this.init.methods.autoSize=function(){let{layer:e,frame:t}=this.$refs;t.onload=function(){try{let o=t.contentWindow.document.body,{clientWidth:s,clientHeight:n}=o;e.style.cssText+=`width: ${s}px;height: ${n}px;`,t.style.cssText+=`height: ${n}px;`}catch(e){}}}),this}create(){let{state:e,$id:t}=this.init,o=document.createElement("div"),s=document.createElement("div");if(o.setAttribute("anot",t),o.setAttribute(":click","onMaskClick"),o.classList.add("do-layer"),e.mask&&(o.classList.add("mask"),e.container&&e.container!==document.body&&o.classList.add("inner")),e.maskColor&&(o.style.background=e.maskColor),s.classList.add("layer-box"),s.classList.add("skin-normal"),e.extraClass&&(s.classList.add(e.extraClass),delete e.extraClass),e.shift){fixOffset(e.shift);for(let t in e.shift){let o=e.shift[t];o+=isFinite(o)?"px":"",s.style.cssText+=`${t}: ${o};`}}e.toast?s.classList.add("type-toast"):s.classList.add("type-"+e.type),s.setAttribute("ref","layer"),s.setAttribute(":click","cancelBubble"),s.style.cssText+="border-radius:"+e.radius+"px",e.menubar||e.fixed||(s.setAttribute(":drag",""),s.setAttribute("data-limit","window"));var n="";"auto"!==e.area[0]&&(n+="width: "+e.area[0]+";"),"auto"!==e.area[1]&&(n+="height: "+e.area[1]+";");let i="";return 5===e.type&&(i+=''),s.innerHTML=`\n ${this.mkMenubar()}\n \n\n ${6===e.type?this.mkLoading(e.load):""}\n \n ${this.mkCtrl()}\n ${i}\n `,delete e.wrap,o.appendChild(s),[o,s]}mkLoading(e){return`\n
\n \n ${(1===e?'':"").repeat(this.dot[e])}\n \n
\n `}mkMenubar(){let{menubar:e,fixed:t}=this.init.state,o="";return e&&(o=`\n
\n
\n `),o}mkCtrl(){let{type:e}=this.init.state;if(e>3)return"";{let t="",o='\n \n ';return e>1&&(o='\n \n '+o),t=`\n
\n ${o}\n
\n `}}append(){let{state:e,$id:t}=this.init,o=e.container;return e.type<4&&(unique&&close(unique),unique=t),layerDom[t]=this.create(),delete e.toast,this.toast=!0,o||(o=document.body),o.appendChild(layerDom[t][0]),this.vm=Anot(this.init),this}show(){let{state:e,$id:t}=this.init,o=(this.vm,e.container);setTimeout(function(){let s={background:e.background},n=Anot(layerDom[t][1]);if(5===e.type){let i=getComputedStyle(layerDom[t][1]);s.color=e.color,s.opacity=1;let a=Anot(o),r=a[0].querySelector(".arrow"),l=a.innerWidth(),c=a.innerHeight(),d=a.offset().left-$doc.scrollLeft(),p=a.offset().top-$doc.scrollTop(),y=parseInt(i.width),f=parseInt(i.height),u=["top"];Anot(layerDom[t][1]).css(s),a.bind("mouseenter",t=>{let o={visibility:"visible"};d=a.offset().left-$doc.scrollLeft(),(p=a.offset().top-$doc.scrollTop())+18window.innerWidth?(o.left=d+.3*l-y,u[1]="left"):o.left=d+.7*l,r.classList.add("offset-"+u.join("-")),n.css(o)}),a.bind("mouseleave",()=>{setTimeout(()=>{r.classList.remove("offset-"+u.join("-")),u=["top"],r.style.borderBottomColor="",r.style.borderTopColor="",layerDom[t][1].style.visibility="hidden"},100)})}else{let o={opacity:1};e.offset&&(fixOffset(e.offset),Object.assign(o,e.offset)),n.css(s),setTimeout(()=>{document.body.style.overflow="hidden",layerDom[t][1].classList.add("shift"),setTimeout(e=>{n.css(o),setTimeout(e=>{try{layerDom[t][1].classList.remove("shift")}catch(e){}},500)},50)},50)}},4),e.type>3&&(e.timeout>0?(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{clearTimeout(this.timeout),close(t),6===e.type&&this.vm.props.yes.call(this.vm,t)},e.timeout)):6===e.type&&this.vm.props.yes.call(this.vm,t))}}const _layer={alert(e,t,o){let s={content:e,fixed:!0};return"function"==typeof t?s.yes=t:(t&&(s.title=t+""),o&&"function"==typeof o&&(s.yes=o)),_layer.open(s)},confirm(e,t,o,s){let n={content:e,fixed:!0,type:2};return"function"==typeof t?(n.yes=t,"function"==typeof o&&(n.no=o)):(t&&(n.title=t+""),o&&"function"==typeof o&&(n.yes=o),s&&"function"==typeof s&&(n.no=s)),_layer.open(n)},frame(e,t={}){let o={content:``,menubar:!1,maskClose:!0,type:4,...t};return _layer.open(o)},toast(e,t="info",o=2500){switch("number"==typeof t&&(o=t,t="info"),t){case"info":case"warn":break;case"error":t="deny";break;default:t="info"}let s={content:`\n \n \n ${e}\n `,menubar:!1,mask:!1,type:7,shift:{top:0},timeout:o,offset:{top:50},fixed:!0,toast:!0};return _layer.open(s)},load:(e,t,o)=>(e=(e>>>=0)<1?1:e>4?4:e,"function"==typeof t?(o=t,t=null):(t instanceof HTMLElement||(t=null),"function"!=typeof o&&(o=Anot.noop)),_layer.open({container:t,type:6,load:e,yes:o,menubar:!1,background:"none",fixed:!0})),tips:(e,t,o={})=>t instanceof HTMLElement?(o.background||(o.background="rgba(0,0,0,.5)"),o.color||(o.color="#fff"),Object.assign(o,{container:t,content:e,type:5,fixed:!0,mask:!1,menubar:!1,timeout:0}),_layer.open(o)):Anot.error(lang.NEED_CONTAINER),prompt(e,t){if("function"!=typeof t)return console.error("argument [callback] requires a function, but "+typeof t+" given");let o={type:3,prompt:"",title:e,content:'',fixed:!0,yes:t};return _layer.open(o)},close:close,open(e){if("string"==typeof e){if(layerObj[e="layerwrap-"+e])return layerObj[e].show?e:(layerObj[e].show=!0,layerObj[e].parentElem.appendChild(layerDom[e][0]),layerDom[e][0].querySelector(".layer-content").appendChild(layerObj[e].wrap),layerObj[e].wrap.style.display="",Anot.vmodels[e]||Anot(layerObj[e].obj.init),layerObj[e].obj.show(),e);throw new Error(lang.ERROR)}return new __layer__(e).init.$id},version:Anot.ui.layer};Anot.directive("layer",{priority:8090,init:function(e){e.element.removeAttribute(e.name),e.param&&"tips"===e.param||(e.param="",e.element.style.display="none")},update:function(e){if(!e)return console.error(`SyntaxError: Unexpected [${this.name}=${this.expr}]`);let t=Object.assign({type:7,wrap:!0},this.element.dataset);if(this.param){if("tips"===this.param){let o=document.createElement("div"),s=document.createElement("span"),n=document.createElement("i"),i=Anot(this.element),{position:a}=getComputedStyle(this.element);o.className="do-layer__tips",s.className="layer-content",n.className="arrow",s.textContent=e,o.appendChild(s),o.appendChild(n),"static"===a&&(this.element.style.position="relative"),this.element.appendChild(o);let r={};t.color&&(r.color=t.color),t.color&&(r.background=t.background);let l=i.innerWidth(),c=i.innerHeight(),d=["top"];Anot(o).css(r),i.bind("mouseenter",e=>{let s={visibility:"visible"},a=o.clientWidth,r=o.clientHeight,{left:p,top:y}=i.offset(),f=p-$doc.scrollLeft();y-$doc.scrollTop()window.innerWidth?(s.left=.3*l-a,d[1]="left"):s.left=.7*l,n.classList.add("offset-"+d.join("-")),Anot(o).css(s)}),i.bind("mouseleave",()=>{setTimeout(()=>{n.classList.remove("offset-"+d.join("-")),d=["top"],n.style.borderBottomColor="",n.style.borderTopColor="",o.style.visibility="hidden"},100)})}}else{let o={$id:"layerwrap-"+e,state:t,props:{}};t.hasOwnProperty("area")&&(t.area=t.area.split(",")),t.hasOwnProperty("shift")&&(t.shift=fixOffset(new Function(`return ${t.shift}`)())),t.hasOwnProperty("offset")&&(t.offset=fixOffset(new Function(`return ${t.offset}`)())),t.hasOwnProperty("btns")&&(t.btns=t.btns.split(",")),t.hasOwnProperty("menubar")||(t.menubar=!1);let s=(new __layer__).__init__(o);for(let e in this.element.dataset)delete this.element.dataset[e];layerObj[s.init.$id]={obj:s,parentElem:this.element.parentNode,wrap:this.element,show:!1},layerDom[s.init.$id]=s.create()}}}),window.layer=_layer;export default _layer; \ No newline at end of file diff --git a/src/lib/request/index.js b/src/lib/request/index.js index 1036cee..5a615eb 100644 --- a/src/lib/request/index.js +++ b/src/lib/request/index.js @@ -1 +1 @@ -"use strict";import Format from "./lib/format.js";const rlocalProtocol=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,rheaders=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,encode=encodeURIComponent,decode=decodeURIComponent,toS=Object.prototype.toString,win=window,doc=win.document,noop=function(t,e){this.defer.resolve(e)},Xhr=function(){return new XMLHttpRequest},supportCors="withCredentials"in Xhr();let isLocal=!1;try{isLocal=rlocalProtocol.test(location.ptyperotocol)}catch(t){}let originAnchor=doc.createElement("a");originAnchor.href=location.href;const noBodyMethods=["GET","HEAD","JSONP"],error={10001:"argument url is required",10002:'method "set" required an object or 2 args',10003:'method "send" can not call by different way',10004:'method "send" arguments error',10005:'method "send" required an object/string or 2 args',10006:'method "field" required an object or 2 args',10011:"Promise required a callback",10012:"Parse error",10104:"Request pending...",10200:"ok",10204:"no content",10304:"not modified",10500:"Internal Server Error",10504:"Connected timeout",form:"application/x-www-form-urlencoded; charset=UTF-8",json:"application/json; charset=UTF-8",text:"text/plain; charset=UTF-8"},convert={text:t=>t,xml:(t,e)=>void 0!==e?e:Format.parseXML(t),html:t=>Format.parseHTML(t),json:t=>JSON.parse(t),script:t=>Format.parseJS(t),jsonp(t){var e=request.cache[t];return delete request.cache[t],e}};class _Request{constructor(t="",e="GET"){if(!t)throw new Error(error[10001]);e=e.toUpperCase(),this.transport=Object.create(null),this.xhr=Xhr(),this.defer=Promise.defer(),this.opt={url:t,method:e,form:null,data:{},headers:{},timeoutID:0,uuid:Math.random().toString(16).slice(2)}}_formData(){if(this.opt.form){let t=Format.parseForm(this.opt.form);Format.merge(this.opt.data,t)}let t=new FormData;for(let e in this.opt.data){let r=this.opt.data[e];Array.isArray(r)?r.forEach(function(r){t.append(e+"[]",r)}):t.append(e,this.opt.data[e])}return t}_jsonp(t){win[t]=function(e){delete win[t],request.cache[t]=e}}_dispatch(t){if(!this.transport)return this.defer.reject(error[10104]);let e={response:{url:this.opt.url,headers:{"content-type":""}},request:{url:this.opt.url,headers:this.opt.headers},status:null===t?504:200,statusText:null===t?"Connected timeout":"ok",text:"",body:"",error:null};if(clearTimeout(this.opt.timeoutID),this.transport.nodeType&&"JSONP"===this.opt.method){if(this.transport.parentNode.removeChild(this.transport),!t){(!this.transport.readyState||"loaded"===this.transport.readyState||"complete"===this.transport.readyState)&&(e.body=convert.jsonp(this.opt.data.callback),e.text=JSON.stringify(e.body))}this.defer.resolve(e)}else{let o=!t&&(this.transport.status>=200&&this.transport.status<400);(!t&&this.transport.getAllResponseHeaders().split("\n")||[]).forEach(function(t,r){(t=t.trim())&&(t=t.split(":"),e.response.headers[t.shift().toLowerCase()]=t.join(":").trim())}),o?(e.status=this.transport.status,204===e.status?e.statusText=error[10204]:304===e.status&&(e.statusText=error[10304])):(e.status=t?504:this.transport.status||500,e.statusText=t?error[10504]:this.transport.statusText||error[10500],e.error=new Error(e.statusText));try{var r=e.response.headers["content-type"].match(/json|xml|script|html/i)||["text"];r=r[0].toLowerCase(),e.text=t?"":this.transport.responseText||this.transport.responseXML,e.body=convert[r](e.text,!t&&this.transport.responseXML)}catch(t){e.error=t,e.statusText=error[10012]}e.status>=200&&e.status<400?this.defer.resolve(e):this.defer.reject(e)}delete this.transport,delete this.opt,delete this.xhr}type(t){return"form-data"===this.opt.formType?this:(this.opt.formType=t||"form","form"===t||noBodyMethods.indexOf(this.opt.method)>-1?this.set("content-type",error.form):"json"===t?this.set("content-type",error.json):this.set("content-type",error.text),this)}set(t,e){if(!this.transport)return this;let r={};if(1===arguments.length){if("object"!=typeof t)return this.defer.reject(error[10002]),this;r=t}else{if(2!==arguments.length)return this.defer.reject(error[10002]),this;"string"==typeof t&&void 0!==e&&(r[t]=e)}for(let t in r){let e=r[t];t=t.toLowerCase(),this.opt.headers[t]=e}return this}send(t,e){if(!this.transport)return this;if(1===arguments.length)if("string"==typeof t)this.opt.data=t;else if("object"==typeof t){if("object"!=typeof this.opt.data)return this.defer.reject(error[10003]),this;Format.merge(this.opt.data,t)}else this.defer.reject(error[10004]);else if(2===arguments.length){if("string"!=typeof t)return this.defer.reject(error[10004]),this;void 0===e?delete this.opt.data[t]:this.opt.data[t]=e}else this.defer.reject(error[10005]);return this}field(t,e){return this.transport?(this.opt.formType="form-data",this.opt.method="POST",this.opt.data&&"object"==typeof this.opt.data||(this.opt.data={}),1===arguments.length&&"object"==typeof t?Format.merge(this.opt.data,t):2===arguments.length?this.opt.data[t]=e:this.defer.reject(error[10006]),this):this}cache(t){return this.transport?(noBodyMethods.indexOf(this.opt.method)>-1&&(this.opt.cache=!!t),this):this}abort(){return delete this.transport,this.opt.form||this.xhr.abort(),this}timeout(t){return"number"!=typeof t||t<1?this:(this.opt.timeout=t,this)}form(t){return"object"==typeof t&&"FORM"===t.nodeName&&(this.opt.method="POST",this.opt.form=t),this}then(t){if("function"!=typeof t)return this.defer.reject(error[10011]),this.defer.promise;if(!this.transport)return this.defer.promise;if(this.opt.url=this.opt.url.replace(/#.*$/,"").replace(/^\/\//,location.protocol+"//"),"boolean"!=typeof this.opt.crossDomain){var e=doc.createElement("a");try{e.href=this.opt.url;var r="1"[0]?e.href:e.getAttribute("href",4);e.href=r,e.async=!0,this.opt.crossDomain=originAnchor.protocol!==e.protocol||originAnchor.host!==e.host}catch(t){this.opt.crossDomain=!0}}if("JSONP"===this.opt.method&&(this.opt.crossDomain?(this.opt.data.callback=this.opt.data.callback||"jsonp"+request.cid++,this._jsonp(this.opt.data.callback)):this.opt.method="GET"),"JSONP"!==this.opt.method&&this.set("X-Requested-With","XMLHttpRequest"),this.opt.crossDomain&&supportCors&&(this.xhr.withCredentials=!0),this.opt.param=Format.param(this.opt.data),this.opt.formType||this.type("form"),noBodyMethods.indexOf(this.opt.method)<0?"form-data"===this.opt.formType?(delete this.opt.headers["content-type"],this.opt.param=this._formData()):"form"!==this.opt.formType&&("object"==typeof this.opt.data&&(this.opt.data=JSON.stringify(this.opt.data)),this.opt.param=this.opt.data):(this.opt.param&&(this.opt.url+=(/\?/.test(this.opt.url)?"&":"?")+this.opt.param),!1===this.opt.cache&&(this.opt.url+=(/\?/.test(this.opt.url)?"&":"?")+"_="+Math.random())),"JSONP"===this.opt.method)this.transport=doc.createElement("script"),this.transport.onerror=this.transport.onload=(()=>{this._dispatch()}),this.transport.src=this.opt.url,doc.head.insertBefore(this.transport,doc.head.firstChild),this.opt.timeout&&this.opt.timeout>0&&(this.opt.timeoutID=setTimeout(()=>{this.transport.onerror=this.transport.onload=null,this._dispatch(!0)},this.opt.timeout));else{for(var o in this.transport=this.xhr,this.xhr.onreadystatechange=(t=>{this.opt.timeout&&this.opt.timeout>0&&(this.opt["time"+this.xhr.readyState]=t.timeStamp,4===this.xhr.readyState&&(this.opt.isTimeout=this.opt.time4-this.opt.time1>this.opt.timeout)),4===this.xhr.readyState&&this._dispatch(this.opt.isTimeout)}),this.xhr.open(this.opt.method,this.opt.url,!0),this.opt.headers)this.xhr.setRequestHeader(o,this.opt.headers[o]);this.xhr.send(this.opt.param),this.opt.timeout&&this.opt.timeout>0&&(this.xhr.timeout=this.opt.timeout)}return this.defer.promise.then(e=>t(e))}}win.request||(win.request={get:t=>new _Request(t,"GET"),post:t=>new _Request(t,"POST"),jsonp:t=>new _Request(t,"JSONP"),open:(t,e="GET")=>new _Request(t,e),cache:{},cid:0,version:"1.1.0-normal"},Anot.ui.request=request.version);export default request; \ No newline at end of file +"use strict";import Format from "./lib/format.js";import format from "./lib/format.js";const rlocalProtocol=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,log=console.log,noop=function(t,e){this.defer.resolve(e)};let isLocal=!1;try{isLocal=rlocalProtocol.test(location.ptyperotocol)}catch(t){}let originAnchor=document.createElement("a");originAnchor.href=location.href;const NOBODY_METHODS=["GET","HEAD"],ERRORS={10001:"Argument url is required",10012:"Parse error",10100:"Request canceled",10104:"Request pending...",10200:"Ok",10204:"No content",10304:"Not modified",10500:"Internal Server Error",10504:"Connected timeout"},FORM_TYPES={form:"application/x-www-form-urlencoded; charset=UTF-8",json:"application/json; charset=UTF-8",text:"text/plain; charset=UTF-8"},convert={text:t=>t,xml:(t,e)=>void 0!==e?e:Format.parseXML(t),html:t=>Format.parseHTML(t),json:t=>JSON.parse(t),script:t=>Format.parseJS(t)};class _Request{constructor(t="",e="GET",s={}){if(!t)throw new Error(ERRORS[10001]);return t=t.replace(/#.*$/,"").replace(/^\/\//,location.protocol+"//"),e=e.toUpperCase(),this.xhr=new XMLHttpRequest,this.defer=Promise.defer(),this.opt={url:t,method:e,headers:{},data:{},dataType:"text",withCredentials:!1},this.defer.promise.abort=(()=>{this.cancel=!0,this.xhr.abort()}),this.__next__(Object.assign({},request.__INIT__,s)),this.defer.promise}__next__(t){t.headers&&Object.assign(this.opt.headers,t.headers);let e=!1;if(t.formType)switch(t.formType){case"form":this.__set__("form");break;case"json":this.__set__("json");break;case"form-data":this.opt.method="POST",e=!0;break;default:NOBODY_METHODS.includes(this.opt.method)?this.__set__("form"):this.__set__("text")}else this.__set__("form");if(t.cache&&NOBODY_METHODS.includes(this.opt.method)&&(this.opt.cache=!0),t.timeout=t.timeout>>>0,t.timeout>0&&(this.opt.timeout=t.timeout),t.data){switch(typeof t.data){case"number":case"string":this.__set__("text"),this.opt.data=t.data;break;case"object":"FORM"===t.data.nodeName?(this.opt.method=t.data.method.toUpperCase()||"POST",this.opt.data=Format.parseForm(t.data),(e=this.opt.data.constructor===FormData)&&delete this.opt.headers["content-type"]):t.data.constructor===FormData?(e=!0,this.opt.method="POST",delete this.opt.headers["content-type"],this.opt.data=t.data):this.opt.data=e?Format.mkFormData(t.data):t.data}}t.withCredentials&&(this.opt.withCredentials=!0);try{let t=document.createElement("a");t.href=this.opt.url,this.opt.crossDomain=originAnchor.protocol!==t.protocol||originAnchor.host!==t.host}catch(t){}this.opt.crossDomain?this.opt.withCredentials&&(this.xhr.withCredentials=!0,this.opt.headers["X-Requested-With"]="XMLHttpRequest"):this.opt.headers["X-Requested-With"]="XMLHttpRequest",!NOBODY_METHODS.includes(this.opt.method)?e||("json"===t.formType?this.opt.data=JSON.stringify(this.opt.data):this.opt.data=Format.param(this.opt.data)):(this.opt.data=Format.param(this.opt.data),this.opt.url+=(/\?/.test(this.opt.url)?"&":"?")+this.opt.data,!1===this.opt.cache&&(this.opt.url+=(/\?/.test(this.opt.url)?"&":"?")+"_="+Math.random())),t.dataType&&(this.opt.dataType=t.dataType.toLowerCase()),this.xhr.responseType=this.opt.dataType,this.xhr.onreadystatechange=(t=>{this.opt.timeout>0&&(this.opt["time"+this.xhr.readyState]=t.timeStamp,4===this.xhr.readyState&&(this.opt.isTimeout=this.opt.time4-this.opt.time1>this.opt.timeout)),4===this.xhr.readyState&&this.__dispatch__(this.opt.isTimeout)}),this.xhr.open(this.opt.method,this.opt.url,!0);for(let t in this.opt.headers)this.xhr.setRequestHeader(t,this.opt.headers[t]);this.xhr.send(this.opt.data),this.opt.timeout&&this.opt.timeout>0&&(this.xhr.timeout=this.opt.timeout)}__set__(t){this.opt.headers["content-type"]=FORM_TYPES[t]}__dispatch__(t){let e={status:200,statusText:"ok",text:"",body:"",error:null};if(this.cancel)return this.__cancel__(e);if(t)return this.__timeout__(e);let s=this.xhr.status>=200&&this.xhr.status<400,o=this.xhr.getAllResponseHeaders().split("\n")||[],r="";for(let t of o)if(t=t.trim()){if("content-type"===(t=t.split(":")).shift().toLowerCase()){r=t.join(":").trim().toLowerCase();break}}switch(s?(e.status=this.xhr.status,204===e.status?e.statusText=ERRORS[10204]:304===e.status&&(e.statusText=ERRORS[10304])):(e.status=this.xhr.status||500,e.statusText=this.xhr.statusText||ERRORS[10500],e.error=new Error(e.statusText)),this.opt.dataType){case"arraybuffer":case"blob":case"document":case"json":e.text=e.body=this.xhr.response;break;default:try{let t=r.match(/json|xml|script|html/);t=t&&t[0].toLowerCase()||"text",e.text=this.xhr.response,e.body=convert[t](e.text,this.xhr.response)}catch(t){e.error=t,e.statusText=ERRORS[10012]}}this.__success__(s,e)}__success__(t,e){t?this.defer.resolve(e):this.defer.reject(e),delete this.xhr,delete this.opt,delete this.defer}__cancel__(t){t.status=0,t.statusText=ERRORS[10100],t.error=new Error(ERRORS[10100]),this.defer.reject(t),delete this.xhr,delete this.opt,delete this.defer}__timeout__(t){t.status=504,t.statusText=ERRORS[10504],t.error=new Error(ERRORS[10504]),this.defer.reject(t),delete this.xhr,delete this.opt,delete this.defer}}window.request||(window.request={get:(t,e={})=>new _Request(t,"GET",e),post:(t,e={})=>new _Request(t,"POST",e),upload(t,e={}){return e.formType="form-data",this.post(t,e)},download(t,e={}){return e.dataType="blob",this.get(t,e)},open:(t,e="GET",s={})=>("object"==typeof e&&(s=e,e="GET"),new _Request(t,e,s)),version:"2.0.0-normal",init(t={}){this.__INIT__=t}},Anot.ui.request=request.version);export default request; \ No newline at end of file diff --git a/src/lib/request/lib/format.js b/src/lib/request/lib/format.js index 8275e56..4f48fb0 100644 --- a/src/lib/request/lib/format.js +++ b/src/lib/request/lib/format.js @@ -1 +1 @@ -"use strict";function serialize(e,t,r){var o;if(Array.isArray(t))t.forEach(function(t,a){o=e?e+"["+(Array.isArray(t)?a:"")+"]":a,"object"==typeof t?serialize(o,t,r):r(o,t)});else for(var a in t)o=e?e+"["+a+"]":a,"object"==typeof t[a]?serialize(o,t[a],r):r(o,t[a])}var toS=Object.prototype.toString,doc=window.document,encode=encodeURIComponent,decode=decodeURIComponent,TagHooks=function(){this.option=doc.createElement("select"),this.thead=doc.createElement("table"),this.td=doc.createElement("tr"),this.area=doc.createElement("map"),this.tr=doc.createElement("tbody"),this.col=doc.createElement("colgroup"),this.legend=doc.createElement("fieldset"),this._default=doc.createElement("div"),this.g=doc.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},Format=function(){var e=this;this.tagHooks=new TagHooks,"circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use".replace(/,/g,function(t){e.tagHooks[t]=e.tagHooks.g}),this.rtagName=/<([\w:]+)/,this.rxhtml=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,this.scriptTypes={"text/javascript":1,"text/ecmascript":1,"application/ecmascript":1,"application/javascript":1},this.rhtml=/<|&#?\w+;/};Format.prototype={parseJS:function(code){if(code=(code+"").trim(),code)if(1===code.indexOf("use strict")){var script=doc.createElement("script");script.text=code,doc.head.appendChild(script).parentNode.removeChild(script)}else eval(code)},parseXML:function(e,t,r){try{t=(new DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&t.documentElement&&!t.getElementsByTagName("parsererror").length||console.error("Invalid XML: "+e),t},parseHTML:function(e){var t=doc.createDocumentFragment().cloneNode(!1);if("string"!=typeof e)return t;if(!this.rhtml.test(e))return t.appendChild(document.createTextNode(e)),t;e=e.replace(this.rxhtml,"<$1>").trim();var r=(this.rtagName.exec(e)||["",""])[1].toLowerCase(),o=this.tagHooks[r]||this.tagHooks._default,a=null;o.innerHTML=e;var i=o.getElementsByTagName("script");if(i.length)for(var c,n=0;c=i[n++];)if(this.scriptTypes[c.type]){var s=doc.createElement("script").cloneNode(!1);c.attributes.forEach(function(e){s.setAttribute(e.name,e.value)}),s.text=c.text,c.parentNode.replaceChild(s,c)}for(;a=o.firstChild;)t.appendChild(a);return t},param:function(e){if(!e||"string"==typeof e||"number"==typeof e)return e;var t=[];return"object"==typeof e&&serialize("",e,function(e,r){/native code/.test(r)||(r="function"==typeof r?r():r,r="[object File]"!==toS.call(r)?encode(r):r,t.push(encode(e)+"="+r))}),t.join("&")},parseForm:function(e){for(var t,r={},o=0;t=e.elements[o++];)switch(t.type){case"select-one":case"select-multiple":if(t.name.length&&!t.disabled)for(var a,i=0;a=t.options[i++];)a.selected&&(r[t.name]=a.value||a.text);break;case"file":t.name.length&&!t.disabled&&(r[t.name]=t.files[0]);break;case void 0:case"submit":case"reset":case"button":break;case"radio":case"checkbox":if(!t.checked)break;default:t.name.length&&!t.disabled&&(r[t.name]=t.value)}return r},merge:function(e,t){if("object"!=typeof e||"object"!=typeof t)throw new TypeError("argument must be an object");if(Object.assign)return Object.assign(e,t);for(var r in t)e[r]=t[r];return e}};export default new Format; \ No newline at end of file +"use strict";function serialize(e,t,r){let o;if(Array.isArray(t))t.forEach(function(t,a){o=e?`${e}[${Array.isArray(t)?a:""}]`:a,"object"==typeof t?serialize(o,t,r):r(o,t)});else for(let a in t)o=e?`${e}[${a}]`:a,"object"==typeof t[a]?serialize(o,t[a],r):r(o,t[a])}const toS=Object.prototype.toString,doc=window.document,encode=encodeURIComponent,decode=decodeURIComponent,TagHooks=function(){this.option=doc.createElement("select"),this.thead=doc.createElement("table"),this.td=doc.createElement("tr"),this.area=doc.createElement("map"),this.tr=doc.createElement("tbody"),this.col=doc.createElement("colgroup"),this.legend=doc.createElement("fieldset"),this._default=doc.createElement("div"),this.g=doc.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,"circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use".replace(/,/g,e=>{this[e]=this.g})},Helper={tagHooks:new TagHooks,rtagName:/<([\w:]+)/,rxhtml:/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,scriptTypes:{"text/javascript":1,"text/ecmascript":1,"application/ecmascript":1,"application/javascript":1},rhtml:/<|&#?\w+;/};export default{parseJS:function(code){if(code=(code+"").trim(),code)if(1===code.indexOf("use strict")){let e=doc.createElement("script");e.text=code,doc.head.appendChild(e).parentNode.removeChild(e)}else eval(code)},parseXML:function(e,t,r){try{t=(new DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&t.documentElement&&!t.getElementsByTagName("parsererror").length||console.error("Invalid XML: "+e),t},parseHTML:function(e){let t=doc.createDocumentFragment().cloneNode(!1);if("string"!=typeof e)return t;if(!Helper.rhtml.test(e))return t.appendChild(document.createTextNode(e)),t;e=e.replace(Helper.rxhtml,"<$1>").trim();let r=(Helper.rtagName.exec(e)||["",""])[1].toLowerCase(),o=Helper.tagHooks[r]||Helper.tagHooks._default,a=null;o.innerHTML=e;let i=o.getElementsByTagName("script");if(i.length)for(let e,t=0;e=i[t++];)if(Helper.scriptTypes[e.type]){let t=doc.createElement("script").cloneNode(!1);e.attributes.forEach(function(e){t.setAttribute(e.name,e.value)}),t.text=e.text,e.parentNode.replaceChild(t,e)}for(;a=o.firstChild;)t.appendChild(a);return t},parseForm:function(e){let t={},r=!1;for(let o,a=0;o=e.elements[a++];)switch(o.type){case"select-one":case"select-multiple":if(o.name.length&&!o.disabled)for(let e,r=0;e=o.options[r++];)e.selected&&(t[o.name]=e.value||e.text);break;case"file":o.name.length&&!o.disabled&&(t[o.name]=o.files[0],r=!0);break;case void 0:case"submit":case"reset":case"button":break;case"radio":case"checkbox":if(!o.checked)break;default:o.name.length&&!o.disabled&&(t[o.name]=o.value)}return r?this.mkFormData(t):t},mkFormData(e){let t=new FormData;for(let r in e){let o=e[r];Array.isArray(o)?o.forEach(function(e){t.append(r+"[]",e)}):t.append(r,e[r])}return t},param:function(e){if(!e||"string"==typeof e||"number"==typeof e)return e;let t=[];return"object"==typeof e&&serialize("",e,function(e,r){/native code/.test(r)||(r="function"==typeof r?r():r,r="[object File]"!==toS.call(r)?encode(r):r,t.push(encode(e)+"="+r))}),t.join("&")}}; \ No newline at end of file diff --git a/src/lib/request/light.js b/src/lib/request/light.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/tools/tray.js b/src/tools/tray.js index 486895c..77c8f7a 100644 --- a/src/tools/tray.js +++ b/src/tools/tray.js @@ -6,12 +6,12 @@ 'use strict' -const { Tray, Menu } = require('electron') +const { app, Tray, Menu } = require('electron') const path = require('path') const ROOT = __dirname module.exports = function(win) { - let tray = new Tray( + app.__TRAY__ = new Tray( path.resolve(__dirname, '../images/trays/trayTemplate.png') ) let menuList = Menu.buildFromTemplate([ @@ -26,13 +26,13 @@ module.exports = function(win) { ]) if (process.platform === 'darwin') { - tray.on('click', _ => { + app.__TRAY__.on('click', _ => { win.webContents.send('dock-click') }) - tray.on('right-click', _ => { - tray.popUpContextMenu(menuList) + app.__TRAY__.on('right-click', _ => { + app.__TRAY__.popUpContextMenu(menuList) }) } else { - tray.setContextMenu(menuList) + app.__TRAY__.setContextMenu(menuList) } } diff --git a/src/tools/windows.js b/src/tools/windows.js index bac8561..951560a 100644 --- a/src/tools/windows.js +++ b/src/tools/windows.js @@ -33,7 +33,7 @@ exports.createMainWindow = function(icon) { win.on('ready-to-show', _ => { win.show() - win.openDevTools() + // win.openDevTools() }) return win