feat(ui): display version and git hash in header

Add version info display below "ERP Auto" logo showing format:
${version}(${git-hash})

- Inject __APP_VERSION__ and __GIT_HASH__ via vite define
- Add TypeScript declarations for global constants
- Simplify portable artifact name (remove version)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-03-16 15:00:38 +08:00
parent 9e577a2226
commit cccc4e4c8c
5 changed files with 30 additions and 6 deletions

View File

@@ -10,8 +10,6 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
npm run dev # Start development server with hot reload
npm run build # Full build with type checking
npm run build:win # Build Windows executable
npm run build:mac # Build macOS DMG
npm run build:linux # Build Linux AppImage
```
### Code Quality

View File

@@ -27,7 +27,7 @@ win:
- nsis
- portable
portable:
artifactName: ${name}-${version}-portable.${ext}
artifactName: ${name}-portable.${ext}
# Portable app uses user data directory (AppData), not exe directory
# This ensures config persists across app updates
nsis:

View File

@@ -2,11 +2,29 @@ import { resolve } from 'path'
import { defineConfig } from 'electron-vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { execSync } from 'child_process'
// Get git hash (first 7 characters)
const getGitHash = (): string => {
try {
return execSync('git rev-parse --short=7 HEAD', { encoding: 'utf-8' }).trim()
} catch {
return 'unknown'
}
}
// Get version from package.json
const version = require('./package.json').version
const gitHash = getGitHash()
export default defineConfig({
main: {},
preload: {},
renderer: {
define: {
__APP_VERSION__: JSON.stringify(version),
__GIT_HASH__: JSON.stringify(gitHash)
},
resolve: {
alias: {
'@renderer': resolve('src/renderer/src')

View File

@@ -332,12 +332,17 @@ function App(): React.JSX.Element {
</div>
<div
className="flex items-center gap-2 text-white font-bold text-lg cursor-pointer"
className="flex flex-col cursor-pointer"
onClick={() => setCurrentPage('home')}
style={{ WebkitAppRegion: 'no-drag' } as any}
>
<LayoutDashboard size={22} className="text-blue-500" />
<span>ERP Auto</span>
<div className="flex items-center gap-2 text-white font-bold text-lg">
<LayoutDashboard size={22} className="text-blue-500" />
<span>ERP Auto</span>
</div>
<span className="text-xs text-slate-400 ml-7">
{__APP_VERSION__}({__GIT_HASH__})
</span>
</div>
</div>

View File

@@ -1 +1,4 @@
/// <reference types="vite/client" />
declare const __APP_VERSION__: string
declare const __GIT_HASH__: string