mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-12 04:07:42 +08:00
fix: align build version source with tags and VERSION fallback
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useState } from 'react'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import {
|
||||
LayoutDashboard,
|
||||
Upload,
|
||||
@@ -47,6 +47,29 @@ export default function DashboardShell({ token, onLogout, config, fetchConfig, s
|
||||
return res
|
||||
}, [onLogout, t, token])
|
||||
|
||||
|
||||
const [versionInfo, setVersionInfo] = useState(null)
|
||||
|
||||
useEffect(() => {
|
||||
let disposed = false
|
||||
async function loadVersion() {
|
||||
try {
|
||||
const res = await authFetch('/admin/version')
|
||||
const data = await res.json()
|
||||
if (!disposed) {
|
||||
setVersionInfo(data)
|
||||
}
|
||||
} catch (_err) {
|
||||
if (!disposed) {
|
||||
setVersionInfo(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
loadVersion()
|
||||
return () => {
|
||||
disposed = true
|
||||
}
|
||||
}, [authFetch])
|
||||
const renderTab = () => {
|
||||
switch (activeTab) {
|
||||
case 'accounts':
|
||||
@@ -135,6 +158,20 @@ export default function DashboardShell({ token, onLogout, config, fetchConfig, s
|
||||
<div className="text-lg font-bold text-foreground">{config.keys?.length || 0}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-background rounded-lg p-3 border border-border shadow-sm">
|
||||
<div className="text-[9px] text-muted-foreground font-bold uppercase tracking-wider mb-1 opacity-70">{t('sidebar.version')}</div>
|
||||
<div className="text-xs font-semibold text-foreground">{versionInfo?.current_tag || '-'}</div>
|
||||
{versionInfo?.has_update && (
|
||||
<a
|
||||
className="inline-flex mt-1 text-[10px] text-amber-500 hover:text-amber-400"
|
||||
href={versionInfo?.release_url || 'https://github.com/CJackHwang/ds2api/releases/latest'}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
{t('sidebar.updateAvailable', { latest: versionInfo.latest_tag || '' })}
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
onClick={onLogout}
|
||||
className="w-full h-10 flex items-center justify-center gap-2 rounded-lg border border-border text-xs font-medium text-muted-foreground hover:bg-destructive/10 hover:text-destructive hover:border-destructive/20 transition-all"
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
"statusOnline": "Online",
|
||||
"accounts": "Accounts",
|
||||
"keys": "Keys",
|
||||
"signOut": "Sign out"
|
||||
"signOut": "Sign out",
|
||||
"version": "Version",
|
||||
"updateAvailable": "Update available: {latest}"
|
||||
},
|
||||
"auth": {
|
||||
"expired": "Authentication expired. Please sign in again.",
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
"statusOnline": "在线",
|
||||
"accounts": "账号",
|
||||
"keys": "密钥",
|
||||
"signOut": "退出登录"
|
||||
"signOut": "退出登录",
|
||||
"version": "版本",
|
||||
"updateAvailable": "发现新版本 {latest}"
|
||||
},
|
||||
"auth": {
|
||||
"expired": "认证已过期,请重新登录",
|
||||
|
||||
Reference in New Issue
Block a user