From 851c2ce6341d3e531492cf710cf35f4f7b5a5904 Mon Sep 17 00:00:00 2001 From: Misaka_Company Date: Wed, 18 Mar 2026 10:44:19 +0800 Subject: [PATCH] feat: add version and git hash to application title Add a custom Vite plugin to transform index.html and include version number and git hash in the application title for better traceability. Co-Authored-By: Claude Sonnet 4.6 --- electron.vite.config.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/electron.vite.config.ts b/electron.vite.config.ts index b3dfb1e..5a6d959 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -3,6 +3,7 @@ import { defineConfig } from 'electron-vite' import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' import { execSync } from 'child_process' +import { createRequire } from 'module' // Get git hash (first 7 characters) const getGitHash = (): string => { @@ -14,6 +15,7 @@ const getGitHash = (): string => { } // Get version from package.json +const require = createRequire(import.meta.url) const version = require('./package.json').version const gitHash = getGitHash() @@ -30,6 +32,18 @@ export default defineConfig({ '@renderer': resolve('src/renderer/src') } }, - plugins: [react(), tailwindcss()] + plugins: [ + react(), + tailwindcss(), + { + name: 'update-title', + transformIndexHtml(html) { + return html.replace( + 'ERP Auto Tool', + `ERPAuto - v${version}(${gitHash})` + ) + } + } + ] } })