index.jsx 1.43 KB
Newer Older
1
import { isDev } from '@/utils/tools';
2
import PageContainer from '@/components/BasePageContainer';
张烨's avatar
张烨 committed
3
import { Tabs } from 'antd';
4 5
import React from 'react';
import styles from './index.less';
6
import SevenParams from '@/pages/productCenter/mobileConfig/menuconfig/SevenParams';
张烨's avatar
张烨 committed
7
const { TabPane } = Tabs;
8 9 10 11 12 13
/**
 * 嵌套iframe的组件
 * @param {*} props 可在路由配置里面配置url参数
 */
const FrameContainer = props => {
  const { route } = props;
张烨's avatar
张烨 committed
14 15 16 17
  const { url = props.url, tabs = props.tabs, tabProps = {} } = route;

  const renderedFrame = tabs ? (
    <Tabs type="card" hideAdd {...tabProps}>
Maofei94's avatar
Maofei94 committed
18
      {tabs.map(({ url: iframeUrl, tabName, type = '' }) => (
张烨's avatar
张烨 committed
19
        <TabPane tab={tabName} key={tabName}>
Maofei94's avatar
Maofei94 committed
20 21 22 23 24 25 26 27 28 29
          {type && type === 'sevenParams' ? (
            <SevenParams />
          ) : (
            <iframe
              title={tabName}
              src={`${
                isDev ? process.env.PROXY : window.location.origin
              }${iframeUrl}`}
            />
          )}
张烨's avatar
张烨 committed
30 31 32 33 34 35 36 37 38 39
        </TabPane>
      ))}
    </Tabs>
  ) : (
    <iframe
      title="iframe"
      src={`${isDev ? process.env.PROXY : window.location.origin}${url}`}
    />
  );

40 41 42
  return (
    <PageContainer
      className={styles.container}
43
      title={false}
44 45 46
      style={{
        display: 'flex',
        flexDirection: 'column',
Maofei94's avatar
Maofei94 committed
47
        height: 'calc(100% + 11px)',
48 49
      }}
    >
张烨's avatar
张烨 committed
50
      {renderedFrame}
51 52 53 54 55
    </PageContainer>
  );
};

export default FrameContainer;