fix: bugs

This commit is contained in:
qier222 2021-03-06 23:44:32 +08:00
parent 0b701d23da
commit ee248be2c5
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D
18 changed files with 3712 additions and 3901 deletions

View File

@ -1,5 +1,5 @@
VUE_APP_NETEASE_API_URL=http://127.0.0.1:3000 VUE_APP_NETEASE_API_URL=/api
VUE_APP_ELECTRON_API_URL=/api VUE_APP_ELECTRON_API_URL=/api
VUE_APP_ELECTRON_API_URL_DEV=http://127.0.0.1:3000 VUE_APP_ELECTRON_API_URL_DEV=http://127.0.0.1:3000
VUE_APP_ENABLE_SENTRY=false VUE_APP_ENABLE_SENTRY=false
DEV_SERVER_PORT=20201 DEV_SERVER_PORT=20201

View File

@ -8,7 +8,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [macos-latest, windows-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Check out Git repository - name: Check out Git repository
@ -17,10 +17,17 @@ jobs:
- name: Install Node.js, NPM and Yarn - name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 12.16.3 node-version: 14.16.0
- name: Install RPM & Pacman (only on Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update &&
sudo apt-get install --no-install-recommends -y rpm &&
sudo apt-get install --no-install-recommends -y bsdtar
- name: Build/release Electron app - name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1 uses: samuelmeuli/action-electron-builder@v1.6.0
with: with:
# GitHub token, automatically provided to the action # GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings) # (No need to define this secret in the repo settings)
@ -35,11 +42,17 @@ jobs:
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: YesPlayMusic-mac name: YesPlayMusic-mac
path: dist_electron/*.dmg path: dist_electron/*-universal.dmg
if-no-files-found: ignore if-no-files-found: ignore
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: YesPlayMusic-win name: YesPlayMusic-win
path: dist_electron/*.exe path: dist_electron/*Setup*.exe
if-no-files-found: ignore
- uses: actions/upload-artifact@v2
with:
name: YesPlayMusic-linux
path: dist_electron/*.AppImage
if-no-files-found: ignore if-no-files-found: ignore

View File

@ -33,7 +33,8 @@
"core-js": "^3.6.5", "core-js": "^3.6.5",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"dayjs": "^1.8.36", "dayjs": "^1.8.36",
"electron": "11.0.2", "electron": "^12.0.0",
"electron-builder": "^22.10.5",
"electron-context-menu": "^2.3.0", "electron-context-menu": "^2.3.0",
"electron-debug": "^3.1.0", "electron-debug": "^3.1.0",
"electron-devtools-installer": "^3.1.1", "electron-devtools-installer": "^3.1.1",
@ -60,7 +61,6 @@
"vscode-codicons": "^0.0.14", "vscode-codicons": "^0.0.14",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-analytics": "^5.22.1", "vue-analytics": "^5.22.1",
"vue-electron": "^1.0.6",
"vue-i18n": "^8.22.0", "vue-i18n": "^8.22.0",
"vue-router": "^3.4.3", "vue-router": "^3.4.3",
"vue-slider-component": "^3.2.5", "vue-slider-component": "^3.2.5",
@ -76,7 +76,6 @@
"@vue/cli-plugin-vuex": "~4.5.0", "@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0", "@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"electron-builder": "^22.10.5",
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2", "eslint-plugin-vue": "^6.2.2",
"husky": "^4.3.0", "husky": "^4.3.0",

BIN
public/img/icons/exit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

BIN
public/img/icons/left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

BIN
public/img/icons/like.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

BIN
public/img/icons/play.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

BIN
public/img/icons/repeat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

BIN
public/img/icons/right.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

View File

@ -12,6 +12,7 @@ import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer";
import express from "express"; import express from "express";
import expressProxy from "express-http-proxy"; import expressProxy from "express-http-proxy";
import Store from "electron-store"; import Store from "electron-store";
import path from "path";
class Background { class Background {
constructor() { constructor() {
@ -88,20 +89,18 @@ class Background {
createWindow() { createWindow() {
console.log("creating app window"); console.log("creating app window");
// Only for Windows, a special title bar for it
const withoutFrame = process.platform == "win32";
this.window = new BrowserWindow({ this.window = new BrowserWindow({
width: this.store.get("window.width") | 1440, width: this.store.get("window.width") | 1440,
height: this.store.get("window.height") | 840, height: this.store.get("window.height") | 840,
minWidth: 1080, minWidth: 1080,
minHeight: 720, minHeight: 720,
titleBarStyle: "hiddenInset", titleBarStyle: "hiddenInset",
frame: !withoutFrame, frame: process.platform !== "win32",
webPreferences: { webPreferences: {
webSecurity: false, webSecurity: false,
nodeIntegration: true, nodeIntegration: true,
enableRemoteModule: true, enableRemoteModule: true,
contextIsolation: false,
}, },
}); });

View File

@ -8,7 +8,7 @@
<div class="right-part"> <div class="right-part">
<div class="info"> <div class="info">
<div class="title">{{ track.name }}</div> <div class="title">{{ track.name }}</div>
<div class="artist"><ArtistsInLine :artists="track.artists" /></div> <div class="artist"><ArtistsInLine :artists="artists" /></div>
</div> </div>
<div class="controls"> <div class="controls">
<div class="buttons"> <div class="buttons">
@ -47,6 +47,9 @@ export default {
isPlaying() { isPlaying() {
return this.player.playing && this.player.isPersonalFM; return this.player.playing && this.player.isPersonalFM;
}, },
artists() {
return this.track.artists || this.track.ar || [];
},
}, },
methods: { methods: {
play() { play() {

View File

@ -73,15 +73,16 @@
<script> <script>
import ButtonIcon from "@/components/ButtonIcon.vue"; import ButtonIcon from "@/components/ButtonIcon.vue";
import { mapState } from "vuex"; import { mapState } from "vuex";
const platformIsWin32 = window.require
? window.require("os").platform() == "win32"
? true
: false
: false;
const win = platformIsWin32 // import icons for win32 title bar
? window.require("electron").remote.getCurrentWindow() // icons by https://github.com/microsoft/vscode-codicons
: null; import "vscode-codicons/dist/codicon.css";
let win = undefined;
if (process.env.IS_ELECTRON === true) {
const electron = require("electron");
win = electron.remote.BrowserWindow.getFocusedWindow();
}
export default { export default {
name: "Navbar", name: "Navbar",
@ -173,7 +174,7 @@ nav {
display: none; display: none;
} }
[data-electron-platform-win32="yes"] { [data-electron-os="win32"] {
nav { nav {
padding-top: 20px; padding-top: 20px;
-webkit-app-region: no-drag; -webkit-app-region: no-drag;

View File

@ -61,12 +61,4 @@ export function initIpcMain(win, store) {
ipcMain.on("settings", (event, options) => { ipcMain.on("settings", (event, options) => {
store.set("settings", options); store.set("settings", options);
}); });
ipcMain.on("max-restore", () => {
if (win.isMaximized()) {
win.restore();
} else {
win.maximize();
}
});
} }

View File

@ -3,8 +3,8 @@ export function ipcRenderer(vueInstance) {
// 添加专有的类名 // 添加专有的类名
document.body.setAttribute("data-electron", "yes"); document.body.setAttribute("data-electron", "yes");
document.body.setAttribute( document.body.setAttribute(
"data-electron-platform-win32", "data-electron-os",
window.require("os").platform() == "win32" ? "yes" : "no" window.require("os").platform()
); );
// ipc message channel // ipc message channel
const electron = window.require("electron"); const electron = window.require("electron");

View File

@ -21,14 +21,18 @@ export function createTray(win) {
const contextMenu = Menu.buildFromTemplate([ const contextMenu = Menu.buildFromTemplate([
{ {
label: "播放/暂停", label: "播放/暂停",
icon: "src/assets/icons/play.png", icon: nativeImage.createFromPath(
path.join(__static, "img/icons/play.png")
),
click: () => { click: () => {
win.webContents.send("play"); win.webContents.send("play");
}, },
}, },
{ {
label: "上一首", label: "上一首",
icon: "src/assets/icons/left.png", icon: nativeImage.createFromPath(
path.join(__static, "img/icons/left.png")
),
accelerator: "CmdOrCtrl+Left", accelerator: "CmdOrCtrl+Left",
click: () => { click: () => {
win.webContents.send("previous"); win.webContents.send("previous");
@ -36,7 +40,9 @@ export function createTray(win) {
}, },
{ {
label: "下一首", label: "下一首",
icon: "src/assets/icons/right.png", icon: nativeImage.createFromPath(
path.join(__static, "img/icons/right.png")
),
accelerator: "CmdOrCtrl+Right", accelerator: "CmdOrCtrl+Right",
click: () => { click: () => {
win.webContents.send("next"); win.webContents.send("next");
@ -44,7 +50,9 @@ export function createTray(win) {
}, },
{ {
label: "循环播放", label: "循环播放",
icon: "src/assets/icons/repeat.png", icon: nativeImage.createFromPath(
path.join(__static, "img/icons/repeat.png")
),
accelerator: "Alt+R", accelerator: "Alt+R",
click: () => { click: () => {
win.webContents.send("repeat"); win.webContents.send("repeat");
@ -52,7 +60,9 @@ export function createTray(win) {
}, },
{ {
label: "加入喜欢", label: "加入喜欢",
icon: "src/assets/icons/like.png", icon: nativeImage.createFromPath(
path.join(__static, "img/icons/like.png")
),
accelerator: "CmdOrCtrl+L", accelerator: "CmdOrCtrl+L",
click: () => { click: () => {
win.webContents.send("like"); win.webContents.send("like");
@ -60,7 +70,9 @@ export function createTray(win) {
}, },
{ {
label: "退出", label: "退出",
icon: "src/assets/icons/exit.png", icon: nativeImage.createFromPath(
path.join(__static, "img/icons/exit.png")
),
accelerator: "CmdOrCtrl+W", accelerator: "CmdOrCtrl+W",
click: () => { click: () => {
app.exit(); app.exit();

View File

@ -13,10 +13,6 @@ import * as Sentry from "@sentry/browser";
import { Vue as VueIntegration } from "@sentry/integrations"; import { Vue as VueIntegration } from "@sentry/integrations";
import { Integrations } from "@sentry/tracing"; import { Integrations } from "@sentry/tracing";
// import icons for win32 title bar
// icons by https://github.com/microsoft/vscode-codicons
import "vscode-codicons/dist/codicon.css";
Vue.use(VueAnalytics, { Vue.use(VueAnalytics, {
id: "UA-180189423-1", id: "UA-180189423-1",
router, router,

View File

@ -58,6 +58,7 @@ module.exports = {
pluginOptions: { pluginOptions: {
// electron-builder的配置文件 // electron-builder的配置文件
electronBuilder: { electronBuilder: {
nodeIntegration: true,
externals: ["@nondanee/unblockneteasemusic", "@njzy/unblockneteasemusic"], externals: ["@nondanee/unblockneteasemusic", "@njzy/unblockneteasemusic"],
builderOptions: { builderOptions: {
productName: "YesPlayMusic", productName: "YesPlayMusic",
@ -80,20 +81,28 @@ module.exports = {
target: [ target: [
{ {
target: "dmg", target: "dmg",
arch: ["arm64", "x64"], arch: ["x64", "arm64", "universal"],
}, },
{ {
target: "zip", target: "zip",
arch: ["arm64", "x64"], arch: ["x64", "arm64", "universal"],
// arch: ["universal"]
}, },
], ],
artifactName: "${productName}-${arch}.${ext}", artifactName: "${productName}-${os}-${arch}.${ext}",
category: "public.app-category.music", category: "public.app-category.music",
darkModeSupport: true, darkModeSupport: true,
}, },
win: { win: {
target: ["nsis", "portable"], target: [
{
target: "portable",
arch: ["x64"],
},
{
target: "nsis",
arch: ["x64"],
},
],
publisherName: "YesPlayMusic", publisherName: "YesPlayMusic",
icon: "build/icons/icon.ico", icon: "build/icons/icon.ico",
publish: ["github"], publish: ["github"],

7491
yarn.lock

File diff suppressed because it is too large Load Diff