parent
603e39f362
commit
2c8ba10e20
@ -1,76 +1,76 @@
|
||||
import store from "@/store";
|
||||
import store from '@/store';
|
||||
|
||||
const player = store.state.player;
|
||||
|
||||
export function ipcRenderer(vueInstance) {
|
||||
const self = vueInstance;
|
||||
// 添加专有的类名
|
||||
document.body.setAttribute("data-electron", "yes");
|
||||
document.body.setAttribute('data-electron', 'yes');
|
||||
document.body.setAttribute(
|
||||
"data-electron-os",
|
||||
window.require("os").platform()
|
||||
'data-electron-os',
|
||||
window.require('os').platform()
|
||||
);
|
||||
// ipc message channel
|
||||
const electron = window.require("electron");
|
||||
const electron = window.require('electron');
|
||||
const ipcRenderer = electron.ipcRenderer;
|
||||
|
||||
// listens to the main process 'changeRouteTo' event and changes the route from
|
||||
// inside this Vue instance, according to what path the main process requires.
|
||||
// responds to Menu click() events at the main process and changes the route accordingly.
|
||||
|
||||
ipcRenderer.on("changeRouteTo", (event, path) => {
|
||||
ipcRenderer.on('changeRouteTo', (event, path) => {
|
||||
self.$router.push(path);
|
||||
});
|
||||
|
||||
ipcRenderer.on("search", () => {
|
||||
ipcRenderer.on('search', () => {
|
||||
// 触发数据响应
|
||||
self.$refs.navbar.$refs.searchInput.focus();
|
||||
self.$refs.navbar.inputFocus = true;
|
||||
});
|
||||
|
||||
ipcRenderer.on("play", () => {
|
||||
ipcRenderer.on('play', () => {
|
||||
player.playOrPause();
|
||||
});
|
||||
|
||||
ipcRenderer.on("next", () => {
|
||||
ipcRenderer.on('next', () => {
|
||||
player.playNextTrack();
|
||||
});
|
||||
|
||||
ipcRenderer.on("previous", () => {
|
||||
ipcRenderer.on('previous', () => {
|
||||
player.playPrevTrack();
|
||||
});
|
||||
|
||||
ipcRenderer.on("increaseVolume", () => {
|
||||
ipcRenderer.on('increaseVolume', () => {
|
||||
if (player.volume + 0.1 >= 1) {
|
||||
return (player.volume = 1);
|
||||
}
|
||||
player.volume += 0.1;
|
||||
});
|
||||
|
||||
ipcRenderer.on("decreaseVolume", () => {
|
||||
ipcRenderer.on('decreaseVolume', () => {
|
||||
if (player.volume - 0.1 <= 0) {
|
||||
return (player.volume = 0);
|
||||
}
|
||||
player.volume -= 0.1;
|
||||
});
|
||||
|
||||
ipcRenderer.on("like", () => {
|
||||
store.dispatch("likeASong", player.currentTrack.id);
|
||||
ipcRenderer.on('like', () => {
|
||||
store.dispatch('likeATrack', player.currentTrack.id);
|
||||
});
|
||||
|
||||
ipcRenderer.on("repeat", () => {
|
||||
ipcRenderer.on('repeat', () => {
|
||||
player.switchRepeatMode();
|
||||
});
|
||||
|
||||
ipcRenderer.on("shuffle", () => {
|
||||
ipcRenderer.on('shuffle', () => {
|
||||
player.switchShuffle();
|
||||
});
|
||||
|
||||
ipcRenderer.on("routerGo", (event, where) => {
|
||||
ipcRenderer.on('routerGo', (event, where) => {
|
||||
self.$refs.navbar.go(where);
|
||||
});
|
||||
|
||||
ipcRenderer.on("nextUp", () => {
|
||||
ipcRenderer.on('nextUp', () => {
|
||||
self.$refs.player.goToNextTracksPage();
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in new issue