更新组件库, 专为electron打造,性能更优;
parent
2f2593f0b5
commit
57a5e14359
File diff suppressed because one or more lines are too long
|
@ -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)}
|
||||
|
|
120
src/js/api.js
120
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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 => {
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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></$2>").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;
|
||||
"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></$2>").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("&")}};
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ exports.createMainWindow = function(icon) {
|
|||
|
||||
win.on('ready-to-show', _ => {
|
||||
win.show()
|
||||
win.openDevTools()
|
||||
// win.openDevTools()
|
||||
})
|
||||
|
||||
return win
|
||||
|
|
Reference in New Issue