fix backup import preview and refresh race (#167)

This commit is contained in:
Cita
2026-03-19 17:14:07 +08:00
committed by GitHub
parent 24483c28eb
commit 36e9a85664
6 changed files with 210 additions and 7 deletions
+18
View File
@@ -75,8 +75,26 @@ function parseImportSummary(raw: string): ParsedSummary | null {
const legacyPrefs = Boolean(data.data?.preferences);
const profilesCount = Array.isArray(data.apiCredentialProfiles?.profiles) ? data.apiCredentialProfiles.profiles.length : 0;
const bookmarksCount = Array.isArray(accountsSection?.bookmarks) ? accountsSection.bookmarks.length : 0;
const isNativeMetapiBackup = Boolean(
accountsSection
&& Array.isArray(accountsSection.sites)
&& Array.isArray(accountsSection.accountTokens)
&& Array.isArray(accountsSection.tokenRoutes)
&& Array.isArray(accountsSection.routeChannels)
);
const hasLegacyAccountRows = Array.isArray(accountsSection?.accounts)
&& accountsSection.accounts.some((row: any) => row && typeof row === 'object' && !Array.isArray(row) && (
'site_url' in row
|| 'site_type' in row
|| 'account_info' in row
|| 'cookieAuth' in row
|| 'authType' in row
|| 'sub2apiAuth' in row
));
const isAllApiHubV2 = Boolean(
accountsSection
&& !isNativeMetapiBackup
&& hasLegacyAccountRows
&& Array.isArray(accountsSection.accounts)
&& (
(typeof data.version === 'string' && data.version.startsWith('2'))