import Bar from './Bar'; import ConfigProvider from '../config-provider'; import Container from './Container'; import React, { Component } from 'react'; import cls from 'classnames'; import { Loading as NextLoading } from '@alifd/next'; import { LoadingProps as NextLoadingProps } from '@alifd/next/types/loading'; import { useNProgress } from '@tanem/react-nprogress'; interface LoadingTypeProps { type?: 'circle' | 'linear' | 'global_linear' } interface LoadingProps extends Omit, LoadingTypeProps { size?: 'xl' | 'large' | 'medium' | 'small', } // 圆形加载不同尺寸大小的加载图案 // 加大号 const indicator1 = prefix => (
); // 大号 const indicator2 = prefix => (
;
); // 中号 const indicator3 = prefix => (
); // 小号 const indicator4 = prefix => (
); // 全局线性加载组件 const Progress = ({ isAnimating }) => { const { animationDuration, isFinished, progress } = useNProgress({ isAnimating, }); return ( ); }; class Loading extends Component { readonly state = { isAnimating: false, key: 0, }; render() { const { prefix = 'next-', size = 'large', type = 'circle', className, fullScreen, visible = true, ...otherProps } = this.props; let loading_indicator; if (size === 'xl' || fullScreen) { loading_indicator = indicator1(prefix); } else if (size === 'large') { loading_indicator = indicator2(prefix); } else if (size === 'medium') { loading_indicator = indicator3(prefix); } else if (size === 'small') { loading_indicator = indicator4(prefix); } if (type === 'global_linear') { return ( <> ); } return ( ); } } export default ConfigProvider.config(Loading);