Add version number to settings dialog.

For the web app we also display the git hash.
This commit is contained in:
Jonatan Heyman 2024-01-12 15:08:53 +01:00
parent 37b62d416e
commit 295e55552b
6 changed files with 41 additions and 10 deletions

View File

@ -3,6 +3,7 @@ import { app, BrowserWindow, nativeTheme } from 'electron'
import { win } from "./index" import { win } from "./index"
import CONFIG from "../config" import CONFIG from "../config"
import { getVersionString } from './version'
let aboutWindow = null; let aboutWindow = null;
@ -33,10 +34,7 @@ export function openAboutWindow() {
aboutWindow.loadFile(join(process.env.DIST, 'about.html')) aboutWindow.loadFile(join(process.env.DIST, 'about.html'))
} }
let versionString = app.getVersion() let versionString = getVersionString()
if (CONFIG.get("settings.allowBetaVersions")) {
versionString += " (beta channel)"
}
// don't show until content is loaded // don't show until content is loaded
aboutWindow.webContents.on("did-finish-load", () => { aboutWindow.webContents.on("did-finish-load", () => {

12
electron/main/version.js Normal file
View File

@ -0,0 +1,12 @@
import { app, ipcMain } from "electron"
import CONFIG from "../config"
export function getVersionString() {
let versionString = app.getVersion()
if (CONFIG.get("settings.allowBetaVersions")) {
versionString += " (beta channel)"
}
return versionString
}
ipcMain.handle("getVersion", () => getVersionString())

View File

@ -100,6 +100,10 @@ contextBridge.exposeInMainWorld("heynote", {
ipcRenderer.invoke(UPDATE_CHECK_FOR_UPDATES) ipcRenderer.invoke(UPDATE_CHECK_FOR_UPDATES)
}, },
}, },
async getVersion() {
return await ipcRenderer.invoke("getVersion")
}
}) })

View File

@ -44,6 +44,7 @@
customBufferLocation: !!this.initialSettings.bufferPath, customBufferLocation: !!this.initialSettings.bufferPath,
systemFonts: [[defaultFontFamily, defaultFontFamily + " (default)"]], systemFonts: [[defaultFontFamily, defaultFontFamily + " (default)"]],
defaultFontSize: defaultFontSize, defaultFontSize: defaultFontSize,
appVersion: "",
} }
}, },
@ -56,6 +57,8 @@
window.addEventListener("keydown", this.onKeyDown); window.addEventListener("keydown", this.onKeyDown);
this.$refs.keymapSelector.focus() this.$refs.keymapSelector.focus()
this.appVersion = await window.heynote.getVersion()
}, },
beforeUnmount() { beforeUnmount() {
window.removeEventListener("keydown", this.onKeyDown); window.removeEventListener("keydown", this.onKeyDown);
@ -134,8 +137,7 @@
@click="activeTab = 'appearance'" @click="activeTab = 'appearance'"
/> />
<TabListItem <TabListItem
v-if="!isWebApp" :name="isWebApp ? 'Version' : 'Updates'"
name="Updates"
tab="updates" tab="updates"
:activeTab="activeTab" :activeTab="activeTab"
@click="activeTab = 'updates'" @click="activeTab = 'updates'"
@ -292,8 +294,15 @@
</div> </div>
</TabContent> </TabContent>
<TabContent tab="updates" :activeTab="activeTab" v-if="!isWebApp"> <TabContent tab="updates" :activeTab="activeTab">
<div class="row"> <div class="row">
<div class="entry">
<h2>Current Version</h2>
<b>{{ appVersion }}</b>
</div>
</div>
<div class="row" v-if="!isWebApp">
<div class="entry"> <div class="entry">
<h2>Auto Update</h2> <h2>Auto Update</h2>
<label> <label>
@ -306,7 +315,7 @@
</label> </label>
</div> </div>
</div> </div>
<div class="row"> <div class="row" v-if="!isWebApp">
<div class="entry"> <div class="entry">
<h2>Beta Versions</h2> <h2>Beta Versions</h2>
<label> <label>

View File

@ -148,6 +148,10 @@ const Heynote = {
currencyData = JSON.parse(await response.text()) currencyData = JSON.parse(await response.text())
return currencyData return currencyData
}, },
async getVersion() {
return __APP_VERSION__ + " (" + __GIT_HASH__ + ")"
},
} }
export { Heynote, ipcRenderer} export { Heynote, ipcRenderer}

View File

@ -2,8 +2,8 @@ import path from 'path'
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
//import { directoryPlugin } from "vite-plugin-list-directory-contents";
import * as child from "child_process";
const middleware = () => { const middleware = () => {
return { return {
@ -33,7 +33,6 @@ export default defineConfig({
plugins: [ plugins: [
vue(), vue(),
//directoryPlugin({ baseDir: __dirname }),
], ],
css: { css: {
@ -51,4 +50,9 @@ export default defineConfig({
'@': path.resolve(__dirname, '..'), '@': path.resolve(__dirname, '..'),
}, },
}, },
define: {
'__APP_VERSION__': JSON.stringify(process.env.npm_package_version),
'__GIT_HASH__': JSON.stringify(child.execSync('git rev-parse --short HEAD').toString().trim()),
},
}) })