fix tenant account unbind flow
Desktop Client Build / Resolve Build Metadata (push) Successful in 28s
Frontend CI / Frontend (push) Successful in 2m53s
Backend CI / Backend (push) Successful in 16m10s
Desktop Client Build / Build Desktop Client (push) Successful in 23m44s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 50s

This commit is contained in:
2026-06-19 09:29:04 +08:00
parent 0cddb47055
commit 97ae601cfd
20 changed files with 561 additions and 15 deletions
@@ -1213,6 +1213,8 @@ async function syncAccounts(source: 'startup' | 'manual' | 'timer'): Promise<voi
state.lastAccountsSyncAt = Date.now()
state.lastError = null
await cleanupRemovedRuntimeAccounts(accounts)
noteSchedulerAccountsSync()
setSchedulerError(null)
@@ -1326,6 +1328,35 @@ async function syncAccounts(source: 'startup' | 'manual' | 'timer'): Promise<voi
}
}
async function cleanupRemovedRuntimeAccounts(accounts: DesktopAccountInfo[]): Promise<void> {
const nextAccountIds = new Set(accounts.map((account) => account.id))
const removedAccounts = state.accounts.filter((account) => !nextAccountIds.has(account.id))
if (removedAccounts.length === 0) {
return
}
for (const account of removedAccounts) {
try {
await clearSessionHandle(account.id)
forgetTrackedAccountHealth(account.id)
state.accountProfiles.delete(account.id)
recordActivity(
'info',
'账号已完成解绑',
`${account.display_name} 已从服务端解除绑定,本机本地会话缓存已清理。`,
)
} catch (error) {
console.warn('[desktop-runtime] removed desktop account cleanup failed', {
accountId: account.id,
platform: account.platform,
platformUid: account.platform_uid,
message: errorMessage(error),
})
recordActivity('warn', '账号本地清理失败', `${account.display_name}${errorMessage(error)}`)
}
}
}
async function consumeDeleteRequestedAccounts(
accounts: DesktopAccountInfo[],
): Promise<DesktopAccountInfo[]> {