This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
// local dependencies | |
import { getVersion } from 'common/util'; | |
// import styles (for compilation) | |
import './styles.scss'; | |
// export a react component | |
export default ( props ) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
// import entry component | |
import Entry from './entry'; | |
// render `Entry` component | |
ReactDOM.render( | |
<Entry name='React'/>, | |
document.getElementById( 'app' ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "electron-lessons", | |
"scripts": { | |
"start": "electron-webpack dev", | |
"build": "electron-webpack" | |
}, | |
"devDependencies": { | |
"electron": "^11.1.1", | |
"electron-webpack": "^2.8.2", | |
"webpack": "^4.44.2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang='en'> | |
<head> | |
<meta charset='UTF-8'> | |
<meta name='viewport' content='width=device-width, initial-scale=1.0'> | |
</head> | |
<body style="background-color: #eee;"> | |
<div id='app'></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import path from 'path'; | |
import fs from 'fs'; | |
// get application version from `static/version.txt` | |
export const getVersion = () => { | |
const versionFilePath = path.resolve( __static, 'version.txt' ); | |
return fs.readFileSync( versionFilePath, { | |
encoding: 'utf-8', | |
} ); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { app, BrowserWindow } from 'electron'; | |
import path from 'path'; | |
// local dependencies | |
import { getVersion } from 'common/util'; | |
// get environment type | |
const isDevelopment = process.env.NODE_ENV !== 'production'; | |
// open a window |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "My React App", | |
"main": { | |
"sourceDirectory": "app/main" | |
}, | |
"renderer": { | |
"sourceDirectory": "app/renderer", | |
"template": "app/renderer/index.html" | |
}, | |
"commonSourceDirectory": "app/common", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ipcRenderer } = require( 'electron' ); | |
// copy file | |
window.copyFile = function ( event, itemId ) { | |
event.preventDefault(); | |
// get path of the file | |
const itemNode = document.getElementById( itemId ); | |
const filepath = itemNode.getAttribute( 'data-filepath' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dragDrop = require( 'drag-drop' ); | |
const { ipcRenderer } = require( 'electron' ); | |
// local dependencies | |
const dom = require( './dom' ); | |
/*****************************/ | |
// get list of files from the `main` process | |
ipcRenderer.invoke( 'app:get-files' ).then( ( files = [] ) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang='en'> | |
<head> | |
<meta charset='UTF-8'> | |
<meta name='viewport' content='width=device-width, initial-scale=1.0'> | |
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" /> | |
<title>Files Manager</title> | |
<!-- import fonts --> | |
<link rel="preconnect" href="https://fonts.gstatic.com"> |