fixed
parent
539a942906
commit
7a696c61b2
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "top.yutent.sonist",
|
"name": "top.yutent.sonist",
|
||||||
"version": "2.0.0-alpha-3",
|
"version": "2.0.0-alpha-4",
|
||||||
"description": "Music Player",
|
"description": "Music Player",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="zh-CN">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<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">
|
|
||||||
<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>
|
|
|
@ -1,36 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="zh-CN">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<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="/css/common.css" rel="stylesheet">
|
|
||||||
<link href="/css/desktop-lrc.css" rel="stylesheet">
|
|
||||||
<script>window.LIBS_BASE_URL = location.origin + '/lib';</script>
|
|
||||||
<script type="module" src="js/desktop-lrc.js"></script>
|
|
||||||
</head>
|
|
||||||
<body class="do-fn-noselect do-fn-drag" anot="lrc">
|
|
||||||
<div class="lrc-box">
|
|
||||||
<section class="left">
|
|
||||||
<span class="shadow" :text="lrc.l.txt"></span>
|
|
||||||
</section>
|
|
||||||
<section class="right">
|
|
||||||
<span class="shadow" :text="lrc.r.txt"></span>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
<div class="lrc-box">
|
|
||||||
<section class="left">
|
|
||||||
<span :text="lrc.l.txt" :css="{background: lrc.l.bg}"></span>
|
|
||||||
</section>
|
|
||||||
<section class="right">
|
|
||||||
<span :text="lrc.r.txt" :css="{background: lrc.r.bg}"></span>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="touch-bar do-fn-nodrag">
|
|
||||||
<a class="do-icon-lock lock" :visible="isMac" :class="{active: isLock}" :click="lock"></a>
|
|
||||||
<a class="do-icon-close quit" :click="quit"></a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -229,6 +229,7 @@ Anot({
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// player.stop()
|
||||||
this.curr = i
|
this.curr = i
|
||||||
this.song.name = it.name
|
this.song.name = it.name
|
||||||
this.song.artist = it.artist
|
this.song.artist = it.artist
|
||||||
|
@ -240,6 +241,8 @@ Anot({
|
||||||
player.play(i)
|
player.play(i)
|
||||||
this.$refs.list.scrollTop = (i - 3) * 26
|
this.$refs.list.scrollTop = (i - 3) * 26
|
||||||
|
|
||||||
|
app.dispatch('update-lrc', { lrc: '正在播放: ' + it.name })
|
||||||
|
|
||||||
// if (!it.lrc) {
|
// if (!it.lrc) {
|
||||||
// Api.searchLrc(it.name, it.duration).then(list => {
|
// Api.searchLrc(it.name, it.duration).then(list => {
|
||||||
// var { id, accesskey } = list[0]
|
// var { id, accesskey } = list[0]
|
||||||
|
|
|
@ -72,8 +72,10 @@ export default class Player {
|
||||||
this.gain = this.__AC__.createGain()
|
this.gain = this.__AC__.createGain()
|
||||||
this.gain.gain.value = this.volume
|
this.gain.gain.value = this.volume
|
||||||
|
|
||||||
this.track = this.__AC__.createMediaElementSource(this.__AUDIO__)
|
this.track = this.__AC__
|
||||||
this.track.connect(this.gain).connect(this.__AC__.destination)
|
.createMediaElementSource(this.__AUDIO__)
|
||||||
|
.connect(this.gain)
|
||||||
|
.connect(this.__AC__.destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
get volume() {
|
get volume() {
|
||||||
|
@ -147,6 +149,7 @@ export default class Player {
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
if (this.track) {
|
if (this.track) {
|
||||||
|
this.track.disconnect()
|
||||||
this.track = null
|
this.track = null
|
||||||
this.gain = null
|
this.gain = null
|
||||||
this.__destroy__()
|
this.__destroy__()
|
||||||
|
|
16
src/main.js
16
src/main.js
|
@ -4,13 +4,13 @@
|
||||||
* @date 2020/11/18 09:27:09
|
* @date 2020/11/18 09:27:09
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { app, session, protocol, globalShortcut } = require('electron')
|
const { app, session, protocol, globalShortcut, ipcMain } = require('electron')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('iofs')
|
const fs = require('iofs')
|
||||||
|
|
||||||
require('./tools/init.js')
|
require('./tools/init.js')
|
||||||
|
|
||||||
const { createMainWindow, createMiniWindow } = require('./tools/windows.js')
|
const { createMainWindow } = require('./tools/windows.js')
|
||||||
|
|
||||||
const MIME_TYPES = {
|
const MIME_TYPES = {
|
||||||
'.js': 'text/javascript',
|
'.js': 'text/javascript',
|
||||||
|
@ -70,6 +70,18 @@ app.once('ready', () => {
|
||||||
win.restore()
|
win.restore()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.on('app', (ev, conn) => {
|
||||||
|
switch (conn.type) {
|
||||||
|
case 'update-lrc':
|
||||||
|
win.__lrc__.setTitle(conn.data.lrc)
|
||||||
|
ev.returnValue = true
|
||||||
|
break
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// 退出前清空所有快捷键
|
// 退出前清空所有快捷键
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="zh-CN">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<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="/css/common.css" rel="stylesheet">
|
|
||||||
<link href="/css/mini-win.css" rel="stylesheet">
|
|
||||||
<script>window.LIBS_BASE_URL = location.origin + '/lib';</script>
|
|
||||||
<script type="module" src="js/mini-win.js"></script>
|
|
||||||
</head>
|
|
||||||
<body class="do-fn-noselect" anot="mini">
|
|
||||||
<div id="app">
|
|
||||||
<span class="cover do-fn-drag">
|
|
||||||
<img :attr-src="curr.cover || '/images/album.png'" />
|
|
||||||
</span>
|
|
||||||
<div class="ctrl">
|
|
||||||
<h3 class="title do-fn-ell do-fn-drag" :text="curr.title ? '正在播放: ' + curr.title : '已经停止播放...'"></h3>
|
|
||||||
<div class="btns" :click="handleCtrl">
|
|
||||||
<span class="s-icon-prev" data-key="prev"></span>
|
|
||||||
<span
|
|
||||||
class="play"
|
|
||||||
data-key="play"
|
|
||||||
:class="{'s-icon-play': !isPlaying, 's-icon-pause': isPlaying}" >
|
|
||||||
</span>
|
|
||||||
<span class="s-icon-next" data-key="next"></span>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="tools do-fn-nodrag" :click="handleTool">
|
|
||||||
<span data-key="pin" class="do-icon-pin" :class="{active: pinned}"></span>
|
|
||||||
<span data-key="quit" class="do-icon-maximized"></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="actions" :click="handleAction">
|
|
||||||
<span data-key="lrc">词</span>
|
|
||||||
<span data-key="mode"
|
|
||||||
:class="{
|
|
||||||
's-icon-all': playMode === 0,
|
|
||||||
's-icon-single': playMode === 1,
|
|
||||||
's-icon-random': playMode === 2
|
|
||||||
}">
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const { ipcMain, Tray, Menu, nativeImage } = require('electron')
|
const { Tray, Menu, nativeImage } = require('electron')
|
||||||
|
|
||||||
const ICON_DICT = {
|
const ICON_DICT = {
|
||||||
app: path.join(__dirname, '../images/trays/tray.png'),
|
app: path.join(__dirname, '../images/trays/tray.png'),
|
||||||
|
@ -74,7 +74,7 @@ exports.createAppTray = function (win) {
|
||||||
|
|
||||||
exports.createLrcTray = function (win) {
|
exports.createLrcTray = function (win) {
|
||||||
var tray = create()
|
var tray = create()
|
||||||
tray.setTitle('这是顶栏歌词, blablablabla...')
|
tray.setTitle('Hello Sonist!')
|
||||||
|
|
||||||
win.__lrc__ = tray
|
win.__lrc__ = tray
|
||||||
return tray
|
return tray
|
||||||
|
|
|
@ -24,7 +24,6 @@ exports.createMainWindow = function (icon) {
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
icon,
|
icon,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
backgroundColor: '#00ffffff',
|
|
||||||
vibrancy: 'dark',
|
vibrancy: 'dark',
|
||||||
visualEffectState: 'active',
|
visualEffectState: 'active',
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
|
@ -47,7 +46,7 @@ exports.createMainWindow = function (icon) {
|
||||||
|
|
||||||
win.on('ready-to-show', _ => {
|
win.on('ready-to-show', _ => {
|
||||||
win.show()
|
win.show()
|
||||||
win.openDevTools()
|
// win.openDevTools()
|
||||||
})
|
})
|
||||||
|
|
||||||
win.on('close', ev => {
|
win.on('close', ev => {
|
||||||
|
@ -57,29 +56,3 @@ exports.createMainWindow = function (icon) {
|
||||||
|
|
||||||
return win
|
return win
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用迷你窗口
|
|
||||||
*/
|
|
||||||
exports.createMiniWindow = function (screen) {
|
|
||||||
let win = new BrowserWindow({
|
|
||||||
title: '',
|
|
||||||
width: 320,
|
|
||||||
height: 60,
|
|
||||||
frame: false,
|
|
||||||
resizable: false,
|
|
||||||
alwaysOnTop: true,
|
|
||||||
skipTaskbar: true,
|
|
||||||
x: screen.width - 320,
|
|
||||||
y: 0,
|
|
||||||
show: false,
|
|
||||||
webPreferences: {
|
|
||||||
webSecurity: false,
|
|
||||||
experimentalFeatures: true,
|
|
||||||
nodeIntegration: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
win.loadURL('app://local/mini-win.html')
|
|
||||||
return win
|
|
||||||
}
|
|
||||||
|
|
Reference in New Issue