增加租户切换功能

This commit is contained in:
hero920103 committed 2026-09-29 15:38:00 +08:00
1 parent 1685b22e1e
commit 0dc5c2f075
8 files changed
+305 -60

No files matched your search

+4 -2
View File
@@ -60,8 +60,10 @@ async function finish() {
try {
await handleAuthorizeCallback(query);
await saveUserInfo();
// 登录成功:清掉 URL 上的 code/state,进入首页
window.location.href = "#/home";
// 登录成功:用 replaceState 改写 hash(不触发路由跳转),再整页重载。
// 若先 window.location.href = '#/home' 再 reload,会在「旧会话状态」下先渲染一次
// 首页并发出请求(部分请求会带登录前的旧令牌 → 401),重载后才恢复。
window.history.replaceState({}, document.title, `${window.location.pathname}#/home`);
window.location.reload();
} catch (e) {
error.value = e?.message || "登录失败";
+11 -30
View File
@@ -3,12 +3,8 @@
<div class="home-top">
<div class="toolbar">
<div class="toolbar-left">
<template v-if="tenantName">
<span class="tenant-name" :title="tenantName">
<el-icon class="tenant-icon"><OfficeBuilding /></el-icon>
{{ tenantName }}
</span>
</template>
<!-- 当前企业 + 一人多企业时可点击切换 -->
<TenantSwitcher variant="plain" />
</div>
<div class="toolbar-right">
<el-tooltip content="刷新菜单" placement="bottom">
@@ -225,7 +221,6 @@ import {
RefreshRight,
Sunny,
Moon,
OfficeBuilding,
Lock,
} from "@element-plus/icons-vue";
@@ -235,6 +230,7 @@ import { getCurrentUserProfile, logout } from "@/api/login";
import { reloadMenusAndDynamicRoutes } from "@/router";
import { useAuthStore } from "@/stores/auth";
import { useMenuStore } from "@/stores/menu";
import TenantSwitcher from "@/components/TenantSwitcher.vue";
interface ModuleItem {
id: number;
@@ -527,22 +523,9 @@ onMounted(() => {
display: flex;
align-items: center;
.tenant-name {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 15px;
font-weight: 500;
color: @text-regular;
max-width: 220px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.tenant-icon {
font-size: 16px;
color: #3973ff;
}
// 企业切换(TenantSwitcher 组件):样式由组件自带,这里只调楼宇图标颜色
:deep(.tenant-chip .tenant-chip-icon) {
color: #3973ff;
}
}
@@ -1119,7 +1102,8 @@ onMounted(() => {
}
.toolbar-left {
.tenant-name {
// 超窄屏隐藏企业名,避免挤压右侧按钮
:deep(.tenant-chip) {
display: none;
}
}
@@ -1172,12 +1156,9 @@ onMounted(() => {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
.toolbar {
.toolbar-left .tenant-name {
color: #cfd3dc;
.tenant-icon {
color: #5a8dff;
}
// 暗色下企业名文字颜色由组件内的主题变量自适应,这里只覆盖图标色
.toolbar-left :deep(.tenant-chip .tenant-chip-icon) {
color: #5a8dff;
}
.toolbar-right {