Skip to content

Instantly share code, notes, and snippets.

@DrMabuse23
Last active October 28, 2015 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrMabuse23/a85b8cbc5355b1ad39fb to your computer and use it in GitHub Desktop.
Save DrMabuse23/a85b8cbc5355b1ad39fb to your computer and use it in GitHub Desktop.
Menu class
'use strict';
import React from 'react';
import { Router, Route, Link } from 'react-router'
import shell from 'shell';
import fs from 'fs';
import ipc from 'ipc';
export class Main extends React.Component {
state = {
message: 'Hello, Electron'
}
constructor () {
super();
}
componentWillMount(){
ipc.on('open-files', (event, files) => {
console.log(files);
});
}
render() {
return (
<div className="container">
<div className="jumbotron main">
<h1>{this.state.message}</h1>
<img src="../assets/images/electron.svg" alt="" width="128px"></img>
</div>
</div>
);
}
}
import ipc from 'ipc';
import dialog from 'dialog';
export default class OpenFile {
constructor() {
this.files = [];
}
openFolder() {
var self = this;
dialog.showOpenDialog({ properties: ['openDirectory'] }, (resp) => {
self.files = resp;
ipc.send('open-folder', self.files);
console.log(self.files);
});
}
openFiles() {
var self = this;
dialog.showOpenDialog(
{
properties: ['openFile', 'multiSelections'],
filters: [
{ name: 'Json', extensions: ['json'] }
]
},
(resp) => {
self.files = resp;
console.log(self.files);
ipc.send('open-files', self.files);
});
}
}
let template = [
{
label: 'Project',
submenu: [
{
label: 'Add Folder',
click: () => { fileManager.openFolder(); }
},
{
label: 'Add Files',
click: () => { fileManager.openFiles(); }
}
]
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment