应用启动增加依赖检测;优化音乐目录扫描逻辑
parent
6730b5f3c0
commit
e649c8347a
File diff suppressed because one or more lines are too long
|
@ -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;}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
|
||||
<link href="lib/css/reset-basic.css" rel="stylesheet">
|
||||
<link href="lib/css/elem-ui.css" rel="stylesheet">
|
||||
<style>
|
||||
|
||||
.do-fn-drag {-webkit-app-region:drag;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%;padding:4rem 3rem;line-height:2;font-size:1.4rem;color:#62778d;}
|
||||
span {color:#ff5061;font-weight:bold}
|
||||
cite {color:#dae1e9;font-style:italic}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="do-fn-drag">
|
||||
<h1>欢迎使用Sonist!</h1>
|
||||
<pre>
|
||||
检测到你系统中没有安装<span>ffmpeg</span>。
|
||||
请先安装<span>ffmpeg</span>。
|
||||
|
||||
如果你的系统是MacOS, 可以使用brew来安装:
|
||||
brew install ffmpeg
|
||||
|
||||
如果你的系统是Linux, 可以使用包管理器"apt/yum/pacman等来安装":
|
||||
sudo apt install ffmpeg <cite># 以debian系为例</cite>
|
||||
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -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('当前设置的音乐目录不存在...<br>请检查后重新尝试!')
|
||||
}
|
||||
} else {
|
||||
layer.toast('请先设置音乐目录', 'error')
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
46
src/main.js
46
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')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -29,7 +29,11 @@
|
|||
<section class="block">
|
||||
<span class="label">本地音乐目录</span>
|
||||
<div class="field">
|
||||
<anot-input :value="setting.musicPath"></anot-input>
|
||||
<span
|
||||
class="path-holder do-fn-ell"
|
||||
:attr-title="setting.musicPath"
|
||||
:text="setting.musicPath || '请选择你的歌曲目录'">
|
||||
</span>
|
||||
<anot-button color="teal" @click="openDir">选择目录...</anot-button>
|
||||
</div>
|
||||
</section>
|
||||
|
|
Reference in New Issue