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 CONFIG from "../config"
import { getVersionString } from './version'
let aboutWindow = null;
@ -33,10 +34,7 @@ export function openAboutWindow() {
aboutWindow.loadFile(join(process.env.DIST, 'about.html'))
}
let versionString = app.getVersion()
if (CONFIG.get("settings.allowBetaVersions")) {
versionString += " (beta channel)"
}
let versionString = getVersionString()
// don't show until content is loaded
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)
},
},
async getVersion() {
return await ipcRenderer.invoke("getVersion")
}
})

View File

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

View File

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

View File

@ -2,8 +2,8 @@ import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
//import { directoryPlugin } from "vite-plugin-list-directory-contents";
import * as child from "child_process";
const middleware = () => {
return {
@ -33,7 +33,6 @@ export default defineConfig({
plugins: [
vue(),
//directoryPlugin({ baseDir: __dirname }),
],
css: {
@ -51,4 +50,9 @@ export default defineConfig({
'@': 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()),
},
})