feat: 添加版本号显示和自动构建/删除 Docker 镜像功能
- 添加前端版本号显示(桌面端和移动端) - 实现 GitHub Actions 自动构建和推送 Docker 镜像 - 实现删除 release 时自动删除对应 Docker 镜像 - 支持版本号格式:v数字.数字.数字 或 v数字.数字.数字-后缀 - 添加版本号管理文档 - 更新 Dockerfile 和部署脚本支持版本号构建参数
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
||||
} from '@ant-design/icons'
|
||||
import type { MenuProps } from 'antd'
|
||||
import type { ReactNode } from 'react'
|
||||
import { removeToken } from '../utils'
|
||||
import { removeToken, getVersionText, getGitHubTagUrl } from '../utils'
|
||||
import { wsManager } from '../services/websocket'
|
||||
import Logo from './Logo'
|
||||
|
||||
@@ -200,10 +200,33 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between'
|
||||
}}>
|
||||
<Logo
|
||||
size="normal"
|
||||
darkMode={true}
|
||||
/>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>
|
||||
<Logo
|
||||
size="normal"
|
||||
darkMode={true}
|
||||
/>
|
||||
<a
|
||||
href={getGitHubTagUrl()}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onClick={(e) => {
|
||||
const version = getVersionText()
|
||||
if (version === 'dev') {
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
color: 'rgba(255, 255, 255, 0.7)',
|
||||
fontSize: '12px',
|
||||
fontWeight: 'normal',
|
||||
textDecoration: 'none',
|
||||
cursor: getVersionText() === 'dev' ? 'default' : 'pointer'
|
||||
}}
|
||||
title={getVersionText() === 'dev' ? '' : '查看版本发布'}
|
||||
>
|
||||
v{getVersionText()}
|
||||
</a>
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||
<a
|
||||
href="https://github.com/WrBug/PolyHermes"
|
||||
@@ -292,9 +315,36 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
|
||||
fontSize: '18px',
|
||||
fontWeight: 'bold',
|
||||
marginBottom: '12px',
|
||||
textAlign: 'center'
|
||||
textAlign: 'center',
|
||||
display: 'flex',
|
||||
alignItems: 'flex-end',
|
||||
justifyContent: 'center',
|
||||
gap: '6px'
|
||||
}}>
|
||||
PolyHermes
|
||||
<span>PolyHermes</span>
|
||||
<a
|
||||
href={getGitHubTagUrl()}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onClick={(e) => {
|
||||
const version = getVersionText()
|
||||
if (version === 'dev') {
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
color: 'rgba(255, 255, 255, 0.7)',
|
||||
fontSize: '12px',
|
||||
fontWeight: 'normal',
|
||||
textDecoration: 'none',
|
||||
cursor: getVersionText() === 'dev' ? 'default' : 'pointer',
|
||||
lineHeight: '1',
|
||||
paddingBottom: '2px'
|
||||
}}
|
||||
title={getVersionText() === 'dev' ? '' : '查看版本发布'}
|
||||
>
|
||||
v{getVersionText()}
|
||||
</a>
|
||||
</div>
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
|
||||
@@ -45,3 +45,10 @@ export {
|
||||
hasToken
|
||||
} from './auth'
|
||||
|
||||
// 统一导出 version 相关工具函数
|
||||
export {
|
||||
getVersionInfo,
|
||||
getVersionText,
|
||||
getGitHubTagUrl
|
||||
} from './version'
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 版本号配置
|
||||
* 在构建时通过环境变量注入
|
||||
*/
|
||||
export interface VersionInfo {
|
||||
version: string
|
||||
gitTag: string
|
||||
githubRepoUrl: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取版本信息
|
||||
* 从 window.__VERSION__ 或环境变量中读取
|
||||
*/
|
||||
export const getVersionInfo = (): VersionInfo => {
|
||||
// 优先从 window.__VERSION__ 读取(构建时注入)
|
||||
const windowVersion = window.__VERSION__
|
||||
if (windowVersion) {
|
||||
return {
|
||||
version: windowVersion.version || 'dev',
|
||||
gitTag: windowVersion.gitTag || '',
|
||||
githubRepoUrl: windowVersion.githubRepoUrl || 'https://github.com/WrBug/PolyHermes'
|
||||
}
|
||||
}
|
||||
|
||||
// 从环境变量读取(开发环境)
|
||||
return {
|
||||
version: import.meta.env.VITE_APP_VERSION || 'dev',
|
||||
gitTag: import.meta.env.VITE_APP_GIT_TAG || '',
|
||||
githubRepoUrl: import.meta.env.VITE_APP_GITHUB_REPO_URL || 'https://github.com/WrBug/PolyHermes'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取版本号显示文本
|
||||
*/
|
||||
export const getVersionText = (): string => {
|
||||
const info = getVersionInfo()
|
||||
return info.version
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 GitHub tag 页面 URL
|
||||
*/
|
||||
export const getGitHubTagUrl = (): string => {
|
||||
const info = getVersionInfo()
|
||||
if (info.gitTag) {
|
||||
return `${info.githubRepoUrl}/releases/tag/${info.gitTag}`
|
||||
}
|
||||
return info.githubRepoUrl
|
||||
}
|
||||
|
||||
Vendored
+12
@@ -3,9 +3,21 @@
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_API_URL?: string
|
||||
readonly VITE_WS_URL?: string
|
||||
readonly VITE_APP_VERSION?: string
|
||||
readonly VITE_APP_GIT_TAG?: string
|
||||
readonly VITE_APP_GITHUB_REPO_URL?: string
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv
|
||||
}
|
||||
|
||||
// 版本号全局变量类型定义
|
||||
interface Window {
|
||||
__VERSION__?: {
|
||||
version: string
|
||||
gitTag: string
|
||||
githubRepoUrl: string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user