diff --git a/ecom-dmb-frontend/apps/web-antd/src/components/SwitchAccountModal.vue b/ecom-dmb-frontend/apps/web-antd/src/components/SwitchAccountModal.vue index 32333a1b..47fd4b38 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/components/SwitchAccountModal.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/components/SwitchAccountModal.vue @@ -4,8 +4,11 @@ import type { UserVO } from '#/api/system/user/types'; import type { PageQueryDTO } from '#/types/common'; import { computed, ref, watch } from 'vue'; +import { useRouter } from 'vue-router'; import { useVbenModal } from '@vben/common-ui'; +import { useTabs } from '@vben/hooks'; +import { preferences } from '@vben/preferences'; import { useAccessStore } from '@vben/stores'; import { Avatar, Card, Form, message, Select, Spin } from 'ant-design-vue'; @@ -39,6 +42,8 @@ const userHasMore = ref(true); // 选中的用户信息 const selectedUser = ref(null); +const { closeAllTabs } = useTabs(); +const router = useRouter(); // 公司选项 const companyOptions = computed(() => @@ -230,6 +235,10 @@ const handleSwitchAccount = async () => { // 重置权限检查状态,让路由守卫重新生成菜单和路由 accessStore.setIsAccessChecked(false); + // 清空当前标签页,避免不同公司下携带旧参数(如店铺ID)的页面残留 + await closeAllTabs(); + await router.replace(preferences.app.defaultHomePath); + message.success('切换账户成功'); modalApi.close();