feat(tenant): show rich workspace-switch confirmation that survives reload

Replace the lightweight "switch success" message with a richer
NotifyPlugin notification that reports the new workspace name and the
user's role in it. Because the post-switch flow does a hard reload,
the notification is stashed in sessionStorage before navigation and
consumed by App.vue on the next mount, so the toast actually appears
on the destination page with its full 6s duration instead of being
torn down a frame after it is shown.

For the cross-tenant superuser path (TenantSelector), the role line is
omitted when the user has no membership row in the target tenant,
avoiding a misleading empty/raw role value. Role labels are formatted
through the shared useRoleLabel composable so any future role text
change still lives in one place.

i18n keys updated across zh-CN, en-US, ko-KR, ru-RU.
This commit is contained in:
wizardchen
2026-05-18 19:34:06 +08:00
committed by lyingbug
parent c19d3543c8
commit 0655b545be
8 changed files with 83 additions and 10 deletions
+6 -2
View File
@@ -236,7 +236,7 @@ import { useI18n } from 'vue-i18n'
import IMChannelsOverviewPanel from '@/components/IMChannelsOverviewPanel.vue'
import CreateTenantDialog from '@/components/CreateTenantDialog.vue'
import { listAllIMChannels, type IMChannelOverview } from '@/api/agent'
import { navigateAfterTenantSwitch } from '@/utils/tenantSwitch'
import { navigateAfterTenantSwitch, stashTenantSwitchToast } from '@/utils/tenantSwitch'
import type { TenantInfo } from '@/api/tenant'
import { useRoleLabel, useHomeTenant } from '@/composables/useRoleLabel'
@@ -446,7 +446,11 @@ const switchToTenant = (m: Membership) => {
authStore.setSelectedTenant(m.tenant_id, tenantDisplayName(m))
}
closeAll()
MessagePlugin.success(t('tenant.switchSuccess'))
// Toast 在 reload 后由 App.vue 弹出(直接在这里弹会被 hard reload 干掉)。
stashTenantSwitchToast({
name: tenantDisplayName(m),
role: formatRole(m.role) || undefined,
})
// Hard reload so every cached store / open SSE stream / in-flight
// request gets re-keyed under the new tenant. If the current path
// embeds a tenant-scoped resource id, reload would white-screen the