新增MAC、Linux构建并兼容Linux

This commit is contained in:
lyswhut
2019-08-23 19:28:54 +08:00
parent bb40a8612a
commit d6c7fb8dcc
18 changed files with 169 additions and 41 deletions
+4
View File
@@ -0,0 +1,4 @@
export const isLinux = process.platform == 'linux'
export const isWin = process.platform == 'win32'
export const isMac = process.platform == 'darwin'
+22 -3
View File
@@ -1,10 +1,11 @@
const { app, BrowserWindow } = require('electron')
const { app, BrowserWindow, Menu } = require('electron')
const path = require('path')
require('./events')
const progressBar = require('./events/progressBar')
const trafficLight = require('./events/trafficLight')
const autoUpdate = require('./utils/autoUpdate')
const { isLinux, isMac } = require('../common/utils')
const isDev = process.env.NODE_ENV !== 'production'
@@ -33,8 +34,8 @@ function createWindow() {
useContentSize: true,
width: 920,
frame: false,
transparent: true,
icon: path.join(global.__static, 'icons/lunch.ico'),
transparent: !isLinux,
// icon: path.join(global.__static, isWin ? 'icons/256x256.ico' : 'icons/512x512.png'),
resizable: false,
maximizable: false,
fullscreenable: false,
@@ -58,6 +59,24 @@ function createWindow() {
if (!isDev) autoUpdate(mainWindow)
}
if (isMac) {
const template = [
{
label: app.getName(),
submenu: [{ label: '关于洛雪音乐', role: 'about' }, { type: 'separator' }, { label: '隐藏', role: 'hide' }, { label: '显示其他', role: 'hideothers' }, { label: '显示全部', role: 'unhide' }, { type: 'separator' }, { label: '退出', click: () => app.quit() }],
},
{
label: '窗口',
role: 'window',
submenu: [{ label: '最小化', role: 'minimize' }, { label: '关闭', role: 'close' }],
},
]
Menu.setApplicationMenu(Menu.buildFromTemplate(template))
} else {
Menu.setApplicationMenu(null)
}
app.once('ready', createWindow)
app.on('window-all-closed', () => {
+26 -9
View File
@@ -1,5 +1,5 @@
<template lang="pug">
#container(v-if="isProd" :class="theme" @mouseenter="enableIgnoreMouseEvents" @mouseleave="dieableIgnoreMouseEvents")
#container(v-if="isProd && !isLinux" :class="theme" @mouseenter="enableIgnoreMouseEvents" @mouseleave="dieableIgnoreMouseEvents")
core-aside#left
#right
core-toolbar#toolbar
@@ -20,14 +20,20 @@
<script>
import { mapMutations, mapGetters, mapActions } from 'vuex'
import { rendererOn } from '../common/icp'
import { isLinux } from '../common/utils'
window.ELECTRON_DISABLE_SECURITY_WARNINGS = process.env.ELECTRON_DISABLE_SECURITY_WARNINGS
const win = require('electron').remote.getCurrentWindow()
const body = document.body
let win
let body
if (!isLinux) {
win = require('electron').remote.getCurrentWindow()
body = document.body
}
export default {
data() {
return {
isProd: process.env.NODE_ENV === 'production',
isLinux,
globalObj: {
apiSource: 'messoer',
},
@@ -42,6 +48,7 @@ export default {
}),
},
mounted() {
document.body.classList.add(this.isLinux ? 'noTransparent' : 'transparent')
this.init()
},
watch: {
@@ -79,7 +86,7 @@ export default {
...mapMutations('download', ['updateDownloadList']),
...mapMutations(['setSetting']),
init() {
if (this.isProd) {
if (this.isProd && !isLinux) {
body.addEventListener('mouseenter', this.dieableIgnoreMouseEvents)
body.addEventListener('mouseleave', this.enableIgnoreMouseEvents)
}
@@ -97,10 +104,12 @@ export default {
window.globalObj = this.globalObj
},
enableIgnoreMouseEvents() {
if (isLinux) return
win.setIgnoreMouseEvents(false)
// console.log('content enable')
},
dieableIgnoreMouseEvents() {
if (isLinux) return
// console.log('content disable')
win.setIgnoreMouseEvents(true, { forward: true })
},
@@ -146,22 +155,30 @@ export default {
@import './assets/styles/layout.less';
body {
// background-color: #fff;
padding: @shadow-app;
user-select: none;
height: 100vh;
box-sizing: border-box;
}
.transparent {
padding: @shadow-app;
#container {
box-shadow: 0 0 @shadow-app rgba(0, 0, 0, 0.5);
border-radius: 4px;
background-color: transparent;
}
}
.noTransparent {
background-color: #fff;
}
#container {
position: relative;
display: flex;
height: 100%;
box-shadow: 0 0 @shadow-app rgba(0, 0, 0, 0.5);
// background-color: #fff;
border-radius: 4px;
overflow: hidden;
}
#left {
flex: none;
width: @width-app-left;
+1 -1
View File
@@ -427,7 +427,7 @@ export default {
},
sendProgressEvent(status, mode) {
// console.log(status)
rendererSend('progress', {
this.setting.player.isShowTaskProgess && rendererSend('progress', {
status: status < 0.01 ? 0.01 : status,
mode: mode || 'normal',
})
+1
View File
@@ -167,6 +167,7 @@ export const updateSetting = setting => {
player: {
togglePlayMethod: 'listLoop',
highQuality: false,
isShowTaskProgess: true,
},
list: {
isShowAlbumName: true,
+9 -2
View File
@@ -31,6 +31,10 @@ div.scroll(:class="$style.setting")
h3 优先播放高品质音乐
div
material-checkbox(id="setting_player_highQuality" v-model="current_setting.player.highQuality" label="是否启用")
dd(title='在任务栏上显示当前歌曲播放进度')
h3 是否启用任务栏播放进度条
div
material-checkbox(id="setting_player_showTaskProgess" v-model="current_setting.player.isShowTaskProgess" label="是否启用")
dt 下载设置
dd(title='下载歌曲保存的路径')
h3 下载路径
@@ -85,9 +89,9 @@ div.scroll(:class="$style.setting")
| 本软件的部分接口使用自 https://github.com/messoer ,非常感谢
strong @messoer
| !
p.small 若有问题可 mail to:lyswhut@qq.com 或到 github 提交 issue
p.small 若有问题可 mail to:lyswhut@qq.com 或到 GitHub 提交 issue
p.small
| 若觉得好用的话可以去GitHub点个
| 若觉得好用的话可以去 GitHub 点个
strong star
| 支持作者哦~~🍻
p
@@ -99,6 +103,8 @@ div.scroll(:class="$style.setting")
import { mapGetters, mapMutations } from 'vuex'
import { openDirInExplorer, openSelectDir, openSaveDir, updateSetting, openUrl } from '../utils'
import fs from 'fs'
export default {
name: 'Setting',
computed: {
@@ -112,6 +118,7 @@ export default {
player: {
togglePlayMethod: 'random',
highQuality: false,
isShowTaskProgess: true,
},
list: {
isShowAlbumName: true,
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB