import type { Settings as LayoutSettings } from '@ant-design/pro-layout'; import { PageLoading } from '@ant-design/pro-layout'; import type { RunTimeLayoutConfig } from 'umi'; import { history, Link } from 'umi'; import RightContent from '@/components/RightContent'; import Footer from '@/components/Footer'; import { currentUser as queryCurrentUser, queryPersonTxByYw } from './services/ant-design-pro/api'; import { BookOutlined, LinkOutlined } from '@ant-design/icons'; import { RequestConfig } from 'umi'; import { ResponseError } from 'umi-request'; import { notification } from 'antd'; import cookie from 'react-cookies'; const isDev = process.env.NODE_ENV === 'development'; const loginPath = '/user/login'; /** 获取用户信息比较慢的时候会展示一个 loading */ export const initialStateConfig = { loading: , }; /** * @see https://umijs.org/zh-CN/plugins/plugin-initial-state * */ export async function getInitialState(): Promise<{ settings?: Partial; currentUser?: API.CurrentUser; fetchUserInfo?: () => Promise; }> { const fetchUserInfo = async () => { try { const msg = await queryCurrentUser({ person_id: cookie.load('person_id'), identity_id: cookie.load('identity_id'), u_type: 1, // 用户类型 random_num: new Date().getTime(), }); const tx = await queryPersonTxByYw({ person_id: cookie.load('person_id'), identity_id: cookie.load('identity_id'), u_type: 1, // 用户类型 random_num: new Date().getTime(), }); console.log('avatar: ',`/dsideal_yy/html/thumb/Material/${tx?.file_id?.substr(0,2)}/${tx?.file_id}.${tx?.extension}`) return {name: msg?.person_name, userid: msg?.person_id, avatar: `/dsideal_yy/html/thumb/Material/${tx?.file_id?.substr(0,2)}/${tx?.file_id}.${tx?.extension}`}; } catch (error) { history.push(loginPath); } return undefined; }; // 如果是登录页面,不执行 if (history.location.pathname !== loginPath) { const currentUser = await fetchUserInfo(); return { fetchUserInfo, currentUser, settings: {}, }; } return { fetchUserInfo, settings: {}, }; } // ProLayout 支持的api https://procomponents.ant.design/components/layout export const layout: RunTimeLayoutConfig = ({ initialState }) => { return { rightContentRender: () => , disableContentMargin: false, /* waterMarkProps: { content: initialState?.currentUser?.name, },*/ footerRender: () =>