mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-06 01:17:46 +08:00
perf(frontend): 收敛导航预取并去重首屏请求
- 导航预取仅保留 pointerdown 触发,移除 mouseenter/focus,避免鼠标划过误触发 - 后台预取只做组件懒加载,不再预取各页业务数据,减少首屏资源争抢 - 版本状态检查增加 sessionStorage 缓存(正常 20 分钟 / 错误 5 分钟 TTL) - fetchModules、必读公告拉取增加请求去重,避免并发重复请求 - 更新检查改用可清理的定时器,组件卸载时清理 - UsageRecordsTable 搜索防抖改为自定义实现,卸载时取消挂起 emit 并补充测试
This commit is contained in:
@@ -1,95 +1,30 @@
|
||||
import { adminWalletApi } from '@/api/admin-wallets'
|
||||
import { adminApi } from '@/api/admin'
|
||||
import { adminBillingPlansApi, epayGatewayApi } from '@/api/billing'
|
||||
import { getProvidersSummary } from '@/api/endpoints/providers'
|
||||
import { getPoolOverview, getPoolSchedulingPresets, listPoolKeys } from '@/api/endpoints/pool'
|
||||
import { listGlobalModels } from '@/api/global-models'
|
||||
import { listRoutingGroups } from '@/api/routing-profiles'
|
||||
import { usersApi } from '@/api/users'
|
||||
import { log } from '@/utils/logger'
|
||||
|
||||
const NAV_DATA_CACHE_TTL_MS = 10 * 1000
|
||||
const NAV_SYSTEM_CONFIG_CACHE_TTL_MS = 30 * 1000
|
||||
const NAV_POOL_PRESETS_CACHE_TTL_MS = 5 * 60 * 1000
|
||||
const PREFETCH_COOLDOWN_MS = 5 * 1000
|
||||
|
||||
const lastPrefetchAt = new Map<string, number>()
|
||||
|
||||
const adminRouteWarmers: Record<string, () => Promise<void>> = {
|
||||
'/admin/users': async () => {
|
||||
await Promise.allSettled([
|
||||
import('@/views/admin/Users.vue'),
|
||||
usersApi.getAllUsers({ cacheTtlMs: NAV_DATA_CACHE_TTL_MS }),
|
||||
adminWalletApi.listAllWallets(
|
||||
{ owner_type: 'user' },
|
||||
{ cacheTtlMs: NAV_DATA_CACHE_TTL_MS },
|
||||
),
|
||||
])
|
||||
await import('@/views/admin/Users.vue')
|
||||
},
|
||||
'/admin/providers': async () => {
|
||||
await Promise.allSettled([
|
||||
import('@/views/admin/ProviderManagement.vue'),
|
||||
getProvidersSummary(
|
||||
{ page: 1, page_size: 20 },
|
||||
{ cacheTtlMs: NAV_DATA_CACHE_TTL_MS },
|
||||
),
|
||||
adminApi.getSystemConfig('provider_priority_mode', {
|
||||
cacheTtlMs: NAV_SYSTEM_CONFIG_CACHE_TTL_MS,
|
||||
}),
|
||||
listGlobalModels(
|
||||
{ is_active: true, limit: 1000 },
|
||||
{ cacheTtlMs: NAV_DATA_CACHE_TTL_MS },
|
||||
),
|
||||
])
|
||||
await import('@/views/admin/ProviderManagement.vue')
|
||||
},
|
||||
'/admin/models': async () => {
|
||||
await Promise.allSettled([
|
||||
import('@/views/admin/ModelManagement.vue'),
|
||||
listGlobalModels(
|
||||
{ skip: 0, limit: 20 },
|
||||
{ cacheTtlMs: NAV_DATA_CACHE_TTL_MS },
|
||||
),
|
||||
])
|
||||
await import('@/views/admin/ModelManagement.vue')
|
||||
},
|
||||
'/admin/routing': async () => {
|
||||
await Promise.allSettled([
|
||||
import('@/views/admin/RoutingProfiles.vue'),
|
||||
listRoutingGroups(),
|
||||
])
|
||||
await import('@/views/admin/RoutingProfiles.vue')
|
||||
},
|
||||
'/admin/pool': async () => {
|
||||
const [overviewResult] = await Promise.allSettled([
|
||||
getPoolOverview({ cacheTtlMs: NAV_DATA_CACHE_TTL_MS }),
|
||||
getPoolSchedulingPresets({ cacheTtlMs: NAV_POOL_PRESETS_CACHE_TTL_MS }),
|
||||
import('@/views/admin/PoolManagement.vue'),
|
||||
])
|
||||
|
||||
if (overviewResult.status !== 'fulfilled') {
|
||||
return
|
||||
}
|
||||
|
||||
const firstProviderId = overviewResult.value.items.find(item => item.pool_enabled)?.provider_id
|
||||
if (!firstProviderId) {
|
||||
return
|
||||
}
|
||||
|
||||
await listPoolKeys(
|
||||
firstProviderId,
|
||||
{ page: 1, page_size: 50, status: 'all' },
|
||||
{ cacheTtlMs: NAV_DATA_CACHE_TTL_MS },
|
||||
)
|
||||
await import('@/views/admin/PoolManagement.vue')
|
||||
},
|
||||
'/admin/payment-gateways': async () => {
|
||||
await Promise.allSettled([
|
||||
import('@/views/admin/PaymentGatewaySettings.vue'),
|
||||
epayGatewayApi.get(),
|
||||
])
|
||||
await import('@/views/admin/PaymentGatewaySettings.vue')
|
||||
},
|
||||
'/admin/billing-plans': async () => {
|
||||
await Promise.allSettled([
|
||||
import('@/views/admin/BillingPlansManagement.vue'),
|
||||
adminBillingPlansApi.list(),
|
||||
])
|
||||
await import('@/views/admin/BillingPlansManagement.vue')
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user