Merge pull request #69 from njzydark/patch-4

feat: support unblock unplayable music
This commit is contained in:
qier222 2020-12-02 13:10:59 +08:00 committed by GitHub
commit 8cc8ed9273
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 1 deletions

View file

@ -1,4 +1,5 @@
import { app, ipcMain } from "electron";
import match from "@nondanee/unblockneteasemusic";
export function initIpcMain(win) {
// Make vuex copy for electron.
@ -8,6 +9,12 @@ export function initIpcMain(win) {
global.vuexCopy = state;
});
ipcMain.on("unblock-music", (event, id) => {
match(id, ["qq", "kuwo", "migu"]).then((res) => {
event.returnValue = res;
});
});
ipcMain.on("close", () => {
win.close();
app.quit();

View file

@ -6,6 +6,9 @@ import localforage from "localforage";
import store from "@/store";
import { cacheTrack } from "@/utils/db";
const electron = window.require("electron");
const ipcRenderer = electron.ipcRenderer;
export default {
switchTrack({ state, dispatch, commit }, basicTrack) {
getTrackDetail(basicTrack.id).then((data) => {
@ -36,7 +39,12 @@ export default {
document.title = `${track.name} · ${track.ar[0].name} - YesPlayMusic`;
if (track.playable === false) {
dispatch("nextTrack");
const res = ipcRenderer.sendSync("unblock-music", track.id);
if (res?.url) {
commitMP3(res.url);
} else {
dispatch("nextTrack");
}
return;
}