新增MAC、Linux构建并兼容Linux

pull/96/head
lyswhut 2019-08-23 19:28:54 +08:00
parent bb40a8612a
commit d6c7fb8dcc
18 changed files with 169 additions and 41 deletions

1
.gitignore vendored
View File

@ -34,6 +34,7 @@ build/Release
# Dependency directories # Dependency directories
node_modules/ node_modules/
node_modules.bak*/
jspm_packages/ jspm_packages/
# TypeScript v1 declaration files # TypeScript v1 declaration files

43
.travis.yml Normal file
View File

@ -0,0 +1,43 @@
matrix:
include:
- os: osx
osx_image: xcode10.2
language: node_js
node_js: "12"
env:
- ELECTRON_CACHE=$HOME/.cache/electron
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
- os: linux
language: node_js
node_js: "12"
dist: trusty
services: docker
language: generic
cache:
directories:
- node_modules
- $HOME/.cache/electron
- $HOME/.cache/electron-builder
- $HOME/.npm/_prebuilds
notifications:
email: false
script:
- |
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
npm install && npm run publish:gh:linux
else
npm run publish:gh:mac
fi
before_cache:
- rm -rf $HOME/.cache/electron-builder/wine
# only run this script on pull requests and merges into
# the 'master' and 'prod' branches
branches:
only:
- master

View File

@ -3,6 +3,7 @@
<p align="center"> <p align="center">
<a href="https://github.com/lyswhut/lx-music-desktop/releases"><img src="https://img.shields.io/github/release/lyswhut/lx-music-desktop" alt="Release version"></a> <a href="https://github.com/lyswhut/lx-music-desktop/releases"><img src="https://img.shields.io/github/release/lyswhut/lx-music-desktop" alt="Release version"></a>
<a href="https://ci.appveyor.com/project/lyswhut/lx-music-desktop"><img src="https://ci.appveyor.com/api/projects/status/flrsqd5ymp8fnte5?svg=true" alt="Build status"></a> <a href="https://ci.appveyor.com/project/lyswhut/lx-music-desktop"><img src="https://ci.appveyor.com/api/projects/status/flrsqd5ymp8fnte5?svg=true" alt="Build status"></a>
<a href="https://travis-ci.org/lyswhut/lx-music-desktop"><img src="https://travis-ci.org/lyswhut/lx-music-desktop.svg?branch=master" alt="Build status"></a>
<a href="https://github.com/lyswhut/lx-music-desktop/releases"><img src="https://img.shields.io/github/downloads/lyswhut/lx-music-desktop/latest/total" alt="Downloads"></a> <a href="https://github.com/lyswhut/lx-music-desktop/releases"><img src="https://img.shields.io/github/downloads/lyswhut/lx-music-desktop/latest/total" alt="Downloads"></a>
<a href="https://github.com/lyswhut/lx-music-desktop/tree/dev"><img src="https://img.shields.io/github/package-json/v/lyswhut/lx-music-desktop/dev" alt="Dev branch version"></a> <a href="https://github.com/lyswhut/lx-music-desktop/tree/dev"><img src="https://img.shields.io/github/package-json/v/lyswhut/lx-music-desktop/dev" alt="Dev branch version"></a>
<!-- <a href="https://github.com/lyswhut/lx-music-desktop/blob/master/LICENSE"><img src="https://img.shields.io/github/license/lyswhut/lx-music-desktop" alt="License"></a> --> <!-- <a href="https://github.com/lyswhut/lx-music-desktop/blob/master/LICENSE"><img src="https://img.shields.io/github/license/lyswhut/lx-music-desktop" alt="License"></a> -->

5
licenses/license_en.txt Normal file
View File

@ -0,0 +1,5 @@
This program is only for learning to communicate!
Do not use for commercial purposes! !
All consequences of using this software are borne by the user!
By: lyswhut

5
licenses/license_zh.txt Normal file
View File

