From 16d4ace80096557fb3fd48396aa09107241c3131 Mon Sep 17 00:00:00 2001 From: Rik Theunis Date: Tue, 15 Oct 2019 20:17:04 +0200 Subject: [PATCH] docs: add system get version info Fiddle example (#20536) --- .../get-version-information/index.html | 26 +++++++++++++++++++ .../get-version-information/main.js | 25 ++++++++++++++++++ .../get-version-information/renderer.js | 8 ++++++ 3 files changed, 59 insertions(+) create mode 100644 docs/fiddles/system/system-information/get-version-information/index.html create mode 100644 docs/fiddles/system/system-information/get-version-information/main.js create mode 100644 docs/fiddles/system/system-information/get-version-information/renderer.js diff --git a/docs/fiddles/system/system-information/get-version-information/index.html b/docs/fiddles/system/system-information/get-version-information/index.html new file mode 100644 index 000000000000..0867bc3ad7da --- /dev/null +++ b/docs/fiddles/system/system-information/get-version-information/index.html @@ -0,0 +1,26 @@ + + + + + + +
+
+

Get version information

+ Supports: Win, macOS, Linux | Process: Both +
+
+ + +
+

The process module is built into Node.js (therefore you can use this in both the main and renderer processes) and in Electron apps this object has a few more useful properties on it.

+

The example below gets the version of Electron in use by the app.

+

See the process documentation (opens in new window) for more.

+
+
+
+ + + diff --git a/docs/fiddles/system/system-information/get-version-information/main.js b/docs/fiddles/system/system-information/get-version-information/main.js new file mode 100644 index 000000000000..1f9f91774ce0 --- /dev/null +++ b/docs/fiddles/system/system-information/get-version-information/main.js @@ -0,0 +1,25 @@ +const { app, BrowserWindow } = require('electron') + +let mainWindow = null + +function createWindow () { + const windowOptions = { + width: 600, + height: 400, + title: 'Get version information', + webPreferences: { + nodeIntegration: true + } + } + + mainWindow = new BrowserWindow(windowOptions) + mainWindow.loadFile('index.html') + + mainWindow.on('closed', () => { + mainWindow = null + }) +} + +app.on('ready', () => { + createWindow() +}) diff --git a/docs/fiddles/system/system-information/get-version-information/renderer.js b/docs/fiddles/system/system-information/get-version-information/renderer.js new file mode 100644 index 000000000000..40f7f2cf2cf6 --- /dev/null +++ b/docs/fiddles/system/system-information/get-version-information/renderer.js @@ -0,0 +1,8 @@ +const versionInfoBtn = document.getElementById('version-info') + +const electronVersion = process.versions.electron + +versionInfoBtn.addEventListener('click', () => { + const message = `This app is using Electron version: ${electronVersion}` + document.getElementById('got-version-info').innerHTML = message +})