| | |
| | | 'map.model.observer': 'Observer Pattern', |
| | | 'map.model.editor': 'Editor Pattern', |
| | | 'map.save': 'Save Map', |
| | | 'map.load': 'Load Map', |
| | | '': '', |
| | | '': '', |
| | | '': '', |
| | |
| | | <Col span={12} style={{ backgroundColor: '#4a69bd' }}> |
| | | <Flex className={styles.flex} gap={'large'} justify={'flex-end'} align={'center'}> |
| | | |
| | | {model === MapModel.OBSERVER_MODEL && ( |
| | | <> |
| | | <Button |
| | | className='map-header-button' |
| | | size={'large'} |
| | | onClick={() => { |
| | | Utils.fetchMapData(intl); |
| | | }} |
| | | > |
| | | <FormattedMessage id='map.load' defaultMessage='加载地图' /> |
| | | </Button> |
| | | </> |
| | | )} |
| | | |
| | | {model !== MapModel.OBSERVER_MODEL && ( |
| | | <> |
| | | <Button |
| | |
| | | return options; |
| | | } |
| | | |
| | | export const fetchMapData = async () => { |
| | | export const fetchMapData = async (intl) => { |
| | | clearMapData(); |
| | | await Http.doPostPromise('api/map/list', {}, (res) => { |
| | | const mapItemList = res.data.itemList; |
| | | mapItemList.forEach(item => { |
| | |
| | | closeLoading(); |
| | | console.error(error); |
| | | }) |
| | | } |
| | | |
| | | export const clearMapData = (intl) => { |
| | | if (!mapContainer) { |
| | | return; |
| | | } |
| | | let childList = []; |
| | | mapContainer.children.forEach(child => { |
| | | if (child.data?.uuid) { |
| | | childList.push(child); |
| | | } |
| | | }) |
| | | if (childList.length > 0) { |
| | | childList.forEach(child => { |
| | | mapContainer.removeChild(child); |
| | | child.destroy({ children: true, texture: false, baseTexture: false }); |
| | | }) |
| | | childList.forEach((child, index) => { |
| | | childList[index] = null; |
| | | }); |
| | | childList = []; |
| | | } |
| | | } |