minor updates to design
This commit is contained in:
parent
e1ccfb95a1
commit
7fcfe80d0a
|
@ -17,7 +17,7 @@
|
|||
</form>
|
||||
|
||||
<label id="screenshot-path">Path:</label><br>
|
||||
<button id="path-button" class="btn btn-warning">Select Path</button><br>
|
||||
<button id="path-button" class="btn btn-primary">Select Path</button><br>
|
||||
<button id="screen-shot" class="btn btn-primary">Take Screenshot</button>
|
||||
</div>
|
||||
</body>
|
||||
|
|
26
renderer.js
26
renderer.js
|
@ -1,9 +1,7 @@
|
|||
const electron = require('electron');
|
||||
const remote = electron.remote;
|
||||
const desktopCapturer = electron.desktopCapturer;
|
||||
const electronScreen = electron.screen;
|
||||
const shell = electron.shell;
|
||||
const dialog = remote.dialog;
|
||||
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
|
@ -11,22 +9,9 @@ const path = require('path');
|
|||
|
||||
const screenshot = document.getElementById('screen-shot');
|
||||
const screenshotMsg = document.getElementById('screenshot-path');
|
||||
const pathButton = document.getElementById('path-button');
|
||||
|
||||
var screenshotPath = '';
|
||||
|
||||
pathButton.addEventListener('click', function(event) {
|
||||
dialog.showSaveDialog(function(fileName) {
|
||||
if (fileName === undefined) {
|
||||
return;
|
||||
}
|
||||
screenshotPath = fileName;
|
||||
screenshotMsg.textContent = screenshotPath;
|
||||
});
|
||||
});
|
||||
|
||||
screenshot.addEventListener('click', function(event) {
|
||||
screenshotMsg.textContent = "Gathering screenshot...";
|
||||
screenshotMsg.textContent = 'Gathering screenshot...';
|
||||
const thumbSize = determineScreenShot();
|
||||
let options = { types: ['screen'], thumbnailSize: thumbSize };
|
||||
|
||||
|
@ -35,13 +20,10 @@ screenshot.addEventListener('click', function(event) {
|
|||
|
||||
sources.forEach(function(source) {
|
||||
if (source.name === 'Entire Screen' || source.name === 'Screen 1') {
|
||||
const screenshotPath = path.join(os.tmpdir(), 'screenshot.png');
|
||||
|
||||
if (screenshotPath === '') {
|
||||
screenshotPath = path.join(os.tmpdir(), 'screenshot.png');
|
||||
}
|
||||
|
||||
fs.writeFile(screenshotPath, source.thumbnail.toPng(), function(error) {
|
||||
if (error) return console.log(error.message);
|
||||
fs.writeFile(screenshotPath, source.thumbnail.toPng(), function(err) {
|
||||
if (err) return console.log(err.message);
|
||||
|
||||
shell.openExternal('file://' + screenshotPath);
|
||||
var message = 'Saved screenshot to: ' + screenshotPath;
|
||||
|
|
Loading…
Reference in New Issue
Block a user