-
Notifications
You must be signed in to change notification settings - Fork 5
/
electron.js
1 lines (1 loc) · 1.25 KB
/
electron.js
1
let electron=require('electron'),url=require('url'),config=require('./assets/config'),{BrowserWindow,Menu,dialog,app,ipcMain}=electron,{join}=require('path'),{platform}=process.env;require('events').EventEmitter.defaultMaxListeners=15;let win,b=[{label:'File',submenu:[{label:'Open File',accelerator:config.open_files,click(){dialog.showOpenDialog({properties:['openFile','multiSelections'],filters:[{name:'Videos',extensions:['mp4','mkv','avi']},{name:'Music',extensions:['mp3','opus','aac','m4a']}]},function(c){if(c){for(let d in c)win.webContents.send('open-file',c[d]);win.webContents.send('kntl',c[c.length-1])}})}}]}];function showWindow(c){win=new BrowserWindow({width:1080,height:600,minWidth:400,minHeight:200}),win.loadURL(url.format({pathname:join(__dirname,c),protocol:'file',slashes:!0})),win.on('closed',()=>{win=null});let d=Menu.buildFromTemplate(b);Menu.setApplicationMenu(d),win.show()}'darwin'===platform&&b.unshift({}),'development'===config.node_env&&b.push({label:'Developer tools',submenu:[{label:'toggle devtools',accelerator:config.open_devtools,click(c,d){d.toggleDevTools()}},{label:'reload',accelerator:config.reload,role:'reload'}]}),app.on('window-all-closed',function(){app.quit()}),app.on('ready',function(){showWindow(`./views/index.html`)});