Last active
March 12, 2021 14:09
-
-
Save xmedeko/b2f8bca876f73f7c1269bd9b7c05d9ad to your computer and use it in GitHub Desktop.
Revisions
-
xmedeko revised this gist
Mar 12, 2021 . No changes.There are no files selected for viewing
-
xmedeko revised this gist
Mar 12, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ <title>openPath error dialog minimized</title> </head> <body> <h1>openPath error dialog minimized</h1> <br/> <input type="text" id="pathInput" value="%24-error-on-purpose" /> <button id="btn">Open path</button> -
xmedeko revised this gist
Mar 12, 2021 . No changes.There are no files selected for viewing
-
xmedeko revised this gist
Mar 12, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,12 +5,12 @@ <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'"> <meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'"> <title>openPath error dialog minimized</title> </head> <body> <h1>openPath bug</h1> <br/> <input type="text" id="pathInput" value="%24-error-on-purpose" /> <button id="btn">Open path</button> </body> </html> -
xmedeko revised this gist
Mar 12, 2021 . 2 changed files with 6 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -22,9 +22,8 @@ app.on('window-all-closed', function () { if (process.platform !== 'darwin') app.quit() }) ipcMain.on('app-open-path', async (_event, filePath) => { const error = shell.openPath(filePath) //if (error) // dialog.showErrorBox('Test App', error) }) 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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ window.addEventListener('DOMContentLoaded', () => { const btn = document.getElementById('btn') btn.addEventListener('click', () => { const filePath = document.getElementById('pathInput').value shell.openPath(filePath) //ipcRenderer.send('app-open-path', filePath) }) }) -
xmedeko created this gist
Mar 12, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'"> <meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'"> <title>openPath bug</title> </head> <body> <h1>openPath bug</h1> <br/> <input type="text" id="pathInput" /> <button id="btn">Open path</button> </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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ const {app, BrowserWindow, ipcMain, dialog, shell} = require('electron') const path = require('path') function createWindow () { const mainWindow = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: path.join(__dirname, 'preload.js') } }) mainWindow.loadFile('index.html') mainWindow.webContents.openDevTools() } app.whenReady().then(() => { createWindow() app.on('activate', function () { if (BrowserWindow.getAllWindows().length === 0) createWindow() }) }) app.on('window-all-closed', function () { if (process.platform !== 'darwin') app.quit() }) ipcMain.on('app-open-path', (_event, filePath) => { shell.openPath(filePath).then(error => { if (error) dialog.showErrorBox('Test App', error) }) }) 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ const { ipcRenderer, shell } = require("electron"); // All of the Node.js APIs are available in the preload process. // It has the same sandbox as a Chrome extension. window.addEventListener('DOMContentLoaded', () => { const btn = document.getElementById('btn') btn.addEventListener('click', () => { const filePath = document.getElementById('pathInput').value //shell.openPath(filePath) ipcRenderer.send('app-open-path', 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ // This file is required by the index.html file and will // be executed in the renderer process for that window. // No Node.js APIs are available in this process because // \`nodeIntegration\` is turned off. Use \`preload.js\` to // selectively enable features needed in the rendering // process. 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ /* Empty */