From 7e34a8f7c50a8c2d546b31e5375073f2cc570318 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 15 三月 2024 16:48:37 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/locales/en-US/map.ts | 1 +
zy-asrs-flow/src/pages/map/index.jsx | 14 ++++++++++++++
zy-asrs-flow/src/pages/map/utils.js | 25 ++++++++++++++++++++++++-
3 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/zy-asrs-flow/src/locales/en-US/map.ts b/zy-asrs-flow/src/locales/en-US/map.ts
index b4ea4c7..c3839c1 100644
--- a/zy-asrs-flow/src/locales/en-US/map.ts
+++ b/zy-asrs-flow/src/locales/en-US/map.ts
@@ -6,6 +6,7 @@
'map.model.observer': 'Observer Pattern',
'map.model.editor': 'Editor Pattern',
'map.save': 'Save Map',
+ 'map.load': 'Load Map',
'': '',
'': '',
'': '',
diff --git a/zy-asrs-flow/src/pages/map/index.jsx b/zy-asrs-flow/src/pages/map/index.jsx
index 11cd0a3..8d16f42 100644
--- a/zy-asrs-flow/src/pages/map/index.jsx
+++ b/zy-asrs-flow/src/pages/map/index.jsx
@@ -240,6 +240,20 @@
<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
diff --git a/zy-asrs-flow/src/pages/map/utils.js b/zy-asrs-flow/src/pages/map/utils.js
index 321d73c..cde1275 100644
--- a/zy-asrs-flow/src/pages/map/utils.js
+++ b/zy-asrs-flow/src/pages/map/utils.js
@@ -316,7 +316,8 @@
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 => {
@@ -382,4 +383,26 @@
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 = [];
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1