perf(bind): speed up account bind detection and runtime sync

Replace the 1.8s polling interval with a 650ms tick plus a debounced
navigation-driven detect, listen for page-title-updated to catch SPA
transitions, and flush the session asynchronously. The bind handler
now optimistically seeds the runtime account list via
noteRuntimeAccountBound and fires the full server refresh in the
background, so the UI reflects the new binding without waiting on a
round-trip.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-26 21:57:26 +08:00
parent 0ce3f51f62
commit 53bebb46be
4 changed files with 72 additions and 30 deletions
@@ -17,7 +17,7 @@ import type { RuntimeAccount } from "../types";
type AccountRow = Readonly<Omit<RuntimeAccount, "tags">> & { tags: readonly string[] };
const { snapshot, refreshAccounts, loading } = useDesktopRuntime();
const { snapshot, refresh, refreshAccounts, loading } = useDesktopRuntime();
const bindPendingPlatformId = ref<string | null>(null);
const openPendingAccountId = ref<string | null>(null);
@@ -156,7 +156,7 @@ async function bindPlatform(platformId: string) {
const account = await window.desktopBridge.app.bindPublishAccount(platformId);
const platformLabel = desktopMonitoringMediaCatalog.find((item) => item.id === platformId)?.label ?? platformId;
showActionNotification("success", "绑定成功", `${account.display_name} 已绑定到 ${platformLabel}`);
await refreshAccounts();
await refresh();
} catch (error) {
showClientActionError("bind-account", error);
} finally {