mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 01:09:19 +08:00
feat(auth): 超管切换账户迁至 SuperAuthController,新增多公司切换与 companyCount 并收紧 auth 白名单
This commit is contained in:
@@ -18,6 +18,7 @@ import { useAccessStore, useUserStore } from '@vben/stores';
|
||||
|
||||
import ImportTaskButton from '#/components/ImportTaskButton.vue';
|
||||
import SwitchAccountModal from '#/components/SwitchAccountModal.vue';
|
||||
import SwitchCompanyModal from '#/components/SwitchCompanyModal.vue';
|
||||
import { useAuthStore, useImportTaskStore } from '#/store';
|
||||
import LoginForm from '#/views/_core/authentication/login.vue';
|
||||
|
||||
@@ -70,7 +71,10 @@ onMounted(() => {
|
||||
|
||||
// 切换账户模态框引用
|
||||
const switchAccountModalRef = ref();
|
||||
const switchCompanyModalRef = ref();
|
||||
|
||||
// 切换公司图标
|
||||
const SwitchCompanyIcon = createIconifyIcon('lucide:building-2');
|
||||
// 切换账户图标
|
||||
const SwitchAccountIcon = createIconifyIcon('lucide:arrow-left-right');
|
||||
// 用户图标
|
||||
@@ -78,6 +82,12 @@ const UserIcon = createIconifyIcon('lucide:user');
|
||||
// 锁图标
|
||||
const LockIcon = createIconifyIcon('lucide:lock');
|
||||
|
||||
/** 当前用户可切换的可用公司数 */
|
||||
const companyCount = computed(() => {
|
||||
const info = userStore.userInfo as null | { companyCount?: number };
|
||||
return info?.companyCount ?? 0;
|
||||
});
|
||||
|
||||
const menus = computed(() => {
|
||||
const menuItems = [];
|
||||
|
||||
@@ -98,6 +108,17 @@ const menus = computed(() => {
|
||||
text: '修改密码',
|
||||
});
|
||||
|
||||
// 可切换公司数大于 1 时显示切换公司
|
||||
if (companyCount.value > 1) {
|
||||
menuItems.push({
|
||||
handler: () => {
|
||||
switchCompanyModalRef.value?.open();
|
||||
},
|
||||
icon: SwitchCompanyIcon,
|
||||
text: '切换公司',
|
||||
});
|
||||
}
|
||||
|
||||
// 只有超级管理员才显示切换账户功能
|
||||
if (accessStore.userRole === 'super') {
|
||||
menuItems.push({
|
||||
@@ -197,6 +218,8 @@ watch(
|
||||
</template>
|
||||
</BasicLayout>
|
||||
|
||||
<!-- 切换公司模态框 -->
|
||||
<SwitchCompanyModal ref="switchCompanyModalRef" />
|
||||
<!-- 切换账户模态框 -->
|
||||
<SwitchAccountModal ref="switchAccountModalRef" />
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user