perf(dashboard): 仪表盘加载提速

- models-dev 快照移出主 bundle(1.35MB→515KB),改为 /models-dev.json 运行时异步加载,就绪后重渲染
- Rust 启动时后台预热价格索引(warm_price_index),首次 get_summary 不再卡
- get_summary 扫描结果 8s TTL 缓存(按 home),切 tab/改范围复用;刷新按钮 refresh=true 强制重扫
This commit is contained in:
KimiSwitch Dev committed 2026-08-01 19:37:20 +08:00
1 parent 9fd22ef55a
commit 1fecb161a9
7 files changed
+64112 -23

No files matched your search

+10 -2
View File
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useMemo, useState } from "react";
import { useCallback, useEffect, useMemo, useReducer, useState } from "react";
import { invoke } from "@tauri-apps/api/core";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { useConfig } from "./hooks/useConfig";
@@ -12,7 +12,7 @@ import { UsageConfigModal } from "./components/UsageConfigModal";
import { PresetPickerModal } from "./components/PresetPickerModal";
import { useTranslation } from "./i18n";
import { getDefaultMaxContextSize } from "./lib/model-defaults";
import { getModelRef } from "./lib/models-dev";
import { getModelRef, modelsDevReady, onModelsDevReady } from "./lib/models-dev";
import {
presetToProviderAndModels,
type ProviderPreset,
@@ -121,6 +121,14 @@ export default function App() {
}).catch(() => {});
}, [loading, config, agent]);
// Load the models.dev index in the background (not in the main bundle)
// and re-render once it lands so context/capability columns fill in.
const [, forceModelsDevReady] = useReducer((x: number) => x + 1, 0);
useEffect(() => {
onModelsDevReady(forceModelsDevReady);
void modelsDevReady();
}, []);
const providers = useMemo(
() => (config ? Object.values(config.providers) : []),
[config]