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

优化音乐扫描;修复歌词模块在特殊场景下报错的bug;

2.x 0.9.3
宇天 2019-01-21 03:08:43 +08:00
parent 934b54f011
commit 29859a4747
13 changed files with 92 additions and 29 deletions

View File

@ -1,6 +1,6 @@
{
"name": "sonist",
"version": "0.9.2",
"version": "0.9.3",
"description": "Music Player",
"main": "src/main.js",
"scripts": {

File diff suppressed because one or more lines are too long

View File

@ -294,6 +294,27 @@ table {overflow:auto;display:table;width:100%;line-height:2.5rem;
}
.loading {position:fixed;left:0;top:0;z-index:65536;display:flex;justify-content:center;align-items:center;width:100%;height:100%;
.box {position:relative;display:flex;justify-content:center;align-items:center;width:8rem;height:8rem;
i {position:absolute;width:8rem;height:8rem;border:3px solid nth($ct, 1);border-radius:50%;opacity:.5;
&:nth-child(1) {animation:load 2.5s ease-in-out infinite;}
&:nth-child(2) {animation:load 2.5s .5s ease-in-out infinite;}
&:nth-child(3) {animation:load 2.5s 1s ease-in-out infinite;}
&:nth-child(4) {animation:load 2.5s 1.5s ease-in-out infinite;}
&:nth-child(5) {animation:load 2.5s 2s ease-in-out infinite;}
}
span {position:absolute;width:8rem;height:8rem;background:url(/images/load1.png) no-repeat center center;background-size:cover;
&:nth-child(6) {animation:play 1.5s linear infinite;}
&:nth-child(7) {background-image:url(/images/load2.png);animation:load2 2.5s linear infinite;}
}
cite {font-size:2.4rem}
}
}
}
@ -320,7 +341,15 @@ table {overflow:auto;display:table;width:100%;line-height:2.5rem;
.do-layer .layer-box.do-mod-contextmenu__fixed {padding:0}
@keyframes load {
from {opacity: .5; transform: scale(1)}
to {opacity: 0; transform: scale(1.5)}
}
@keyframes load2 {
from {transform:rotate(360deg)}
to {transform:rotate(0deg)}
}
@keyframes play {
from {transform:rotate(0deg)}

BIN
src/images/load1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
src/images/load2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@ -163,6 +163,16 @@
</div>
<div class="loading" :if="loading">
<div class="box">
<i></i><i></i><i></i><i></i><i></i>
<span></span>
<span></span>
<cite>{{progress}}%</cite>
</div>
</div>
</div>
</body>

View File

@ -81,7 +81,6 @@ const LRC_WIN = new remote.BrowserWindow({
hasShadow: false,
thickFrame: false,
transparent: true,
// focusable: false,
show: false
})
@ -109,7 +108,9 @@ Anot({
duration: 0
},
ctrlLrc: '暂无歌词...',
...KTV.data
...KTV.data,
loading: false,
progress: 0
},
skip: [],
computed: {

View File

@ -70,7 +70,6 @@ export default {
hash: it.FileHash
}
})
log(list, this.lrcForm.result)
})
}
},

View File

@ -129,10 +129,13 @@ export default Anot({
__checkSong__(el) {
let song = this.__LIST__.pop()
let scaned = this.__WAIT_FOR_SCAN__ - this.__LIST__.length
this.__APP__.progress = ((100 * scaned) / this.__WAIT_FOR_SCAN__) >>> 0
if (!song) {
el.textContent = '重新扫描'
el = null
if (this.__NEW_NUM__ > 0) {
LS.sort('artist', true)
dbCache = LS.getAll()
this.list.clear()
@ -143,21 +146,21 @@ export default Anot({
fs.echo(JSON.stringify(dbCache, '', 2), MUSIC_DB_PATH)
dbCache = null
}
layer.close(this.__load__)
layer.toast(`刷新缓存完成,新增${this.__NEW_NUM__}`)
delete this.__load__
this.__APP__.loading = false
this.__APP__.progress = 0
delete this.__NEW_NUM__
return
}
Anot.nextTick(() => {
let name = path.basename(song)
if (name.startsWith('.')) {
return this.__checkSong__(el)
}
let hash = crypto.md5Sign(song)
if (LS.get(hash)) {
let item = LS.get(hash)
if (item) {
item.path = `file://${song}`
LS.update(hash, item)
return this.__checkSong__(el)
}
this.__NEW_NUM__++
@ -175,25 +178,25 @@ export default Anot({
})
},
refresh(ev) {
if (this.__load__) {
if (this.__APP__.loading) {
return
}
if (appInit.musicPath) {
if (fs.isdir(appInit.musicPath)) {
this.__load__ = layer.load(4)
this.__APP__.loading = true
this.__LIST__ = fs.ls(appInit.musicPath, true).filter(_ => {
if (fs.isdir(_)) {
return false
} else {
let { ext, name } = path.parse(song)
let { ext, name } = path.parse(_)
if (!ext || name.startsWith('.')) {
return false
}
return SUPPORTED_EXTS.includes(ext)
}
})
this.__WAIT_FOR_SCAN__ = this.__LIST__.length
this.__NEW_NUM__ = 0
ev.target.textContent = '正在扫描, 请稍候...'
this.__checkSong__(ev.target)
@ -204,6 +207,11 @@ export default Anot({
layer.toast('请先设置音乐目录', 'error')
}
},
closeEditByEnter(ev) {
if (ev.keyCode === 13 && ev.ctrlKey) {
this.closeEdit()
}
},
closeEdit() {
this.editMode = false
let song = this.list[this.__idx__].$model

View File

@ -199,7 +199,7 @@ export const ID3 = song => {
title: format.tags.TITLE || format.tags.title || name,
album: format.tags.ALBUM || format.tags.album || '',
artist: format.tags.ARTIST || format.tags.artist || '',
duration: +format.duration,
duration: Math.ceil(format.duration),
size: +(format.size / 1024 / 1024).toFixed(2)
})
} catch (err) {

View File

@ -128,6 +128,9 @@ class Lyrics {
if (!this.curr.length && this.tmpLib.length) {
this.curr = this.tmpLib.splice(0, 2)
}
if (this.curr.length < 2) {
this.curr.push(this.curr[0])
}
let stat = 0
// 当前时间小于第1句的结束时间

View File

@ -57,6 +57,18 @@ const TRAYMENU_TMPL = [
}
]
const MENUBAR_TMPL = [
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ role: 'selectall' }
]
},
{
label: 'View',
submenu: [{ role: 'zoomin' }, { role: 'zoomout' }]
@ -74,7 +86,7 @@ if (process.platform === 'darwin') {
})
// Window menu
MENUBAR_TMPL[2].submenu = [{ role: 'minimize' }]
MENUBAR_TMPL[3].submenu = [{ role: 'minimize' }]
}
let traymenuList = Menu.buildFromTemplate(TRAYMENU_TMPL)

View File

@ -31,7 +31,7 @@
</div>
<div class="edit-form" :if="editMode">
<div class="form">
<div class="form" :keyup="closeEditByEnter">
<section class="section title">
歌曲信息编辑
<i class="do-icon-close" :click="closeEdit"></i>
@ -58,4 +58,5 @@
</div>
</div>
</div>