mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 21:28:06 +00:00
Merge pull request #69 from njzydark/patch-4
feat: support unblock unplayable music
This commit is contained in:
commit
8cc8ed9273
5 changed files with 23 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue