From 10640890973bce21cc8a23878b7aa5d7a8c0691e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Sun, 20 Jan 2019 23:01:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=AB=E6=8F=8F=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E4=BC=9A=E5=AF=BC=E8=87=B4=E7=99=BD=E5=B1=8F=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/modules/local.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/js/modules/local.js b/src/js/modules/local.js index dea1826..4f91af5 100644 --- a/src/js/modules/local.js +++ b/src/js/modules/local.js @@ -19,6 +19,8 @@ const HOME_PATH = app.getPath('appData') const MUSIC_DB_PATH = path.join(HOME_PATH, 'music.db') const LYRICS_PATH = path.join(HOME_PATH, 'lyrics') +const SUPPORTED_EXTS = ['.mp3', '.webm', '.ogg', '.flac', '.m4a', '.aac'] + let appInit = {} let dbCache = fs.cat(MUSIC_DB_PATH) dbCache = JSON.parse(dbCache) @@ -179,7 +181,19 @@ export default Anot({ if (appInit.musicPath) { if (fs.isdir(appInit.musicPath)) { this.__load__ = layer.load(4) - this.__LIST__ = fs.ls(appInit.musicPath) + + this.__LIST__ = fs.ls(appInit.musicPath, true).filter(_ => { + if (fs.isdir(_)) { + return false + } else { + let { ext, name } = path.parse(song) + if (!ext || name.startsWith('.')) { + return false + } + return SUPPORTED_EXTS.includes(ext) + } + }) + this.__NEW_NUM__ = 0 ev.target.textContent = '正在扫描, 请稍候...' this.__checkSong__(ev.target)