From e649c8347af3d4a890e68b3cb170023cc5db4370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Sun, 20 Jan 2019 17:58:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=90=AF=E5=8A=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BE=9D=E8=B5=96=E6=A3=80=E6=B5=8B;=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=9F=B3=E4=B9=90=E7=9B=AE=E5=BD=95=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/modules.css | 2 +- src/css/modules.scss | 1 + src/depends.html | 35 +++++++++++++++++++++++++++++ src/js/modules/local.js | 14 +++++++----- src/js/modules/profile.js | 4 ++-- src/main.js | 46 ++++++++++++++++++++++++--------------- src/views/profile.htm | 6 ++++- 7 files changed, 82 insertions(+), 26 deletions(-) create mode 100644 src/depends.html diff --git a/src/css/modules.css b/src/css/modules.css index b4b1058..8d204ca 100644 --- a/src/css/modules.css +++ b/src/css/modules.css @@ -1 +1 @@ -.do-mod-artist{position:relative;display:flex;width:100%;height:100%}.do-mod-artist .filter-box{flex:0 1 12rem;border-right:0.1rem solid #f3f5fb;text-align:right}.do-mod-artist .filter-box .item{width:100%;height:2.4rem;padding:0 1.2rem;line-height:2.4rem;color:#98acae}.do-mod-artist .filter-box .item.active{color:#3fc2a7;font-weight:bold}.do-mod-artist .filter-box .item:hover{padding-right:1.3rem;color:#3fc2a7}.do-mod-artist .filter-box .pipe{display:block;width:100%;height:.7rem}.do-mod-artist .list-box{overflow-y:auto;display:flex;flex-flow:row wrap;flex:1;padding:0 1rem}.do-mod-artist .list-box .item{display:flex;justify-content:center;align-items:center;flex:45%;height:7rem;margin:1rem 2.5%;padding:.5rem;background:#f3f5fb}.do-mod-artist .list-box .item img{flex:0 1 6rem;height:6rem}.do-mod-artist .list-box .item summary{flex:2;padding:0 1rem}.do-mod-artist .list-box .item strong{font-size:1.6rem}.do-mod-artist .list-box .item p{font-size:1.2rem;color:#98acae}.do-mod-artist .artist-box{position:absolute;left:0;top:0;z-index:9;width:100%;height:100%;background-size:cover;background-repeat:no-repeat;background-position:center center}.do-mod-artist .artist-box .content{display:flex;flex-flow:column wrap;width:100%;height:100%;padding:1.5rem 2.5rem;background:linear-gradient(to bottom, #fff 2%, rgba(255,255,255,0.75), #fff 98%);-webkit-backdrop-filter:blur(1rem);backdrop-filter:blur(1rem)}.do-mod-artist .artist-box .content .name{flex:0 1 3.6rem;font-size:1.4rem;font-style:italic;font-weight:normal}.do-mod-artist .artist-box .content .name a{text-decoration:underline;color:#3fc2a7}.do-mod-artist .artist-box .content .name i{color:#98acae}.do-mod-artist .artist-box .content .desc{flex:0 1 3rem;font-size:1.2rem;color:#98acae}.do-mod-artist .artist-box .content .desc span{padding:0 .5rem;text-decoration:underline;color:#3fc2a7}.do-mod-artist .artist-box .content .song-album{flex:1;display:flex;flex-flow:column wrap}.do-mod-artist .artist-box .content .tab{flex:0 1 3rem;display:flex;padding:0 .5rem;line-height:2.9rem;border-bottom:0.1rem solid #e8ebf4;text-align:center}.do-mod-artist .artist-box .content .tab .item{flex:0 0 7.5rem;height:3rem;margin:0 .3rem}.do-mod-artist .artist-box .content .tab .item.active{border-bottom:0.2rem solid #3fc2a7;color:#3fc2a7}.do-mod-artist .artist-box .content .tab .item.disabled{opacity:.25}.do-mod-local{flex:1;display:flex;flex-flow:column wrap}.do-mod-local .tabbar{flex:0 1 3rem;padding:0 1rem;line-height:2.9rem;border-bottom:0.1rem solid rgba(200,200,200,0.3)}.do-mod-local .tabbar .refresh{margin-left:1rem;color:#3fc2a7;text-decoration:underline}.do-mod-local .tabbar .refresh:hover{color:#ffb618}.do-mod-local .tabbar .refresh:active{color:#3fc2a7;-webkit-transform:scale(1.1);transform:scale(1.1)}.do-mod-local .table{overflow:auto;flex:1}.do-mod-local .table .stat{width:2.6rem;height:2.6rem;line-height:2.6rem}.do-mod-local .table .ac{text-align:center}.do-mod-local .table .active{color:#3fc2a7;background:rgba(255,255,255,0.6)}.do-mod-local .table .active i{-webkit-animation:play 2s infinite linear;animation:play 2s infinite linear}.do-mod-local .edit-form{position:absolute;left:0;top:0;z-index:90;display:flex;justify-content:center;align-items:center;width:100%;height:100%}.do-mod-local .edit-form .form{position:relative;display:flex;flex-flow:column wrap;flex:0 40rem;width:5rem;height:auto;padding:.5rem 4rem 2rem;background:#fff;box-shadow:0 0.5rem 2rem rgba(0,0,0,0.2)}.do-mod-local .edit-form .form .section{display:flex;flex:1;justify-content:center;align-items:center;margin:1rem 0}.do-mod-local .edit-form .form .section.title{line-height:2;font-size:1.6rem}.do-mod-local .edit-form .form .section.title i{position:absolute;right:1rem;top:1rem;color:#ff5061}.do-mod-local .edit-form .form .section.title i:hover{-webkit-transform:scale(1.2);transform:scale(1.2);font-weight:bold}.do-mod-local .edit-form .form .section .label{flex:0 5rem;padding-right:2rem;color:#98acae;text-align:right}.do-mod-local .edit-form .form .section .field{flex:1}.do-mod-search{flex:1;display:flex;flex-flow:column wrap}.do-mod-search .tabbar{flex:0 1 3rem;display:flex;padding:0 .5rem;line-height:2.9rem;border-bottom:0.1rem solid #e8ebf4;text-align:center}.do-mod-search .tabbar .item{flex:0 0 7.5rem;height:3rem;margin:0 .3rem;border:0.1rem solid rgba(200,200,200,0.3);background:rgba(255,255,255,0.3);color:#dae1e9}.do-mod-search .tabbar .item.active{border-bottom-color:transparent;color:#62778d}.do-mod-search .tabbar .item i{color:#ff5061}.do-mod-search .table{overflow:auto;flex:1}.do-mod-search .table .active{color:#3fc2a7}.do-mod-search .table .ac{text-align:center}.do-mod-profile{overflow-y:auto;padding:0 3rem}.do-mod-profile .title{position:relative;width:100%;height:6rem;line-height:6rem;border-bottom:0.1rem solid #dae1e9;font-size:1.8rem}.do-mod-profile .title .save{position:absolute;bottom:.3rem;right:0}.do-mod-profile .block{display:flex;justify-content:center;align-items:center;width:100%;padding:2rem 0;border-bottom:0.1rem solid #f3f5fb}.do-mod-profile .block .label{flex:0 1 20rem}.do-mod-profile .block .field{flex:1;display:flex;align-items:center}.do-mod-profile .block .do-radio{margin-right:2rem}.do-mod-profile .block .desc{line-height:2}.do-mod-profile .block .desc p{margin-top:1.5rem}.artist-desc-layer{width:60rem;height:30rem}.artist-desc-layer .layer-content{overflow-y:auto;height:85% !important;padding:1rem;line-height:2;text-indent:2em} +.do-mod-artist{position:relative;display:flex;width:100%;height:100%}.do-mod-artist .filter-box{flex:0 1 12rem;border-right:0.1rem solid #f3f5fb;text-align:right}.do-mod-artist .filter-box .item{width:100%;height:2.4rem;padding:0 1.2rem;line-height:2.4rem;color:#98acae}.do-mod-artist .filter-box .item.active{color:#3fc2a7;font-weight:bold}.do-mod-artist .filter-box .item:hover{padding-right:1.3rem;color:#3fc2a7}.do-mod-artist .filter-box .pipe{display:block;width:100%;height:.7rem}.do-mod-artist .list-box{overflow-y:auto;display:flex;flex-flow:row wrap;flex:1;padding:0 1rem}.do-mod-artist .list-box .item{display:flex;justify-content:center;align-items:center;flex:45%;height:7rem;margin:1rem 2.5%;padding:.5rem;background:#f3f5fb}.do-mod-artist .list-box .item img{flex:0 1 6rem;height:6rem}.do-mod-artist .list-box .item summary{flex:2;padding:0 1rem}.do-mod-artist .list-box .item strong{font-size:1.6rem}.do-mod-artist .list-box .item p{font-size:1.2rem;color:#98acae}.do-mod-artist .artist-box{position:absolute;left:0;top:0;z-index:9;width:100%;height:100%;background-size:cover;background-repeat:no-repeat;background-position:center center}.do-mod-artist .artist-box .content{display:flex;flex-flow:column wrap;width:100%;height:100%;padding:1.5rem 2.5rem;background:linear-gradient(to bottom, #fff 2%, rgba(255,255,255,0.75), #fff 98%);-webkit-backdrop-filter:blur(1rem);backdrop-filter:blur(1rem)}.do-mod-artist .artist-box .content .name{flex:0 1 3.6rem;font-size:1.4rem;font-style:italic;font-weight:normal}.do-mod-artist .artist-box .content .name a{text-decoration:underline;color:#3fc2a7}.do-mod-artist .artist-box .content .name i{color:#98acae}.do-mod-artist .artist-box .content .desc{flex:0 1 3rem;font-size:1.2rem;color:#98acae}.do-mod-artist .artist-box .content .desc span{padding:0 .5rem;text-decoration:underline;color:#3fc2a7}.do-mod-artist .artist-box .content .song-album{flex:1;display:flex;flex-flow:column wrap}.do-mod-artist .artist-box .content .tab{flex:0 1 3rem;display:flex;padding:0 .5rem;line-height:2.9rem;border-bottom:0.1rem solid #e8ebf4;text-align:center}.do-mod-artist .artist-box .content .tab .item{flex:0 0 7.5rem;height:3rem;margin:0 .3rem}.do-mod-artist .artist-box .content .tab .item.active{border-bottom:0.2rem solid #3fc2a7;color:#3fc2a7}.do-mod-artist .artist-box .content .tab .item.disabled{opacity:.25}.do-mod-local{flex:1;display:flex;flex-flow:column wrap}.do-mod-local .tabbar{flex:0 1 3rem;padding:0 1rem;line-height:2.9rem;border-bottom:0.1rem solid rgba(200,200,200,0.3)}.do-mod-local .tabbar .refresh{margin-left:1rem;color:#3fc2a7;text-decoration:underline}.do-mod-local .tabbar .refresh:hover{color:#ffb618}.do-mod-local .tabbar .refresh:active{color:#3fc2a7;-webkit-transform:scale(1.1);transform:scale(1.1)}.do-mod-local .table{overflow:auto;flex:1}.do-mod-local .table .stat{width:2.6rem;height:2.6rem;line-height:2.6rem}.do-mod-local .table .ac{text-align:center}.do-mod-local .table .active{color:#3fc2a7;background:rgba(255,255,255,0.6)}.do-mod-local .table .active i{-webkit-animation:play 2s infinite linear;animation:play 2s infinite linear}.do-mod-local .edit-form{position:absolute;left:0;top:0;z-index:90;display:flex;justify-content:center;align-items:center;width:100%;height:100%}.do-mod-local .edit-form .form{position:relative;display:flex;flex-flow:column wrap;flex:0 40rem;width:5rem;height:auto;padding:.5rem 4rem 2rem;background:#fff;box-shadow:0 0.5rem 2rem rgba(0,0,0,0.2)}.do-mod-local .edit-form .form .section{display:flex;flex:1;justify-content:center;align-items:center;margin:1rem 0}.do-mod-local .edit-form .form .section.title{line-height:2;font-size:1.6rem}.do-mod-local .edit-form .form .section.title i{position:absolute;right:1rem;top:1rem;color:#ff5061}.do-mod-local .edit-form .form .section.title i:hover{-webkit-transform:scale(1.2);transform:scale(1.2);font-weight:bold}.do-mod-local .edit-form .form .section .label{flex:0 5rem;padding-right:2rem;color:#98acae;text-align:right}.do-mod-local .edit-form .form .section .field{flex:1}.do-mod-search{flex:1;display:flex;flex-flow:column wrap}.do-mod-search .tabbar{flex:0 1 3rem;display:flex;padding:0 .5rem;line-height:2.9rem;border-bottom:0.1rem solid #e8ebf4;text-align:center}.do-mod-search .tabbar .item{flex:0 0 7.5rem;height:3rem;margin:0 .3rem;border:0.1rem solid rgba(200,200,200,0.3);background:rgba(255,255,255,0.3);color:#dae1e9}.do-mod-search .tabbar .item.active{border-bottom-color:transparent;color:#62778d}.do-mod-search .tabbar .item i{color:#ff5061}.do-mod-search .table{overflow:auto;flex:1}.do-mod-search .table .active{color:#3fc2a7}.do-mod-search .table .ac{text-align:center}.do-mod-profile{overflow-y:auto;padding:0 3rem}.do-mod-profile .title{position:relative;width:100%;height:6rem;line-height:6rem;border-bottom:0.1rem solid #dae1e9;font-size:1.8rem}.do-mod-profile .title .save{position:absolute;bottom:.3rem;right:0}.do-mod-profile .block{display:flex;justify-content:center;align-items:center;width:100%;padding:2rem 0;border-bottom:0.1rem solid #f3f5fb}.do-mod-profile .block .label{flex:0 1 20rem}.do-mod-profile .block .field{flex:1;display:flex;align-items:center}.do-mod-profile .block .path-holder{max-width:26rem;padding:0 1.5rem 0 .5rem;border-bottom:0.1rem solid #98acae;color:#98acae}.do-mod-profile .block .do-radio{margin-right:2rem}.do-mod-profile .block .desc{line-height:2}.do-mod-profile .block .desc p{margin-top:1.5rem}.artist-desc-layer{width:60rem;height:30rem}.artist-desc-layer .layer-content{overflow-y:auto;height:85% !important;padding:1rem;line-height:2;text-indent:2em} diff --git a/src/css/modules.scss b/src/css/modules.scss index 44a65db..f6c9364 100644 --- a/src/css/modules.scss +++ b/src/css/modules.scss @@ -155,6 +155,7 @@ .label {flex:0 1 20rem;} .field {flex:1;display:flex;align-items:center;} + .path-holder {max-width:26rem;padding:0 1.5rem 0 .5rem;border-bottom:.1rem solid nth($cgr, 1); color:nth($cgr,1)} .do-radio {margin-right:2rem} .desc {line-height:2; p {margin-top:1.5rem;} diff --git a/src/depends.html b/src/depends.html new file mode 100644 index 0000000..588f1bf --- /dev/null +++ b/src/depends.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + +

欢迎使用Sonist!

+
+检测到你系统中没有安装ffmpeg。
+请先安装ffmpeg。
+
+如果你的系统是MacOS, 可以使用brew来安装:
+brew install ffmpeg
+
+如果你的系统是Linux, 可以使用包管理器"apt/yum/pacman等来安装":
+sudo apt install ffmpeg   # 以debian系为例
+
+
+ + \ No newline at end of file diff --git a/src/js/modules/local.js b/src/js/modules/local.js index 51ee186..dea1826 100644 --- a/src/js/modules/local.js +++ b/src/js/modules/local.js @@ -177,11 +177,15 @@ export default Anot({ return } if (appInit.musicPath) { - this.__load__ = layer.load(4) - this.__LIST__ = fs.ls(appInit.musicPath) - this.__NEW_NUM__ = 0 - ev.target.textContent = '正在扫描, 请稍候...' - this.__checkSong__(ev.target) + if (fs.isdir(appInit.musicPath)) { + this.__load__ = layer.load(4) + this.__LIST__ = fs.ls(appInit.musicPath) + this.__NEW_NUM__ = 0 + ev.target.textContent = '正在扫描, 请稍候...' + this.__checkSong__(ev.target) + } else { + layer.alert('当前设置的音乐目录不存在...
请检查后重新尝试!') + } } else { layer.toast('请先设置音乐目录', 'error') } diff --git a/src/js/modules/profile.js b/src/js/modules/profile.js index 44e9815..bd1aff3 100644 --- a/src/js/modules/profile.js +++ b/src/js/modules/profile.js @@ -27,7 +27,7 @@ export default Anot({ allowPlayOnBack: appInit.allowPlayOnBack, autoLrc: appInit.autoLrc, theme: appInit.theme || 1, - musicPath: appInit.musicPath + musicPath: appInit.musicPath || '' } }, watch: { @@ -44,7 +44,7 @@ export default Anot({ dialog.showOpenDialog( { properties: ['openDirectory'], - defaultPath: app.getPath('home') + defaultPath: appInit.musicPath || app.getPath('home') }, dir => { if (dir) { diff --git a/src/main.js b/src/main.js index 1e1f522..fd56ba0 100644 --- a/src/main.js +++ b/src/main.js @@ -8,6 +8,7 @@ const { } = require('electron') const path = require('path') const fs = require('iofs') +const { exec } = require('child_process') const log = console.log const ROOT = __dirname @@ -109,24 +110,35 @@ app.once('ready', () => { cb({ data: buf, mimeType: MIME_TYPES[ext] }) }) - tray = new Tray(path.resolve(ROOT, './images/trays/trayTemplate.png')) + exec('which ffprobe', (err, res) => { + if (res) { + tray = new Tray(path.resolve(ROOT, './images/trays/trayTemplate.png')) - if (process.platform === 'darwin') { - tray.on('click', _ => { - win.show() - }) - tray.on('right-click', _ => { - tray.popUpContextMenu(traymenuList) - }) - } else { - tray.setContextMenu(traymenuList) - } - Menu.setApplicationMenu(menubarList) + if (process.platform === 'darwin') { + tray.on('click', _ => { + win.show() + }) + tray.on('right-click', _ => { + tray.popUpContextMenu(traymenuList) + }) + } else { + tray.setContextMenu(traymenuList) + } + Menu.setApplicationMenu(menubarList) - session.defaultSession.setUserAgent( - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36' - ) + session.defaultSession.setUserAgent( + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36' + ) - createWindow() - // win.openDevTools() + createWindow() + win.openDevTools() + } else { + win = new BrowserWindow({ + width: 600, + height: 360, + titleBarStyle: 'hiddenInset' + }) + win.loadURL('app://sonist/depends.html') + } + }) }) diff --git a/src/views/profile.htm b/src/views/profile.htm index 7edafa3..3865f72 100644 --- a/src/views/profile.htm +++ b/src/views/profile.htm @@ -29,7 +29,11 @@
本地音乐目录
- + + 选择目录...