fix(webui): disable dashboard auto update checks

feat(plugins): add plugin marketplace route
This commit is contained in:
LoveLosita
2026-05-12 11:20:28 +08:00
parent f75d98900f
commit 587aa0a531
6 changed files with 555 additions and 497 deletions

View File

@@ -1,39 +1,11 @@
import { useEffect, useState } from 'react'
import { getDashboardVersionStatus, type DashboardVersionStatus } from '@/lib/system-api'
import { cn } from '@/lib/utils'
import { APP_VERSION, formatVersion } from '@/lib/version'
import { formatVersion } from '@/lib/version'
interface LogoAreaProps {
sidebarOpen: boolean
}
export function LogoArea({ sidebarOpen }: LogoAreaProps) {
const [versionStatus, setVersionStatus] = useState<DashboardVersionStatus | null>(null)
useEffect(() => {
let mounted = true
const loadVersionStatus = async () => {
try {
const status = await getDashboardVersionStatus(APP_VERSION)
if (mounted) {
setVersionStatus(status)
}
} catch (error) {
console.debug('检查 WebUI 版本更新失败:', error)
}
}
void loadVersionStatus()
return () => {
mounted = false
}
}, [])
const hasUpdate = versionStatus?.has_update === true && Boolean(versionStatus.latest_version)
return (
<div className="flex h-20 items-center border-b px-4">
<div
@@ -56,35 +28,7 @@ export function LogoArea({ sidebarOpen }: LogoAreaProps) {
<span className="shrink-0 whitespace-nowrap text-sm font-semibold text-primary/70">
{formatVersion()}
</span>
{hasUpdate && (
<a
href={versionStatus?.pypi_url}
target="_blank"
rel="noopener noreferrer"
className={cn(
"inline-flex h-5 min-w-0 items-center rounded-md border border-amber-400/50 px-2",
"bg-amber-400/10 text-[11px] font-semibold text-amber-700",
"transition-colors hover:bg-amber-400/20 dark:text-amber-300"
)}
>
<span className="truncate"> v{versionStatus?.latest_version}</span>
</a>
)}
</div>
{false && hasUpdate && (
<a
href={versionStatus?.pypi_url}
target="_blank"
rel="noopener noreferrer"
className={cn(
"inline-flex h-5 items-center rounded-md border border-amber-400/50 px-2",
"bg-amber-400/10 text-[11px] font-semibold text-amber-700",
"transition-colors hover:bg-amber-400/20 dark:text-amber-300"
)}
>
v{versionStatus?.latest_version}
</a>
)}
<div className="hidden">
<span className="font-bold text-xl text-primary-gradient whitespace-nowrap">MaiBot WebUI</span>
<span className="text-base font-semibold text-primary/70 whitespace-nowrap">

View File

@@ -56,7 +56,7 @@ import { RestartOverlay } from '@/components/restart-overlay'
import { ExpressionReviewer } from '@/components/expression-reviewer'
import { getBotConfig, getModelConfig } from '@/lib/config-api'
import { getReviewStats } from '@/lib/expression-api'
import { getDashboardVersionStatus, type DashboardVersionStatus } from '@/lib/system-api'
import type { DashboardVersionStatus } from '@/lib/system-api'
import { APP_VERSION } from '@/lib/version'
import { ZoomableChart } from '@/components/ui/zoomable-chart'
@@ -132,6 +132,9 @@ interface FeatureStatus {
visualEnabled: boolean
}
const MAIBOT_RELEASES_URL = 'https://github.com/Mai-with-u/MaiBot/releases'
const MAIBOT_WEBUI_RELEASES_URL = 'https://pypi.org/project/maibot-dashboard/'
// 为饼图生成更丰富的颜色方案 (HSL色相均匀分布)
const generatePieColors = (count: number): string[] => {
const colors: string[] = []
@@ -200,48 +203,20 @@ function IndexPageContent() {
let mounted = true
const loadLatestVersions = async () => {
try {
const response = await fetch('https://api.github.com/repos/Mai-with-u/MaiBot/releases?per_page=20', {
headers: { Accept: 'application/vnd.github+json' },
})
if (!response.ok) {
throw new Error(`GitHub release status ${response.status}`)
}
const releases = await response.json() as Array<{
draft?: boolean
prerelease?: boolean
tag_name?: string
html_url?: string
}>
const visibleReleases = releases.filter((release) => !release.draft)
const stableRelease = visibleReleases.find((release) => !release.prerelease)
const testRelease = visibleReleases[0]
if (mounted) {
if (stableRelease?.tag_name) {
setMaibotStableRelease({
version: String(stableRelease.tag_name).replace(/^v/i, '').trim(),
url: stableRelease.html_url || 'https://github.com/Mai-with-u/MaiBot/releases',
})
}
if (testRelease?.tag_name) {
setMaibotTestRelease({
version: String(testRelease.tag_name).replace(/^v/i, '').trim(),
url: testRelease.html_url || 'https://github.com/Mai-with-u/MaiBot/releases',
})
}
}
} catch (error) {
console.debug('检查 MaiBot 最新版本失败:', error)
if (!mounted) {
return
}
try {
const status = await getDashboardVersionStatus(APP_VERSION)
if (mounted) {
setDashboardVersionStatus(status)
}
} catch (error) {
console.debug('妫€鏌?WebUI 鐗堟湰鏇存柊澶辫触:', error)
}
// 阶段 0停止首页主动进行远程版本探测仅保留发布页跳转入口。
setMaibotStableRelease(null)
setMaibotTestRelease(null)
setDashboardVersionStatus({
current_version: APP_VERSION,
latest_version: null,
has_update: false,
package_name: 'maibot-dashboard',
pypi_url: MAIBOT_WEBUI_RELEASES_URL,
})
}
void loadLatestVersions()
@@ -631,7 +606,7 @@ function IndexPageContent() {
</div>
<div className="hidden">
<a
href={maibotTestRelease?.url || 'https://github.com/Mai-with-u/MaiBot/releases'}
href={maibotTestRelease?.url || MAIBOT_RELEASES_URL}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1 transition-colors hover:text-muted-foreground"
@@ -642,38 +617,38 @@ function IndexPageContent() {
</div>
<div className="space-y-1 border-t border-border/50 pt-2 text-xs text-muted-foreground/60">
<a
href={maibotStableRelease?.url || 'https://github.com/Mai-with-u/MaiBot/releases'}
href={maibotStableRelease?.url || MAIBOT_RELEASES_URL}
target="_blank"
rel="noopener noreferrer"
className="flex items-center justify-between gap-2 transition-colors hover:text-muted-foreground"
>
<span></span>
<span></span>
<span className="inline-flex items-center gap-1">
{maibotStableRelease ? `v${maibotStableRelease.version}` : 'GitHub Releases'}
GitHub Releases
<ExternalLink className="h-3 w-3" />
</span>
</a>
<a
href={maibotTestRelease?.url || 'https://github.com/Mai-with-u/MaiBot/releases'}
href={maibotTestRelease?.url || MAIBOT_RELEASES_URL}
target="_blank"
rel="noopener noreferrer"
className="flex items-center justify-between gap-2 transition-colors hover:text-muted-foreground"
>
<span></span>
<span></span>
<span className="inline-flex items-center gap-1">
{maibotTestRelease ? `v${maibotTestRelease.version}` : 'GitHub Releases'}
GitHub Releases
<ExternalLink className="h-3 w-3" />
</span>
</a>
<a
href={dashboardVersionStatus?.pypi_url || 'https://pypi.org/project/maibot-dashboard/'}
href={dashboardVersionStatus?.pypi_url || MAIBOT_WEBUI_RELEASES_URL}
target="_blank"
rel="noopener noreferrer"
className="flex items-center justify-between gap-2 transition-colors hover:text-muted-foreground"
>
<span>WebUI </span>
<span> WebUI </span>
<span className="inline-flex items-center gap-1">
v{dashboardVersionStatus?.latest_version || APP_VERSION}
PyPI
<ExternalLink className="h-3 w-3" />
</span>
</a>