refactor: 管理员租户切换不再返回首页 直接刷新当前页(除特殊页面外会回到首页)
This commit is contained in:
parent
b67be83a19
commit
362bc84cfb
@ -5,6 +5,7 @@
|
|||||||
- 文件上传/图片上传重构(破坏性更新 不兼容之前的api)
|
- 文件上传/图片上传重构(破坏性更新 不兼容之前的api)
|
||||||
- 文件上传/图片上传**不再支持**url用法 强制使用ossId
|
- 文件上传/图片上传**不再支持**url用法 强制使用ossId
|
||||||
- TableSwitch组件重构
|
- TableSwitch组件重构
|
||||||
|
- 管理员租户切换不再返回首页 直接刷新当前页(除特殊页面外会回到首页)
|
||||||
|
|
||||||
**BUG FIX**
|
**BUG FIX**
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { MessageType } from 'ant-design-vue/es/message';
|
||||||
import type { SelectHandler } from 'ant-design-vue/es/vc-select/Select';
|
import type { SelectHandler } from 'ant-design-vue/es/vc-select/Select';
|
||||||
|
|
||||||
import type { TenantOption } from '#/api';
|
import type { TenantOption } from '#/api';
|
||||||
|
|
||||||
import { computed, onMounted, ref, unref } from 'vue';
|
import { computed, onMounted, ref, shallowRef, unref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
import { useAccess } from '@vben/access';
|
import { useAccess } from '@vben/access';
|
||||||
import { DEFAULT_HOME_PATH } from '@vben/constants';
|
|
||||||
import { useTabs } from '@vben/hooks';
|
import { useTabs } from '@vben/hooks';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
@ -41,15 +41,26 @@ onMounted(async () => {
|
|||||||
await initTenant();
|
await initTenant();
|
||||||
});
|
});
|
||||||
|
|
||||||
const { closeAllTabs } = useTabs();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
|
||||||
function close(checked: boolean) {
|
const messageInstance = shallowRef<MessageType | null>();
|
||||||
|
|
||||||
|
const { closeOtherTabs, refreshTab, closeAllTabs } = useTabs();
|
||||||
|
async function close(checked: boolean) {
|
||||||
// store设置状态
|
// store设置状态
|
||||||
setChecked(checked);
|
setChecked(checked);
|
||||||
// 需要关闭全部标签页
|
|
||||||
closeAllTabs();
|
/**
|
||||||
// 切换完加载首页
|
* 切换租户需要回到首页的页面 一般为带id的页面
|
||||||
router.push(DEFAULT_HOME_PATH);
|
* 其他则直接刷新页面
|
||||||
|
*/
|
||||||
|
if (route.meta.requireHomeRedirect) {
|
||||||
|
await closeAllTabs();
|
||||||
|
} else {
|
||||||
|
// 先关闭再刷新 这里不用Promise.all()
|
||||||
|
await closeOtherTabs();
|
||||||
|
await refreshTab();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const dictStore = useDictStore();
|
const dictStore = useDictStore();
|
||||||
@ -65,9 +76,13 @@ const onSelected: SelectHandler = async (tenantId: string, option: any) => {
|
|||||||
}
|
}
|
||||||
await tenantDynamicToggle(tenantId);
|
await tenantDynamicToggle(tenantId);
|
||||||
lastSelected.value = tenantId;
|
lastSelected.value = tenantId;
|
||||||
message.success(
|
|
||||||
|
// 关闭之前的message 只保留一条
|
||||||
|
messageInstance.value?.();
|
||||||
|
messageInstance.value = message.success(
|
||||||
`${$t('component.tenantToggle.switch')} ${option.companyName}`,
|
`${$t('component.tenantToggle.switch')} ${option.companyName}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
close(true);
|
close(true);
|
||||||
// 需要放在宏队列处理 直接清空页面由于没有字典会有样式问题(标签变成unknown)
|
// 需要放在宏队列处理 直接清空页面由于没有字典会有样式问题(标签变成unknown)
|
||||||
setTimeout(() => dictStore.resetCache());
|
setTimeout(() => dictStore.resetCache());
|
||||||
@ -75,7 +90,11 @@ const onSelected: SelectHandler = async (tenantId: string, option: any) => {
|
|||||||
|
|
||||||
async function onDeselect() {
|
async function onDeselect() {
|
||||||
await tenantDynamicClear();
|
await tenantDynamicClear();
|
||||||
message.success($t('component.tenantToggle.reset'));
|
|
||||||
|
// 关闭之前的message 只保留一条
|
||||||
|
messageInstance.value?.();
|
||||||
|
messageInstance.value = message.success($t('component.tenantToggle.reset'));
|
||||||
|
|
||||||
lastSelected.value = '';
|
lastSelected.value = '';
|
||||||
close(false);
|
close(false);
|
||||||
// 需要放在宏队列处理 直接清空页面由于没有字典会有样式问题(标签变成unknown)
|
// 需要放在宏队列处理 直接清空页面由于没有字典会有样式问题(标签变成unknown)
|
||||||
|
@ -12,6 +12,7 @@ const localRoutes: RouteRecordStringComponent[] = [
|
|||||||
icon: 'mingcute:profile-line',
|
icon: 'mingcute:profile-line',
|
||||||
title: $t('ui.widgets.profile'),
|
title: $t('ui.widgets.profile'),
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
|
requireHomeRedirect: true,
|
||||||
},
|
},
|
||||||
name: 'Profile',
|
name: 'Profile',
|
||||||
path: '/profile',
|
path: '/profile',
|
||||||
@ -23,6 +24,7 @@ const localRoutes: RouteRecordStringComponent[] = [
|
|||||||
icon: 'ant-design:setting-outlined',
|
icon: 'ant-design:setting-outlined',
|
||||||
title: 'oss配置',
|
title: 'oss配置',
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
|
requireHomeRedirect: true,
|
||||||
},
|
},
|
||||||
name: 'OssConfig',
|
name: 'OssConfig',
|
||||||
path: '/system/oss-config',
|
path: '/system/oss-config',
|
||||||
@ -34,6 +36,7 @@ const localRoutes: RouteRecordStringComponent[] = [
|
|||||||
icon: 'tabler:code',
|
icon: 'tabler:code',
|
||||||
title: '生成配置',
|
title: '生成配置',
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
|
requireHomeRedirect: true,
|
||||||
},
|
},
|
||||||
name: 'GenConfig',
|
name: 'GenConfig',
|
||||||
path: '/code-gen/edit/:tableId',
|
path: '/code-gen/edit/:tableId',
|
||||||
@ -45,6 +48,7 @@ const localRoutes: RouteRecordStringComponent[] = [
|
|||||||
icon: 'eos-icons:role-binding-outlined',
|
icon: 'eos-icons:role-binding-outlined',
|
||||||
title: '分配角色',
|
title: '分配角色',
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
|
requireHomeRedirect: true,
|
||||||
},
|
},
|
||||||
name: 'RoleAssign',
|
name: 'RoleAssign',
|
||||||
path: '/system/role-assign/:roleId',
|
path: '/system/role-assign/:roleId',
|
||||||
@ -56,6 +60,7 @@ const localRoutes: RouteRecordStringComponent[] = [
|
|||||||
icon: 'fluent-mdl2:flow',
|
icon: 'fluent-mdl2:flow',
|
||||||
title: '流程设计',
|
title: '流程设计',
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
|
requireHomeRedirect: true,
|
||||||
},
|
},
|
||||||
name: 'WorkflowDesigner',
|
name: 'WorkflowDesigner',
|
||||||
path: '/workflow/designer',
|
path: '/workflow/designer',
|
||||||
@ -70,6 +75,7 @@ const localRoutes: RouteRecordStringComponent[] = [
|
|||||||
title: '请假申请',
|
title: '请假申请',
|
||||||
activePath: '/demo/leave',
|
activePath: '/demo/leave',
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
|
requireHomeRedirect: true,
|
||||||
},
|
},
|
||||||
name: 'WorkflowLeaveIndex',
|
name: 'WorkflowLeaveIndex',
|
||||||
path: '/workflow/leaveEdit/index',
|
path: '/workflow/leaveEdit/index',
|
||||||
|
@ -113,6 +113,12 @@ interface RouteMeta {
|
|||||||
* 菜单所携带的参数
|
* 菜单所携带的参数
|
||||||
*/
|
*/
|
||||||
query?: Recordable;
|
query?: Recordable;
|
||||||
|
/**
|
||||||
|
* 管理员切换租户 该页面是否需要重定向到首页
|
||||||
|
* 用于区分带路由参数的页面 比如/oss/:id 这种路由是需要回到首页的
|
||||||
|
* 默认false
|
||||||
|
*/
|
||||||
|
requireHomeRedirect?: boolean;
|
||||||
/**
|
/**
|
||||||
* 标题名称
|
* 标题名称
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user