Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Init all the modules
theme.init();
quill.init();
editor.init();
sidebar.init();
contextMenu.init();
footer.init();
ipcRenderer.on('message', (e, d) => {
const { method, module, parameters } = d;
modules[module][method](parameters);
});
// Save editor contents
ipc.answerMain('save', async () => {
editor.save();
return true;
});
window.onbeforeunload = (e) => {
const changes = store.get('changes');
if (changes) {
const choice = dialog.showMessageBox({
type: 'question',
buttons: ['Save', 'Cancel', 'Don\'t Save'],
title: 'Confirm',
message: `${store.get('path')} has changes, do you want to save them?`,
detail: 'Your changes will be lost if you close this file without saving.',
icon: `${app.image}`,
});
async init () {
log.info('Initializing config module...')
await config.init()
if (this.$route.name === Route.Player) {
// 播放器不需要加载其他内容
this.starting = false
return
}
log.info('Initializing close tip handler...')
ipc.answerMain(IPCMsg.OpenCloseTip, this.OpenCloseTip)
log.info('Initializing database module...')
await db.init()
log.info('Initializing ffmpeg configuration...')
ffmpeg.setFfmpegPath(ffmpegStatic.path.replace('app.asar', 'app.asar.unpacked'))
log.info('Loading channels...')
this.$store.channels = await db.Channel.findAll()
recorder.init()
this.starting = false
},
onMenuSelect (name) {
function initListeners() {
// Listen for message to toggle theme
ipcRenderer.on('message', (e, d) => {
const { method, module } = d;
if (module === 'theme' && method === 'toggle') {
document.body.classList.toggle('dark');
const isDark = document.body.classList.contains('dark');
settings.set('intro.dark', isDark);
}
});
// Listen for message to show spinner
ipc.answerMain('showSpinner', async () => {
spinner.classList.add('active');
});
// Send message to main process to prompt for a folder.
footer.addEventListener('click', async () => {
spinner.classList.add('active');
const res = await ipc.callMain('openProject');
if (!res) spinner.classList.remove('active');
});
// Open GitHub page when each link is clicked.
document.querySelectorAll('.link').forEach((link) => {
link.addEventListener('click', () => {
shell.openExternal('https://github.com/pacocoursey/Opus/');
});
});
appContainer.subscribe(() => {
// TODO: This can be removed when the update issue is fixed in Electron:
// https://github.com/electron/electron/issues/12636
if (appContainer.state.activeView === prevState.activeView) {
return;
}
prevState = appContainer.state;
ipc.send('app-container-state-updated', appContainer.state);
});
// We send an initial event so it can show the correct menu state after logging out
ipc.send('app-container-state-updated', appContainer.state);
ipc.answerMain('current-portfolio-id', () => appContainer.state.portfolio.id);
window.addEventListener('beforeunload', () => {
ipc.callMain('stop-marketmaker');
});
export default appContainer;
componentDidMount() {
answerMain("window-blur", () => {
this.setState(prevState => ({
isBlur: !prevState.isBlur,
}));
});
}
export const liveStats = callback => {
ipc.answerMain(STATS_CHANNEL_NAME, data => callback(data))
}
const {is, api} = require('electron-util')
const ipc = require('electron-better-ipc')
if (!is.macos) {
const {createElement} = require('react')
const {render} = require('react-dom')
const TrafficLights = require('../common/traffic-lights')
render(
createElement(TrafficLights), document.querySelector('#traffic-lights')
)
}
document.querySelector('#version').innerText = `v${api.app.getVersion()}`
ipc.answerMain('close-current-tab', () => window.close())
async init () {
let data = await ipc.callMain(IPCMsg.GetConfig)
this.setData(data)
ipc.answerMain(IPCMsg.SetConfig, this.setData)
},
async setData (data) {
ReactDOM.render(
React.createElement(TrafficLights),
document.querySelector('#titlebar')
)
document.querySelector('#hamburger').addEventListener('click', () => {
profilesContainer.style.left = '0px'
return backdrop.classList.add('active')
})
backdrop.addEventListener('click', () => {
profilesContainer.style.left = '-275px'
return backdrop.classList.remove('active')
})
ipc.answerMain('close-current-tab', () => window.close())
export const liveClusterReadWrite = callback => {
ipc.answerMain(CLUSTER_CHANNEL_NAME, data => callback(data))
}