@ -0,0 +1,5 @@
本程序仅用于学习交流使用!
请勿用于商业用途!!
使用本软件造成的一切后果由使用者承担!
By: 落雪无痕

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "lx-music-desktop", "name": "lx-music-desktop",
"version": "0.2.3", "version": "0.2.4",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "lx-music-desktop", "name": "lx-music-desktop",
"version": "0.2.3", "version": "0.2.4",
"description": "一个免费的音乐下载助手", "description": "一个免费的音乐下载助手",
"main": "./dist/electron/main.js", "main": "./dist/electron/main.js",
"productName": "lx-music-desktop", "productName": "lx-music-desktop",
@ -26,6 +26,15 @@
"publish:win:7z": "npm run publish:win:7z:x64 && npm run publish:win:7z:x86", "publish:win:7z": "npm run publish:win:7z:x64 && npm run publish:win:7z:x86",
"publish:win:7z:x64": "cross-env TARGET=green ARCH=x64 electron-builder -w=7z --x64 -p onTagOrDraft", "publish:win:7z:x64": "cross-env TARGET=green ARCH=x64 electron-builder -w=7z --x64 -p onTagOrDraft",
"publish:win:7z:x86": "cross-env TARGET=green ARCH=x86 electron-builder -w=7z --ia32 -p onTagOrDraft", "publish:win:7z:x86": "cross-env TARGET=green ARCH=x86 electron-builder -w=7z --ia32 -p onTagOrDraft",
"publish:gh:mac": "node build-config/pack.js && npm run publish:mac",
"publish:mac": "npm run publish:mac:dmg",
"publish:mac:dmg": "electron-builder -m=dmg -p onTagOrDraft",
"publish:gh:linux": "node build-config/pack.js && npm run publish:linux",
"publish:linux": "npm run publish:linux:appImage && npm run publish:linux:deb",
"publish:linux:appImage": "cross-env ARCH=x64 electron-builder -l=AppImage -p onTagOrDraft",
"publish:linux:deb": "npm run publish:linux:deb:x64 && npm run publish:linux:deb:x86",
"publish:linux:deb:x64": "cross-env ARCH=x64 electron-builder -l=deb --x64 -p onTagOrDraft",
"publish:linux:deb:x86": "cross-env ARCH=x86 electron-builder -l=deb --ia32 -p onTagOrDraft",
"pack:linux": "node build-config/pack.js && electron-builder -l", "pack:linux": "node build-config/pack.js && electron-builder -l",
"pack:dir": "node build-config/pack.js && electron-builder --dir", "pack:dir": "node build-config/pack.js && electron-builder --dir",
"dev": "node build-config/runner-dev.js", "dev": "node build-config/runner-dev.js",
@ -53,43 +62,51 @@
"files": [ "files": [
"dist/electron/**/*" "dist/electron/**/*"
], ],
"extraResources": [
"./licenses"
],
"win": { "win": {
"icon": "src/static/icons/lunch.ico", "icon": "./resources/icons/256x256.ico",
"legalTrademarks": "lyswhut", "legalTrademarks": "lyswhut",
"artifactName": "${productName} v${version} ${env.ARCH} ${env.TARGET}.${ext}" "artifactName": "${productName} v${version} ${env.ARCH} ${env.TARGET}.${ext}"
}, },
"mac": {
"icon": "./resources/icons/512x512.png",
"category": "public.app-category.music"
},
"linux": { "linux": {
"target": [ "maintainer": "lyswhut <lyswuhut@qq.com>",
{ "artifactName": "${productName} v${version} ${env.ARCH}.${ext}"
"target": "AppImage",
"arch": [
"x64"
]
},
{
"arch": [
"ia32",
"x64"
],
"target": "deb"
},
{
"arch": [
"x64"
],
"target": "snap"
}
],
"maintainer": "lyswhut <lyswuhut@qq.com>"
}, },
"nsis": { "nsis": {
"oneClick": false, "oneClick": false,
"language": "2052", "language": "2052",
"allowToChangeInstallationDirectory": true, "allowToChangeInstallationDirectory": true,
"differentialPackage": true, "differentialPackage": true,
"license": "./license.rtf", "license": "./licenses/license.rtf",
"shortcutName": "lx-music" "shortcutName": "lx-music"
}, },
"dmg": {
"contents": [
{
"x": 110,
"y": 150,
"name": "lx-music"
},
{
"x": 240,
"y": 150,
"type": "link",
"path": "/Applications",
"name": "lx-music"
}
],
"title": "洛雪音乐助手 v${version}"
},
"appImage": {
"license": "./licenses/license_zh.txt",
"category": "Audio"
},
"publish": [ "publish": [
{ {
"provider": "github", "provider": "github",

View File

@ -0,0 +1,8 @@
### 新增
- 新增**MAC**及**Linux**版本(需要的可自行下载)
- 新增任务栏播放进度条控制选项(现在可在设置界面关闭在任务栏显示的播放进度)
### 修复
- 强制把临时接口设置回 `messoer` 接口

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

BIN
resources/icons/512x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

4
src/common/utils.js Normal file
View File

@ -0,0 +1,4 @@
export const isLinux = process.platform == 'linux'
export const isWin = process.platform == 'win32'
export const isMac = process.platform == 'darwin'

View File

@ -1,10 +1,11 @@
const { app, BrowserWindow } = require('electron') const { app, BrowserWindow, Menu } = require('electron')
const path = require('path') const path = require('path')
require('./events') require('./events')
const progressBar = require('./events/progressBar') const progressBar = require('./events/progressBar')
const trafficLight = require('./events/trafficLight') const trafficLight = require('./events/trafficLight')
const autoUpdate = require('./utils/autoUpdate') const autoUpdate = require('./utils/autoUpdate')
const { isLinux, isMac } = require('../common/utils')
const isDev = process.env.NODE_ENV !== 'production' const isDev = process.env.NODE_ENV !== 'production'
@ -33,8 +34,8 @@ function createWindow() {
useContentSize: true, useContentSize: true,
width: 920, width: 920,
frame: false, frame: false,
transparent: true, transparent: !isLinux,
icon: path.join(global.__static, 'icons/lunch.ico'), // icon: path.join(global.__static, isWin ? 'icons/256x256.ico' : 'icons/512x512.png'),
resizable: false, resizable: false,
maximizable: false, maximizable: false,
fullscreenable: false, fullscreenable: false,
@ -58,6 +59,24 @@ function createWindow() {
if (!isDev) autoUpdate(mainWindow) 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.once('ready', createWindow)
app.on('window-all-closed', () => { app.on('window-all-closed', () => {

View File

@ -1,5 +1,5 @@
<template lang="pug"> <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 core-aside#left
#right #right
core-toolbar#toolbar core-toolbar#toolbar
@ -20,14 +20,20 @@
<script> <script>
import { mapMutations, mapGetters, mapActions } from 'vuex' import { mapMutations, mapGetters, mapActions } from 'vuex'
import { rendererOn } from '../common/icp' import { rendererOn } from '../common/icp'
import { isLinux } from '../common/utils'
window.ELECTRON_DISABLE_SECURITY_WARNINGS = process.env.ELECTRON_DISABLE_SECURITY_WARNINGS window.ELECTRON_DISABLE_SECURITY_WARNINGS = process.env.ELECTRON_DISABLE_SECURITY_WARNINGS
const win = require('electron').remote.getCurrentWindow() let win
const body = document.body let body
if (!isLinux) {
win = require('electron').remote.getCurrentWindow()
body = document.body
}
export default { export default {
data() { data() {
return { return {
isProd: process.env.NODE_ENV === 'production', isProd: process.env.NODE_ENV === 'production',
isLinux,
globalObj: { globalObj: {
apiSource: 'messoer', apiSource: 'messoer',
}, },
@ -42,6 +48,7 @@ export default {
}), }),
}, },
mounted() { mounted() {
document.body.classList.add(this.isLinux ? 'noTransparent' : 'transparent')
this.init() this.init()
}, },
watch: { watch: {
@ -79,7 +86,7 @@ export default {
...mapMutations('download', ['updateDownloadList']), ...mapMutations('download', ['updateDownloadList']),
...mapMutations(['setSetting']), ...mapMutations(['setSetting']),
init() { init() {
if (this.isProd) { if (this.isProd && !isLinux) {
body.addEventListener('mouseenter', this.dieableIgnoreMouseEvents) body.addEventListener('mouseenter', this.dieableIgnoreMouseEvents)
body.addEventListener('mouseleave', this.enableIgnoreMouseEvents) body.addEventListener('mouseleave', this.enableIgnoreMouseEvents)
} }
@ -97,10 +104,12 @@ export default {
window.globalObj = this.globalObj window.globalObj = this.globalObj
}, },
enableIgnoreMouseEvents() { enableIgnoreMouseEvents() {
if (isLinux) return
win.setIgnoreMouseEvents(false) win.setIgnoreMouseEvents(false)
// console.log('content enable') // console.log('content enable')
}, },
dieableIgnoreMouseEvents() { dieableIgnoreMouseEvents() {
if (isLinux) return
// console.log('content disable') // console.log('content disable')
win.setIgnoreMouseEvents(true, { forward: true }) win.setIgnoreMouseEvents(true, { forward: true })
}, },
@ -146,22 +155,30 @@ export default {
@import './assets/styles/layout.less'; @import './assets/styles/layout.less';
body { body {
// background-color: #fff;
padding: @shadow-app;
user-select: none; user-select: none;
height: 100vh; height: 100vh;
box-sizing: border-box; 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 { #container {
position: relative; position: relative;
display: flex; display: flex;
height: 100%; height: 100%;
box-shadow: 0 0 @shadow-app rgba(0, 0, 0, 0.5);
// background-color: #fff;
border-radius: 4px;
overflow: hidden; overflow: hidden;
} }
#left { #left {
flex: none; flex: none;
width: @width-app-left; width: @width-app-left;

View File

@ -427,7 +427,7 @@ export default {
}, },
sendProgressEvent(status, mode) { sendProgressEvent(status, mode) {
// console.log(status) // console.log(status)
rendererSend('progress', { this.setting.player.isShowTaskProgess && rendererSend('progress', {
status: status < 0.01 ? 0.01 : status, status: status < 0.01 ? 0.01 : status,
mode: mode || 'normal', mode: mode || 'normal',
}) })

View File

@ -167,6 +167,7 @@ export const updateSetting = setting => {
player: { player: {
togglePlayMethod: 'listLoop', togglePlayMethod: 'listLoop',
highQuality: false, highQuality: false,
isShowTaskProgess: true,
}, },
list: { list: {
isShowAlbumName: true, isShowAlbumName: true,

View File

@ -31,6 +31,10 @@ div.scroll(:class="$style.setting")
h3 优先播放高品质音乐 h3 优先播放高品质音乐
div div
material-checkbox(id="setting_player_highQuality" v-model="current_setting.player.highQuality" label="是否启用") 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 下载设置 dt 下载设置
dd(title='下载歌曲保存的路径') dd(title='下载歌曲保存的路径')
h3 下载路径 h3 下载路径
@ -85,9 +89,9 @@ div.scroll(:class="$style.setting")
| 本软件的部分接口使用自 https://github.com/messoer | 本软件的部分接口使用自 https://github.com/messoer
strong @messoer strong @messoer
| |
p.small 若有问题可 mail tolyswhut@qq.com 或到 github 提交 issue p.small 若有问题可 mail tolyswhut@qq.com 或到 GitHub 提交 issue
p.small p.small
| 若觉得好用的话可以去GitHub点个 | 若觉得好用的话可以去 GitHub 点个
strong star strong star
| 支持作者哦~~🍻 | 支持作者哦~~🍻
p p
@ -99,6 +103,8 @@ div.scroll(:class="$style.setting")
import { mapGetters, mapMutations } from 'vuex' import { mapGetters, mapMutations } from 'vuex'
import { openDirInExplorer, openSelectDir, openSaveDir, updateSetting, openUrl } from '../utils' import { openDirInExplorer, openSelectDir, openSaveDir, updateSetting, openUrl } from '../utils'
import fs from 'fs' import fs from 'fs'
export default { export default {
name: 'Setting', name: 'Setting',
computed: { computed: {
@ -112,6 +118,7 @@ export default {
player: { player: {
togglePlayMethod: 'random', togglePlayMethod: 'random',
highQuality: false, highQuality: false,
isShowTaskProgess: true,
}, },
list: { list: {
isShowAlbumName: true, isShowAlbumName: true,