perf: optimize app startup and background lifecycles

This commit is contained in:
inman
2026-08-19 00:56:15 +08:00
parent 31332f6d76
commit 927e13349b
121 changed files with 4359 additions and 1400 deletions

View File

@@ -57,7 +57,7 @@ import { useAuthStore } from '@/stores/auth';
import { hostApiFetch } from '@/lib/host-api';
import { subscribeHostEvent } from '@/lib/host-events';
const inputClasses = 'h-[44px] rounded-xl font-mono text-meta bg-surface-input border-border/70 focus-visible:ring-2 focus-visible:ring-brand/35 focus-visible:border-brand shadow-sm transition-all text-foreground placeholder:text-foreground/40';
const inputClasses = 'h-[44px] rounded-xl font-mono text-meta bg-surface-input border-border/70 focus-visible:ring-2 focus-visible:ring-brand/35 focus-visible:border-brand shadow-sm transition-colors duration-100 text-foreground placeholder:text-foreground/40';
const labelClasses = 'text-sm text-foreground/80 font-medium';
type ArkMode = 'apikey' | 'codeplan';
@@ -623,7 +623,7 @@ function ProviderCard({
<div
data-testid={`provider-card-${account.id}`}
className={cn(
"group flex flex-col p-4 rounded-2xl transition-all relative overflow-hidden hover:bg-surface-subtle",
"group flex flex-col p-4 rounded-2xl transition-colors duration-100 relative overflow-hidden hover:bg-surface-subtle",
isDefault
? "bg-surface-subtle border border-transparent"
: "bg-transparent border border-transparent"
@@ -631,7 +631,7 @@ function ProviderCard({
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-4">
<div className="h-[42px] w-[42px] shrink-0 flex items-center justify-center text-foreground border border-border/70 border-border/70 rounded-full bg-surface-subtle shadow-sm group-hover:scale-105 transition-transform">
<div className="h-[42px] w-[42px] shrink-0 flex items-center justify-center text-foreground border border-border/70 border-border/70 rounded-full bg-surface-subtle shadow-sm">
{getProviderIconUrl(account.vendorId) ? (
<img src={getProviderIconUrl(account.vendorId)} alt={typeInfo?.name || account.vendorId} className="h-5 w-5" />
) : (
@@ -860,7 +860,7 @@ function ProviderCard({
className="flex items-center justify-between w-full text-sm font-medium text-foreground/80 hover:text-foreground transition-colors"
>
<span>{t('aiProviders.sections.fallback')}</span>
<ChevronDown className={cn("h-4 w-4 transition-transform duration-200 ease-out", showFallback && "rotate-180")} />
<ChevronDown className={cn("h-4 w-4", showFallback && "rotate-180")} />
</button>
<DisclosureContent open={showFallback} className="mt-2" innerClassName="space-y-3 pt-2">
<div className="space-y-1.5">
@@ -871,7 +871,7 @@ function ProviderCard({
placeholder={t('aiProviders.dialog.fallbackModelIdsPlaceholder')}
className={isDefault
? "min-h-24 w-full rounded-xl border border-border/70 bg-background px-3 py-2 text-meta font-mono outline-none focus-visible:ring-2 focus-visible:ring-brand/35 shadow-sm"
: "min-h-24 w-full rounded-xl border border-border/70 bg-surface-input px-3 py-2 text-meta font-mono outline-none focus-visible:ring-2 focus-visible:ring-brand/35 focus-visible:border-brand shadow-sm transition-all text-foreground placeholder:text-foreground/40"}
: "min-h-24 w-full rounded-xl border border-border/70 bg-surface-input px-3 py-2 text-meta font-mono outline-none focus-visible:ring-2 focus-visible:ring-brand/35 focus-visible:border-brand shadow-sm transition-colors duration-100 text-foreground placeholder:text-foreground/40"}
/>
<p className="text-xs text-muted-foreground">
{t('aiProviders.dialog.fallbackModelIdsHelp')}
@@ -1381,7 +1381,7 @@ function AddProviderDialog({
}}
className="p-4 rounded-2xl border border-border/70 hover:bg-surface-subtle transition-colors text-center group"
>
<div className="h-12 w-12 mx-auto mb-3 flex items-center justify-center bg-surface-subtle rounded-xl shadow-sm border border-border/70 group-hover:scale-105 transition-transform">
<div className="h-12 w-12 mx-auto mb-3 flex items-center justify-center bg-surface-subtle rounded-xl shadow-sm border border-border/70">
{getProviderIconUrl(type.id) ? (
<img src={getProviderIconUrl(type.id)} alt={type.name} className="h-6 w-6" />
) : (
@@ -1637,7 +1637,7 @@ function AddProviderDialog({
className="flex items-center justify-between w-full text-sm font-medium text-foreground/80 hover:text-foreground transition-colors"
>
<span>{t('aiProviders.dialog.advancedConfig')}</span>
<ChevronDown className={cn("h-4 w-4 transition-transform duration-200 ease-out", showAdvancedConfig && "rotate-180")} />
<ChevronDown className={cn("h-4 w-4", showAdvancedConfig && "rotate-180")} />
</button>
<DisclosureContent open={showAdvancedConfig} className="mt-1" innerClassName="space-y-2.5 pt-1">
<Label htmlFor="userAgent" className={labelClasses}>{t('aiProviders.dialog.userAgent')}</Label>