index.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * @Author: your name
  3. * @Date: 2022-03-03 18:04:40
  4. * @LastEditTime: 2022-04-01 14:29:24
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  7. * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/reports/index.tsx
  8. */
  9. import { useEffect, useState } from 'react';
  10. import { useModel } from 'umi';
  11. import { Skeleton } from 'antd';
  12. export default () => {
  13. const { initialState, setInitialState } = useModel('@@initialState');
  14. const [specialPageUrl, setspecialPageUrl] = useState<string | undefined>(undefined);
  15. const [loading, setloading] = useState(false);
  16. const onLoadhandle = () => {
  17. setloading(false);
  18. };
  19. useEffect(() => {
  20. setloading(true);
  21. if (initialState && initialState.spacicalPageParamsType && initialState.currentUser) {
  22. const {
  23. spacicalPageParamsType,
  24. currentUser: { youshuToken },
  25. } = initialState;
  26. const { pathname } = location;
  27. const spacialPage = spacicalPageParamsType.filter((t: any) => pathname.endsWith(t.path));
  28. if (spacialPage.length > 0) {
  29. //当前页面属于有数数据展示页面
  30. console.log(`${spacialPage[0].url}&token=${youshuToken}`);
  31. const url = `${spacialPage[0].url}&token=${youshuToken}`;
  32. setspecialPageUrl(url);
  33. }
  34. }
  35. }, [initialState]);
  36. return (
  37. <>
  38. <Skeleton loading={loading} paragraph={{ rows: 50 }} active />
  39. <iframe
  40. onLoad={() => onLoadhandle()}
  41. style={{ width: '100%', height:'calc(100vh - 96px)', border: 'none' }}
  42. src={specialPageUrl}
  43. ></iframe>
  44. </>
  45. );
  46. };