diff --git a/src/common/libs/umi/layoutConfig.tsx b/src/common/libs/umi/layoutConfig.tsx index e52bf2c..bb2bb7d 100644 --- a/src/common/libs/umi/layoutConfig.tsx +++ b/src/common/libs/umi/layoutConfig.tsx @@ -1,9 +1,20 @@ import { MyIcons, MyIconsType, PermissionsType, useMyState } from '@/common'; import AvatarProps from '@/common/components/layout/AvatarProps'; import { Apis } from '@/gen/Apis'; +import { BellOutlined } from '@ant-design/icons'; import { Link, RuntimeConfig, history, useNavigate } from '@umijs/max'; -import { AutoComplete, Input, Menu, MenuProps, Select, Space } from 'antd'; -import { useEffect, useState } from 'react'; +import { + AutoComplete, + Badge, + Button, + Input, + Menu, + MenuProps, + Select, + Space, + Tooltip, +} from 'antd'; +import { useEffect, useRef, useState } from 'react'; import './allConfig.scss'; // import Logo from './logo.png'; interface LevelKeysProps { @@ -61,6 +72,41 @@ export const LayoutConfig: RuntimeConfig['layout'] = () => { const [getSelectProject, setSelectProject] = useState([]); const { snap } = useMyState(); const navigate = useNavigate(); + const [pendingCount, setPendingCount] = useState(); + const intervalRef = useRef(null); + + // 获取待审核数量 + const fetchPendingCount = async () => { + try { + const res = await Apis.Approval.ApprovalInstances.PendingCount(); + setPendingCount(res?.data?.count || ''); + } catch (error) { + console.error('Failed to fetch pending count:', error); + } + }; + + // 组件挂载和用户状态变化时获取数据 + useEffect(() => { + if (!snap.session.user) { + return; + } + fetchPendingCount(); + if (intervalRef.current !== null) { + clearInterval(intervalRef.current); + } + const interval = setInterval(() => { + fetchPendingCount().catch((error) => { + console.error('Interval fetch failed:', error); + }); + }, 3000000); + intervalRef.current = interval; + return () => { + if (intervalRef.current !== null) { + clearInterval(intervalRef.current); + intervalRef.current = null; + } + }; + }, [snap.session.user]); const permissionsList = (snap.session.permissions || []) .filter((p: any) => p.type !== 'Button' && p.path) .sort((a: any, b: any) => a._lft - b._lft) @@ -74,7 +120,7 @@ export const LayoutConfig: RuntimeConfig['layout'] = () => { const handleLoadProject = async () => { let res = await Apis.Common.Auth.GetProjects(); setSelectProject( - res?.data?.map((item) => ({ + res?.data?.map((item: any) => ({ value: item.id, label: item.name, })), @@ -130,12 +176,6 @@ export const LayoutConfig: RuntimeConfig['layout'] = () => { - {/*