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
+19 -2
View File
@@ -2,11 +2,12 @@
import { computed, nextTick, onMounted, onUnmounted, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { MessagePlugin } from 'tdesign-vue-next'
import { MessagePlugin, NotifyPlugin } from 'tdesign-vue-next'
import ManualKnowledgeEditor from '@/components/manual-knowledge-editor.vue'
import { useAuthStore } from '@/stores/auth'
import { useSettingsStore } from '@/stores/settings'
import { getCurrentUser } from '@/api/auth'
import { consumePendingTenantSwitchToast } from '@/utils/tenantSwitch'
// TDesign locale configs
import enUSConfig from 'tdesign-vue-next/esm/locale/en_US'
@@ -14,7 +15,7 @@ import zhCNConfig from 'tdesign-vue-next/esm/locale/zh_CN'
import koKRConfig from 'tdesign-vue-next/esm/locale/ko_KR'
import ruRUConfig from 'tdesign-vue-next/esm/locale/ru_RU'
const { locale } = useI18n()
const { locale, t } = useI18n()
const router = useRouter()
const authStore = useAuthStore()
const settingsStore = useSettingsStore()
@@ -183,8 +184,24 @@ watch(
{ immediate: true },
)
// 切换租户后会 hard reload;切换前 stash 的 toast 这里 consume 并弹出,
// 这样 toast 显示在新页面上,duration 才真正生效。
const showPendingTenantSwitchToast = () => {
const pending = consumePendingTenantSwitchToast()
if (!pending) return
NotifyPlugin.success({
title: t('tenant.switchSuccessTitle'),
content: pending.role
? t('tenant.switchSuccessContentWithRole', { name: pending.name, role: pending.role })
: t('tenant.switchSuccessContent', { name: pending.name }),
duration: 6000,
closeBtn: true,
})
}
onMounted(() => {
handleGlobalOIDCCallback()
showPendingTenantSwitchToast()
// Auto check for updates on startup
setTimeout(() => {