ソースを参照

feat: 菜单栏左下角当没有用户名是显示账号。

lanjianrong 4 年 前
コミット
2717320836

+ 2 - 2
src/components/Authorization/index.tsx

@@ -1,4 +1,4 @@
-import { tenderStore } from '@/store/mobx'
+import { tenderStore, userStore } from '@/store/mobx'
 import { observer } from 'mobx-react'
 import React, { useEffect } from 'react'
 interface Authorization {
@@ -23,7 +23,7 @@ const Authorization: React.FC<Authorization> = ({ type, auth, children }) => {
   // 获取mobx存储的权限
   const permission = tenderStore.permission[type]
 
-  if (permission[auth] === authPass) {
+  if (permission[auth] === authPass || !!userStore.userInfo.isAdmin) {
     return <>{children}</>
   }
   return null

+ 2 - 2
src/components/Menu/index.tsx

@@ -15,7 +15,7 @@ interface iMenuProps {
 class NavSider extends Component<iMenuProps, any> {
   render() {
     const { list: MeunList } = this.props
-    return ( 
+    return (
       <div className="main-nav">
         <div className="logo"><img src={logo} /></div>
         <div className="nav-content">
@@ -57,7 +57,7 @@ class NavSider extends Component<iMenuProps, any> {
                   </Menu>
                 )
               }} trigger={[ 'click' ]} placement="topRight">
-                <Button size="small" className={styles.bottomBtn}>{userStore.userInfo.name}</Button>
+                <Button size="small" className={styles.bottomBtn}>{userStore.menuBtnText}</Button>
               </Dropdown>
             </div>
           </div>

+ 3 - 0
src/store/mobx/user/index.ts

@@ -47,6 +47,9 @@ class UserState {
     return this.projectInfo.name
   }
 
+  @computed get menuBtnText() {
+    return this.userInfo.name || this.userInfo.account
+  }
   @action login(values: iFromValues) {
     apiLogin(values).then(({ code = -1, data }) => {
       if (code === consts.RET_CODE.SUCCESS) {