feat: releases 版本接口 + 全站仓库链接修正
- 后端 /api/releases/latest 代理 gitea Releases(10min 缓存,无发布/不可达时回退 SUNDYNIX_FALLBACK_VERSION) - 前端 use-release hook 就绪(下载区动态接线暂缓) - 仓库链接统一指向 git.sundynix.cn/sundynix/sundynix-agentix,下载按钮 # 占位改为 releases 页 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ const COLUMNS = [
|
||||
title: 'RESOURCES',
|
||||
links: [
|
||||
{ label: '博客', href: '/blog', internal: true },
|
||||
{ label: 'GitHub', href: SITE.github },
|
||||
{ label: '源码仓库', href: SITE.repo },
|
||||
{ label: 'RSS 订阅', href: '/rss.xml' },
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/** 站点文案与数据,改这里即可,不用动组件 */
|
||||
|
||||
export const SITE = {
|
||||
/** 静态回退版本号;线上以 /api/releases/latest 为准 */
|
||||
version: 'v0.1.2',
|
||||
tagline: '事件驱动的 AI Agent 工作台',
|
||||
github: 'https://github.com/sundynix/agentix',
|
||||
repo: 'https://git.sundynix.cn/sundynix/sundynix-agentix',
|
||||
icp: '滇ICP备2025056308号-1',
|
||||
}
|
||||
|
||||
@@ -118,21 +119,21 @@ export const DOWNLOADS = [
|
||||
os: 'macOS',
|
||||
meta: 'universal · .app · v0.1.2',
|
||||
action: '下载 .dmg',
|
||||
href: '#',
|
||||
href: `${SITE.repo}/releases`,
|
||||
highlight: true,
|
||||
},
|
||||
{
|
||||
os: 'Windows',
|
||||
meta: 'x64 · .exe · v0.1.2',
|
||||
action: '下载 .exe',
|
||||
href: '#',
|
||||
href: `${SITE.repo}/releases`,
|
||||
highlight: false,
|
||||
},
|
||||
{
|
||||
os: '自托管',
|
||||
meta: 'docker compose · 全平台',
|
||||
action: '部署文档',
|
||||
href: '#',
|
||||
href: SITE.repo,
|
||||
highlight: false,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { SITE } from '@/content/site'
|
||||
|
||||
export interface ReleaseInfo {
|
||||
version: string
|
||||
page_url: string
|
||||
macos_url?: string
|
||||
windows_url?: string
|
||||
source: 'gitea' | 'fallback'
|
||||
}
|
||||
|
||||
const STATIC_FALLBACK: ReleaseInfo = {
|
||||
version: SITE.version,
|
||||
page_url: `${SITE.repo}/releases`,
|
||||
source: 'fallback',
|
||||
}
|
||||
|
||||
// 模块级缓存:整个会话只请求一次,多处组件共享
|
||||
let cache: ReleaseInfo | null = null
|
||||
let inflight: Promise<ReleaseInfo> | null = null
|
||||
|
||||
function load(): Promise<ReleaseInfo> {
|
||||
if (cache) return Promise.resolve(cache)
|
||||
inflight ??= fetch('/api/releases/latest')
|
||||
.then(async (res) => {
|
||||
const body = (await res.json()) as { code: number; data: ReleaseInfo }
|
||||
if (!res.ok || body.code !== 0) throw new Error('release api failed')
|
||||
cache = body.data
|
||||
return cache
|
||||
})
|
||||
.catch(() => {
|
||||
cache = STATIC_FALLBACK
|
||||
return cache
|
||||
})
|
||||
return inflight
|
||||
}
|
||||
|
||||
/** 最新版本信息;请求完成前先给静态回退值,避免闪空 */
|
||||
export function useRelease(): ReleaseInfo {
|
||||
const [release, setRelease] = useState<ReleaseInfo>(cache ?? STATIC_FALLBACK)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
load().then((r) => {
|
||||
if (!cancelled) setRelease(r)
|
||||
})
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [])
|
||||
|
||||
return release
|
||||
}
|
||||
@@ -40,7 +40,7 @@ export function Hero() {
|
||||
下载桌面版 <Download className="size-4" />
|
||||
</Link>
|
||||
<a
|
||||
href={SITE.github}
|
||||
href={SITE.repo}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center rounded-lg border border-hairline-strong px-6 py-2.5 font-mono text-[14px] transition-colors hover:border-accent"
|
||||
|
||||
@@ -24,7 +24,7 @@ export function Quickstart() {
|
||||
<span className="text-white/35"># 内嵌 NATS,零配置体验</span>
|
||||
{'\n'}
|
||||
<span className="text-[#22d3ee]">$</span> git clone
|
||||
https://github.com/sundynix/agentix{'\n'}
|
||||
https://git.sundynix.cn/sundynix/sundynix-agentix{'\n'}
|
||||
<span className="text-[#22d3ee]">$</span> make demo{'\n'}
|
||||
{'\n'}
|
||||
<span className="text-white/35"># 或一条命令私有化部署</span>
|
||||
|
||||
Reference in New Issue
Block a user