feat(webui): show app version in avatar menu using local version file

This commit is contained in:
yiling
2026-06-19 22:57:26 +08:00
parent 5542538a64
commit 66d07d1fb0
5 changed files with 20 additions and 37 deletions
+1 -4
View File
@@ -3,7 +3,4 @@ plugins = ["bun-plugin-tailwind"]
[install]
minimumReleaseAge = 604800 # 7 days in seconds
exact = true
[define]
"__APP_VERSION__" = "'0.0.8'"
exact = true
+14 -13
View File
@@ -1,24 +1,25 @@
import { client } from '@/ui/api/client'
import { Avatar, AvatarFallback, AvatarImage } from '@/ui/components/ui/avatar'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
DropdownMenuSub,
DropdownMenuSubTrigger,
DropdownMenuSubContent,
DropdownMenuPortal,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuPortal,
DropdownMenuSeparator,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuTrigger,
} from '@/ui/components/ui/dropdown-menu'
import { useTeamId } from '@/ui/hooks/use-team-id'
import { signOut } from '@/ui/lib/auth-client'
import { useAuthStore } from '@/ui/stores/auth'
import { useQuery } from '@tanstack/react-query'
import { useNavigate } from '@tanstack/react-router'
import { useTheme } from './theme-provider'
import { Check } from 'lucide-react'
import { APP_VERSION } from '../version'
import { useTheme } from './theme-provider'
const Github = (props: React.SVGProps<SVGSVGElement>) => (
<svg
@@ -145,13 +146,13 @@ export function UserMenu() {
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem
className="text-xs text-muted-foreground flex items-center gap-2 cursor-pointer focus:bg-accent focus:text-accent-foreground"
className="text-xs text-muted-foreground flex items-center gap-2 cursor-pointer focus:bg-accent focus:text-accent-foreground justify-center bg-accent border"
onClick={() =>
window.open('https://github.com/shumaiOne/shumai', '_blank', 'noopener,noreferrer')
}
>
<Github className="size-3.5" />
<span>Version {__APP_VERSION__}</span>
<span>Version {APP_VERSION}</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
-6
View File
@@ -1,6 +0,0 @@
/* eslint-disable @typescript-eslint/naming-convention */
declare global {
const __APP_VERSION__: string
}
export {}
+1
View File
@@ -0,0 +1 @@
export const APP_VERSION = '0.0.8'
+4 -14
View File
@@ -92,20 +92,10 @@ function updateVersions(newVersion: string) {
console.log(` Updated version in ${file}`)
}
if (existsSync('bunfig.toml')) {
let content = readFileSync('bunfig.toml', 'utf-8')
const appVersionLine = `"__APP_VERSION__" = "'${newVersion}'"`
if (content.includes('__APP_VERSION__')) {
content = content.replace(/"__APP_VERSION__"\s*=\s*['"].*?['"]/, appVersionLine)
} else {
if (content.includes('[define]')) {
content = content.replace('[define]', `[define]\n${appVersionLine}`)
} else {
content = content.trimEnd() + `\n\n[define]\n${appVersionLine}\n`
}
}
writeFileSync('bunfig.toml', content, 'utf-8')
console.log(' Updated version in bunfig.toml')
const versionFile = 'packages/webui/version.ts'
if (existsSync(versionFile)) {
writeFileSync(versionFile, `export const APP_VERSION = '${newVersion}'\n`, 'utf-8')
console.log(` Updated version in ${versionFile}`)
}
}