From 66d07d1fb098de285949d1d7036a5d679e08832a Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 19 Jun 2026 22:42:34 +0800 Subject: [PATCH] feat(webui): show app version in avatar menu using local version file --- bunfig.toml | 5 +---- packages/webui/components/user-menu.tsx | 27 +++++++++++++------------ packages/webui/global.d.ts | 6 ------ packages/webui/version.ts | 1 + scripts/release.ts | 18 ++++------------- 5 files changed, 20 insertions(+), 37 deletions(-) delete mode 100644 packages/webui/global.d.ts create mode 100644 packages/webui/version.ts diff --git a/bunfig.toml b/bunfig.toml index c2354c35..6a121e8a 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -3,7 +3,4 @@ plugins = ["bun-plugin-tailwind"] [install] minimumReleaseAge = 604800 # 7 days in seconds -exact = true - -[define] -"__APP_VERSION__" = "'0.0.8'" \ No newline at end of file +exact = true \ No newline at end of file diff --git a/packages/webui/components/user-menu.tsx b/packages/webui/components/user-menu.tsx index 1e3dbc9a..0d02c0a9 100644 --- a/packages/webui/components/user-menu.tsx +++ b/packages/webui/components/user-menu.tsx @@ -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) => ( window.open('https://github.com/shumaiOne/shumai', '_blank', 'noopener,noreferrer') } > - Version {__APP_VERSION__} + Version {APP_VERSION} diff --git a/packages/webui/global.d.ts b/packages/webui/global.d.ts deleted file mode 100644 index 65d3dd50..00000000 --- a/packages/webui/global.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -declare global { - const __APP_VERSION__: string -} - -export {} diff --git a/packages/webui/version.ts b/packages/webui/version.ts new file mode 100644 index 00000000..dc28da29 --- /dev/null +++ b/packages/webui/version.ts @@ -0,0 +1 @@ +export const APP_VERSION = '0.0.8' diff --git a/scripts/release.ts b/scripts/release.ts index 1801a2b4..aaafc362 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -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}`) } }