From 487dac4f16336f44ef421cb6e04716896759505e Mon Sep 17 00:00:00 2001 From: qier222 Date: Tue, 5 Jan 2021 22:21:27 +0800 Subject: [PATCH] fix: remove vuexCopy --- src/electron/ipcMain.js | 7 ------- src/store/index.js | 6 ------ src/store/plugins/broadcast.js | 23 ----------------------- 3 files changed, 36 deletions(-) delete mode 100644 src/store/plugins/broadcast.js diff --git a/src/electron/ipcMain.js b/src/electron/ipcMain.js index 83a3ae8..29e8fc7 100644 --- a/src/electron/ipcMain.js +++ b/src/electron/ipcMain.js @@ -2,13 +2,6 @@ import { app, ipcMain } from "electron"; import match from "@njzy/unblockneteasemusic"; export function initIpcMain(win) { - // Make vuex copy for electron. - global.vuexCopy = null; - // 同步 vuex 状态,由于 player 有循环引用问题,拷贝部分属性 - ipcMain.on("vuex-state", (e, state) => { - global.vuexCopy = state; - }); - ipcMain.on("unblock-music", (event, track) => { // 兼容 unblockneteasemusic 所使用的 api 字段 track.alias = track.alia || []; diff --git a/src/store/index.js b/src/store/index.js index 80fab4f..417d6af 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -7,7 +7,6 @@ import { changeAppearance } from "@/utils/common"; import updateApp from "@/utils/updateApp"; import Player from "@/utils/Player"; // vuex 自定义插件 -import { getBroadcastPlugin } from "./plugins/broadcast"; import saveToLocalStorage from "./plugins/localStorage"; updateApp(); @@ -15,11 +14,6 @@ updateApp(); Vue.use(Vuex); let plugins = [saveToLocalStorage]; -if (process.env.IS_ELECTRON === true) { - let vuexBroadCast = getBroadcastPlugin(); - plugins.push(vuexBroadCast); -} - const options = { state, mutations, diff --git a/src/store/plugins/broadcast.js b/src/store/plugins/broadcast.js deleted file mode 100644 index 921cbfa..0000000 --- a/src/store/plugins/broadcast.js +++ /dev/null @@ -1,23 +0,0 @@ -export function getBroadcastPlugin() { - const electron = window.require("electron"); - const ipcRenderer = electron.ipcRenderer; - - return (store) => { - // 第一行初始化第一次的状态 - ipcRenderer.send("vuex-state", store.state); - store.subscribe( - ( - mutation, - { data = "", settings = "", player = {}, contextMenu = {}, liked = {} } - ) => { - const copyState = { data, settings, player, contextMenu, liked }; - ipcRenderer.send("vuex-state", copyState); - } - ); - store.subscribe((mutation, state) => { - if (mutation.type === "updateData") { - ipcRenderer.send("updateData", state.data); - } - }); - }; -}