From f3e727574adeddd0d76d562be841a1bb4c23e574 Mon Sep 17 00:00:00 2001 From: UKDTOM Date: Sat, 17 Oct 2020 00:40:27 +0200 Subject: [PATCH] #184 set Windows title on Linux/Darwin --- .gitignore | 2 +- package.json | 6 ++++-- script/getGitVer.sh | 9 ++++----- src/background.js | 8 ++++++++ vue.config.js | 4 ++-- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index a7aed1a..359e3e8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,4 @@ yarn-error.log* /dist_electron* #WebTools-NG speclials -/public/version \ No newline at end of file +/public/version.json \ No newline at end of file diff --git a/package.json b/package.json index 775323d..3fdbd60 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,10 @@ "license": "MPL-2.0", "homepage": "https://github.com/WebTools-NG/WebTools-NG", "private": true, - "scripts": { - "serve": "vue-cli-service electron:serve", + "scripts": { + "serve": "run-script-os", + "serve:darwin:linux": "chmod +x script/getGitVer.sh && . script/getGitVer.sh && vue-cli-service electron:serve && unset AppRev", + "serve:win32": "vue-cli-service electron:serve", "build": "run-script-os", "build:darwin:linux": "chmod +x script/getGitVer.sh && . script/getGitVer.sh && vue-cli-service electron:build && unset AppRev", "build:win32": "vue-cli-service electron:build", diff --git a/script/getGitVer.sh b/script/getGitVer.sh index 7ac3e52..6ddaa51 100755 --- a/script/getGitVer.sh +++ b/script/getGitVer.sh @@ -1,9 +1,8 @@ -# get commit hash -rev=$(git rev-parse --short HEAD 2>&1) -# Export to env as well, for the artifact -echo $(git rev-parse --short HEAD) +# Export rev to env, for the artifact export AppRev=$(git rev-parse --short HEAD) # Get git root directory root=$(git rev-parse --show-toplevel 2>&1) +# get commit hash for version file +rev='{"rev":"'$(git rev-parse --short HEAD 2>&1)'"}' # Save to version file -echo "$rev" > "$root/public/version" +echo "$rev" > "$root/public/version.json" \ No newline at end of file diff --git a/src/background.js b/src/background.js index 2c41958..9b3688b 100644 --- a/src/background.js +++ b/src/background.js @@ -46,6 +46,14 @@ function createWindow () { win.on('closed', () => { win = null }) + + // Set proper title for main window + win.webContents.on('did-finish-load', () => { + let rev = require('../public/version.json').rev; + let windowtitle = appName + " v" + process.env.VUE_APP_VERSION + "." + rev; + win.setTitle(windowtitle); + }) + } // Quit when all windows are closed. diff --git a/vue.config.js b/vue.config.js index 5e81e91..58c7275 100644 --- a/vue.config.js +++ b/vue.config.js @@ -18,8 +18,8 @@ module.exports = { "to": "locales" }, { - "from": "./public/version", - "to": "version" + "from": "./public/version.json", + "to": "version.json" } ], linux: {