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

应用启动增加依赖检测;优化音乐目录扫描逻辑

2.x
宇天 2019-01-20 17:58:28 +08:00
parent 6730b5f3c0
commit e649c8347a
7 changed files with 82 additions and 26 deletions

File diff suppressed because one or more lines are too long

View File

@ -155,6 +155,7 @@
.label {flex:0 1 20rem;} .label {flex:0 1 20rem;}
.field {flex:1;display:flex;align-items:center;} .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} .do-radio {margin-right:2rem}
.desc {line-height:2; .desc {line-height:2;
p {margin-top:1.5rem;} p {margin-top:1.5rem;}

35
src/depends.html Normal file
View File

@ -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>

View File

@ -177,11 +177,15 @@ export default Anot({
return return
} }
if (appInit.musicPath) { if (appInit.musicPath) {
if (fs.isdir(appInit.musicPath)) {
this.__load__ = layer.load(4) this.__load__ = layer.load(4)
this.__LIST__ = fs.ls(appInit.musicPath) this.__LIST__ = fs.ls(appInit.musicPath)
this.__NEW_NUM__ = 0 this.__NEW_NUM__ = 0
ev.target.textContent = '正在扫描, 请稍候...' ev.target.textContent = '正在扫描, 请稍候...'
this.__checkSong__(ev.target) this.__checkSong__(ev.target)
} else {
layer.alert('当前设置的音乐目录不存在...<br>请检查后重新尝试!')
}
} else { } else {
layer.toast('请先设置音乐目录', 'error') layer.toast('请先设置音乐目录', 'error')
} }

View File

@ -27,7 +27,7 @@ export default Anot({
allowPlayOnBack: appInit.allowPlayOnBack, allowPlayOnBack: appInit.allowPlayOnBack,
autoLrc: appInit.autoLrc, autoLrc: appInit.autoLrc,
theme: appInit.theme || 1, theme: appInit.theme || 1,
musicPath: appInit.musicPath musicPath: appInit.musicPath || ''
} }
}, },
watch: { watch: {
@ -44,7 +44,7 @@ export default Anot({
dialog.showOpenDialog( dialog.showOpenDialog(
{ {
properties: ['openDirectory'], properties: ['openDirectory'],
defaultPath: app.getPath('home') defaultPath: appInit.musicPath || app.getPath('home')
}, },
dir => { dir => {
if (dir) { if (dir) {

View File

@ -8,6 +8,7 @@ const {
} = require('electron') } = require('electron')
const path = require('path') const path = require('path')
const fs = require('iofs') const fs = require('iofs')
const { exec } = require('child_process')
const log = console.log const log = console.log
const ROOT = __dirname const ROOT = __dirname
@ -109,6 +110,8 @@ app.once('ready', () => {
cb({ data: buf, mimeType: MIME_TYPES[ext] }) cb({ data: buf, mimeType: MIME_TYPES[ext] })
}) })
exec('which ffprobe', (err, res) => {
if (res) {
tray = new Tray(path.resolve(ROOT, './images/trays/trayTemplate.png')) tray = new Tray(path.resolve(ROOT, './images/trays/trayTemplate.png'))
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
@ -128,5 +131,14 @@ app.once('ready', () => {
) )
createWindow() createWindow()
// win.openDevTools() win.openDevTools()
} else {
win = new BrowserWindow({
width: 600,
height: 360,
titleBarStyle: 'hiddenInset'
})
win.loadURL('app://sonist/depends.html')
}
})
}) })

View File

@ -29,7 +29,11 @@
<section class="block"> <section class="block">
<span class="label">本地音乐目录</span> <span class="label">本地音乐目录</span>
<div class="field"> <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> <anot-button color="teal" @click="openDir">选择目录...</anot-button>
</div> </div>
</section> </section>