/*
 * @Author: cclu
 * @Date: 2021-12-13 11:01:23
 * @LastEditors: cclu 1106109051@qq.com
 * @LastEditTime: 2025-02-26 11:43:08
 * @FilePath: \cloud-platform\src\layouts\UserLayout.tsx
 * @Description:
 *
 * Copyright (c) 2022 by cclu/杭州驿商科技, All Rights Reserved.
 */
import type { MenuDataItem } from '@ant-design/pro-layout';
import { DefaultFooter, getMenuData, getPageTitle } from '@ant-design/pro-layout';
import { Helmet, HelmetProvider } from 'react-helmet-async';
import type { ConnectProps } from 'umi';
import { Link, useIntl, connect } from 'umi';
import React, { useEffect } from 'react';
import type { ConnectState } from '@/models/connect';
import logo from '../assets/logo.png';
import { VERSION, BUILD_TIME, GIT_HASH } from '../versionEnv';
import styles from './UserLayout.less';

export type UserLayoutProps = {
  breadcrumbNameMap: Record<string, MenuDataItem>;
} & Partial<ConnectProps>;

const UserLayout: React.FC<UserLayoutProps> = (props) => {
  const {
    route = {
      routes: [],
    },
  } = props;
  const { routes = [] } = route;
  const {
    children,
    location = {
      pathname: '',
    },
  } = props;
  const { formatMessage } = useIntl();
  const { breadcrumb } = getMenuData(routes);
  const title = getPageTitle({
    pathname: location.pathname,
    // formatMessage,
    breadcrumb,
    ...props,
  });

  return (
    <HelmetProvider>
      <Helmet>
        <title>{title}</title>
        <meta name="description" content={title} />
      </Helmet>

      <div className={styles.container}>
        <div className={styles.lang}>
          <Link to="/">
            <img alt="logo" className={styles.logo} src={logo} />
            <span className={styles.headtitle}>驿商云</span>
          </Link>
        </div>
        <div className={styles.content}>

          {children}
        </div>
        <DefaultFooter
          copyright={`Copyright © 2013-${new Date().getFullYear()} Eshang Cloud. All Rights Reserved. 驿商云 版权所有  V${VERSION || ''}`}
          // copyright={`Copyright © 2013-${new Date().getFullYear()} Eshang Cloud. All Rights Reserved. 驿商云 版权所有  V6.6.6`}
          links={[]}
        />
      </div>
    </HelmetProvider>
  );
};

export default connect(({ settings }: ConnectState) => ({ ...settings }))(UserLayout);
