#
Junjie
2024-03-28 0817793961918c1123328bca9a78ca29d95738b8
zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx
@@ -1,6 +1,7 @@
import React, { useState, useRef, useEffect } from 'react';
import { Card, Form, Button } from 'antd';
import { Spin, Form, Button } from 'antd';
import { FormattedMessage, useIntl, useModel } from '@umijs/max';
import { LoadingOutlined } from '@ant-design/icons';
import { createStyles } from 'antd-style';
import * as Utils from '../../utils'
import Http from '@/utils/http';
@@ -12,7 +13,7 @@
            zIndex: 99,
            width: '500px',
            height: '600px',
        }
        },
    }
})
@@ -21,23 +22,41 @@
const ShelfView = (props) => {
    const intl = useIntl();
    const { styles } = useStyles();
    // console.log(props.data);
    const refContainer = useRef();
    const [loading, setLoading] = React.useState(false);
    useEffect(() => {
    const startThree = () => {
        shelfThree = new ShelfThree(refContainer.current);
        shelfThree.startup();
    }
        return () => {
            shelfThree?.destroy();
    const endThree = () => {
        if (shelfThree) {
            shelfThree.destroy();
            shelfThree = null;
        }
    }, []);
    }
    useEffect(() => {
        setLoading(true);
        endThree();
        setTimeout(() => {
            setLoading(false);
            startThree();
        }, 300)
        return endThree;
    }, [props.data.uuid]);
    return (
        <>
            <div className={styles.threeContainer} ref={refContainer}></div>
            <Spin
                spinning={loading}
                indicator={<LoadingOutlined spin />}
                size={'large'}
            >
                <div ref={refContainer} className={styles.threeContainer}></div>
            </Spin>
        </>
    )
}