/*
 * @Author: your name
 * @Date: 2022-03-03 18:04:40
 * @LastEditTime: 2024-09-13 11:12:26
 * @LastEditors: code4eat awesomedema@gmail.com
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/reports/index.tsx
 */

import { useEffect, useState } from 'react';

import { Skeleton } from 'antd';
import { useModel } from 'umi';

export default () => {
  const { initialState, setInitialState } = useModel('@@initialState');
  const [specialPageUrl, setspecialPageUrl] = useState<string | undefined>(undefined);
  const [loading, setloading] = useState(false);

  const onLoadhandle = () => {
    setloading(false);
  };

  useEffect(() => {
    setloading(true);
    if (initialState && initialState.spacicalPageParamsType && initialState.userData) {
      const {
        spacicalPageParamsType,
        userData: { youshuToken },
      } = initialState;


      const { pathname } = location;
      const spacialPage = spacicalPageParamsType.filter((t) => t.path == pathname);

      if (spacialPage.length > 0) {
        //当前页面属于有数数据展示页面
        const url = `${spacialPage[0].url}`;
        setspecialPageUrl(url);
      }
    }
  }, [initialState]);

  return (
    <>
      <Skeleton loading={loading} paragraph={{ rows: 50 }} active />
      <iframe onLoad={() => onLoadhandle()} style={{ width: '100%', height: '90vh', border: 'none' }} src={specialPageUrl}></iframe>
    </>
  );
};
