Merge pull request #72 from njzydark/pach-1

fix(unblockMusic): the song information may fail to be fetched and reduce the request time
master
qier222 4 years ago committed by GitHub
commit 6f7bbbe333
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,7 +25,7 @@
}, },
"main": "background.js", "main": "background.js",
"dependencies": { "dependencies": {
"@nondanee/unblockneteasemusic": "^0.25.3", "@njzy/unblockneteasemusic": "^0.25.3",
"axios": "^0.21.0", "axios": "^0.21.0",
"big-integer": "^1.6.48", "big-integer": "^1.6.48",
"core-js": "^3.6.5", "core-js": "^3.6.5",

@ -1,5 +1,5 @@
import { app, ipcMain } from "electron"; import { app, ipcMain } from "electron";
import match from "@nondanee/unblockneteasemusic"; import match from "@njzy/unblockneteasemusic";
export function initIpcMain(win) { export function initIpcMain(win) {
// Make vuex copy for electron. // Make vuex copy for electron.
@ -9,9 +9,26 @@ export function initIpcMain(win) {
global.vuexCopy = state; global.vuexCopy = state;
}); });
ipcMain.on("unblock-music", (event, id) => { ipcMain.on("unblock-music", (event, track) => {
match(id, ["qq", "kuwo", "migu"]).then((res) => { // 兼容 unblockneteasemusic 所使用的 api 字段
track.alias = track.alia || [];
track.duration = track.dt || 0;
track.album = track.al || [];
track.artists = track.ar || [];
const matchPromise = match(track.id, ["qq", "kuwo", "migu"], track);
const timeoutPromise = new Promise((_, reject) => {
setTimeout(() => {
reject("timeout");
}, 3000);
});
Promise.race([matchPromise, timeoutPromise])
.then((res) => {
event.returnValue = res; event.returnValue = res;
})
.catch((err) => {
console.log("unblock music error: ", err);
event.returnValue = null;
}); });
}); });

@ -43,7 +43,7 @@ export default {
if (track.playable === false) { if (track.playable === false) {
let res = undefined; let res = undefined;
if (process.env.IS_ELECTRON === true) { if (process.env.IS_ELECTRON === true) {
res = ipcRenderer.sendSync("unblock-music", track.id); res = ipcRenderer.sendSync("unblock-music", track);
} }
if (res?.url) { if (res?.url) {
commitMP3(res.url); commitMP3(res.url);

@ -49,7 +49,7 @@ module.exports = {
pluginOptions: { pluginOptions: {
// electron-builder的配置文件 // electron-builder的配置文件
electronBuilder: { electronBuilder: {
externals: ["@nondanee/unblockneteasemusic"], externals: ["@nondanee/unblockneteasemusic", "@njzy/unblockneteasemusic"],
builderOptions: { builderOptions: {
productName: "YesPlayMusic", productName: "YesPlayMusic",
copyright: "Copyright © YesPlayMusic", copyright: "Copyright © YesPlayMusic",

@ -1265,16 +1265,16 @@
call-me-maybe "^1.0.1" call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0" glob-to-regexp "^0.3.0"
"@njzy/unblockneteasemusic@^0.25.3":
version "0.25.3"
resolved "https://registry.yarnpkg.com/@njzy/unblockneteasemusic/-/unblockneteasemusic-0.25.3.tgz#f8223df756ab3a723af066a75b91357a2b162443"
integrity sha512-rY9SMf6VbJueIvVW22Ut4dX48PBSETvdCoVJNdbKzOMacgxiQ5K5I2ZJtbLhZ0kj27tx7bN5Zo36bSwf2KlP7g==
"@nodelib/fs.stat@^1.1.2": "@nodelib/fs.stat@^1.1.2":
version "1.1.3" version "1.1.3"
resolved "https://registry.npm.taobao.org/@nodelib/fs.stat/download/@nodelib/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" resolved "https://registry.npm.taobao.org/@nodelib/fs.stat/download/@nodelib/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
integrity sha1-K1o6s/kYzKSKjHVMCBaOPwPrphs= integrity sha1-K1o6s/kYzKSKjHVMCBaOPwPrphs=
"@nondanee/unblockneteasemusic@^0.25.3":
version "0.25.3"
resolved "https://registry.yarnpkg.com/@nondanee/unblockneteasemusic/-/unblockneteasemusic-0.25.3.tgz#72d936f18f46523a2b929b8eaec8dfd2acf25e7e"
integrity sha512-Fgl0iRvuFCNhyFlovbqqnJQRomaFVjMLosS1hRUd/X47y6HeNlQsxa9c8RtmeLwNnZ27rj0DsUZlECqU7FyNPA==
"@npmcli/move-file@^1.0.1": "@npmcli/move-file@^1.0.1":
version "1.0.1" version "1.0.1"
resolved "https://registry.npm.taobao.org/@npmcli/move-file/download/@npmcli/move-file-1.0.1.tgz#de103070dac0f48ce49cf6693c23af59c0f70464" resolved "https://registry.npm.taobao.org/@npmcli/move-file/download/@npmcli/move-file-1.0.1.tgz#de103070dac0f48ce49cf6693c23af59c0f70464"

Loading…
Cancel
Save