Browse Source

主页面中的租户

hella_online_20240829
wangyufei 5 months ago
parent
commit
5a32098cb8
  1. 10
      src/layout/components/UserInfo/src/UserInfo.vue
  2. 14
      src/store/modules/permission.ts

10
src/layout/components/UserInfo/src/UserInfo.vue

@ -6,6 +6,7 @@ import { useDesign } from '@/hooks/web/useDesign'
import avatarImg from '@/assets/imgs/avatar.gif'
import { useUserStore } from '@/store/modules/user'
import { useTagsViewStore } from '@/store/modules/tagsView'
import { getTenantId } from '@/utils/auth'
defineOptions({ name: 'UserInfo' })
@ -28,6 +29,8 @@ const user = wsCache.get(CACHE_KEY.USER)
const avatar = user.user.avatar ? user.user.avatar : avatarImg
const userName = user.user.nickname ? user.user.nickname : 'Admin'
const names =[{"text":"长春1379","value":1},{"text":"成都1397","value":2},{"text":"长春2379","value":3}]
const tenant = names.find(item=>item.value == getTenantId())
const loginOut = () => {
ElMessageBox.confirm(t('common.loginOutMessage'), t('common.reminder'), {
@ -54,9 +57,10 @@ const toDocument = () => {
<ElDropdown class="custom-hover custom-hover1" :class="prefixCls" trigger="click">
<div class="flex items-center">
<ElAvatar :src="avatar" alt="" class="w-[calc(var(--logo-height)-25px)] rounded-[50%]" />
<span class="pl-[5px] text-14px text-[var(--top-header-text-color)] <lg:hidden" style="color:#ffffff">
{{ userName }}
</span>
<div class="pl-[5px] text-14px text-[var(--top-header-text-color)] <lg:hidden" style="display: flex; flex-direction: column;color:#ffffff">
<span> {{ userName }} </span>
<span style="margin-top: 5px;text-align:center">{{ tenant.text }}</span>
</div>
</div>
<template #dropdown>
<ElDropdownMenu>

14
src/store/modules/permission.ts

@ -34,17 +34,17 @@ export const usePermissionStore = defineStore('permission', {
actions: {
async generateRoutes(): Promise<unknown> {
return new Promise<void>(async (resolve) => {
let names =[{"text":"长春1379","value":1},{"text":"成都1397","value":2},{"text":"长春2379","value":3}]
let tenant = names.find(item=>item.value == getTenantId())
// let names =[{"text":"长春1379","value":1},{"text":"成都1397","value":2},{"text":"长春2379","value":3}]
// let tenant = names.find(item=>item.value == getTenantId())
// 获得菜单列表,它在登录的时候,setUserInfoAction 方法中已经进行获取
let res: AppCustomRouteRecordRaw[] = []
if (wsCache.get(CACHE_KEY.ROLE_ROUTERS)) {
res = wsCache.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[]
res.forEach(item=>{
if(item.name == '富维海拉供应商系统'&&tenant){
item.name = item.name + tenant['text']
}
})
// res.forEach(item=>{
// if(item.name == '富维海拉供应商系统'&&tenant){
// item.name = item.name + tenant['text']
// }
// })
}
console.log('菜单res',res)
const routerMap: AppRouteRecordRaw[] = generateRoute(res)

Loading…
Cancel
Save