mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2025-02-21 11:12:42 +08:00
fix: bugs
This commit is contained in:
parent
bc0de620c1
commit
43fd1bc536
@ -36,7 +36,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isElectron: process.env.IS_ELECTRON, // "true" || undefined
|
||||
isElectron: process.env.IS_ELECTRON, // true || undefined
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
@ -9,7 +9,7 @@ import { changeAppearance } from "@/utils/common";
|
||||
import updateApp from "@/utils/updateApp";
|
||||
import pkg from "../../package.json";
|
||||
// vuex 自定义插件
|
||||
import vuexBroadCast from "./plugins/broadcast";
|
||||
import { getBroadcastPlugin } from "./plugins/broadcast";
|
||||
import saveToLocalStorage from "./plugins/localStorage";
|
||||
|
||||
if (localStorage.getItem("appVersion") === null) {
|
||||
@ -24,11 +24,17 @@ updateApp();
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
let plugins = [saveToLocalStorage];
|
||||
if (process.env.IS_ELECTRON === true) {
|
||||
let vuexBroadCast = getBroadcastPlugin();
|
||||
plugins.push(vuexBroadCast);
|
||||
}
|
||||
|
||||
const options = {
|
||||
state,
|
||||
mutations,
|
||||
actions,
|
||||
plugins: [saveToLocalStorage, vuexBroadCast],
|
||||
plugins,
|
||||
};
|
||||
|
||||
const store = new Vuex.Store(options);
|
||||
|
@ -1,22 +1,23 @@
|
||||
// const electron = import('electron')
|
||||
const electron = window.require("electron");
|
||||
const ipcRenderer = electron.ipcRenderer;
|
||||
export function getBroadcastPlugin() {
|
||||
const electron = window.require("electron");
|
||||
const ipcRenderer = electron.ipcRenderer;
|
||||
|
||||
export default (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);
|
||||
}
|
||||
});
|
||||
};
|
||||
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);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user