perf(dashboard): 加载统计去掉对整个返回值的 JSON.stringify(数 MB 大对象在 webview 主线程序列化造成卡顿),loadStats 仅保留耗时 ms,中英文案同步

This commit is contained in:
KimiSwitch Dev committed 2026-10-07 23:35:30 +08:00
1 parent d190a55bf2
commit 9f51ea5e84
4 files changed
+5 -8

No files matched your search

+1 -1
View File
@@ -179,7 +179,7 @@ export function DashboardPage() {
</div> </div>
{loadStats && !loading && ( {loadStats && !loading && (
<span className="hidden text-[10px] text-content-muted sm:inline"> <span className="hidden text-[10px] text-content-muted sm:inline">
{t("loadStats", { ms: loadStats.ms, kb: loadStats.kb })} {t("loadStats", { ms: loadStats.ms })}
</span> </span>
)} )}
</div> </div>
+2 -5
View File
@@ -23,7 +23,7 @@ export function useDashboard() {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
/** Round-trip timing for the last get_summary call (user-perceived lag). */ /** Round-trip timing for the last get_summary call (user-perceived lag). */
const [loadStats, setLoadStats] = useState<{ ms: number; kb: number } | null>(null); const [loadStats, setLoadStats] = useState<{ ms: number } | null>(null);
const refresh = useCallback(async (force = false) => { const refresh = useCallback(async (force = false) => {
setLoading(true); setLoading(true);
@@ -35,10 +35,7 @@ export function useDashboard() {
refresh: force, refresh: force,
}); });
setData(result); setData(result);
setLoadStats({ setLoadStats({ ms: Math.round(performance.now() - start) });
ms: Math.round(performance.now() - start),
kb: Math.round(JSON.stringify(result).length / 1024),
});
} catch (err) { } catch (err) {
const msg = err instanceof Error ? err.message : String(err); const msg = err instanceof Error ? err.message : String(err);
setError(msg); setError(msg);
+1 -1
View File
@@ -257,7 +257,7 @@ export const enTranslations: Record<TranslationKey, string> = {
scanning: "Scanning…", scanning: "Scanning…",
refresh: "Refresh", refresh: "Refresh",
refreshing: "Refreshing…", refreshing: "Refreshing…",
loadStats: "Loaded in {ms} ms · {kb} KB payload", loadStats: "Loaded in {ms} ms",
refreshed: "Refreshed", refreshed: "Refreshed",
cancel: "Cancel", cancel: "Cancel",
confirmDeleteTitle: "Delete session forever?", confirmDeleteTitle: "Delete session forever?",
+1 -1
View File
@@ -249,7 +249,7 @@ export const zhTranslations = {
scanning: "扫描中…", scanning: "扫描中…",
refresh: "刷新", refresh: "刷新",
refreshing: "刷新中…", refreshing: "刷新中…",
loadStats: "加载 {ms} ms · 数据 {kb} KB", loadStats: "加载 {ms} ms",
refreshed: "已刷新", refreshed: "已刷新",
cancel: "取消", cancel: "取消",
confirmDeleteTitle: "永久删除会话?", confirmDeleteTitle: "永久删除会话?",