From 398fde3a6d9e833e8dd99e1c30865caf369c1d24 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期三, 17 十二月 2025 12:47:04 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/map/header/AreaFab.jsx | 14 +++-----------
zy-acs-flow/src/map/tool.js | 20 +++++++++++++++++++-
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/zy-acs-flow/src/map/header/AreaFab.jsx b/zy-acs-flow/src/map/header/AreaFab.jsx
index 16651f0..229ddb1 100644
--- a/zy-acs-flow/src/map/header/AreaFab.jsx
+++ b/zy-acs-flow/src/map/header/AreaFab.jsx
@@ -1,28 +1,20 @@
-import React, { useState, useRef, useEffect, useMemo } from "react";
+import React from "react";
import { useTranslate } from "react-admin";
-import {
- Fab,
- Box,
- Backdrop,
- useTheme,
-} from '@mui/material';
+import { Fab } from '@mui/material';
import CropFreeIcon from '@mui/icons-material/CropFree';
import CircularProgress from '@mui/material/CircularProgress';
import * as Tool from '../tool';
const AreaFab = (props) => {
- const { curZone, showAreas, setShowAreas, notify } = props;
+ const { curZone, showAreas, setShowAreas } = props;
const translate = useTranslate();
- const theme = useTheme(); // theme.palette.primary.main
const [loading, setLoading] = React.useState(false);
const handleClick = () => {
if (showAreas) {
- // setShowAreas(false);
Tool.hideAreas(curZone, setShowAreas);
} else {
- // setShowAreas(true);
Tool.showAreas(curZone, setShowAreas, setLoading);
}
}
diff --git a/zy-acs-flow/src/map/tool.js b/zy-acs-flow/src/map/tool.js
index 791f5c1..a9213fc 100644
--- a/zy-acs-flow/src/map/tool.js
+++ b/zy-acs-flow/src/map/tool.js
@@ -945,7 +945,7 @@
sprite.destroy({ children: true, texture: false, baseTexture: false });
};
-export const loadAreas = (curZone, setCurSprite) => {
+export const loadAreas = (curZone, setCurSprite, callback) => {
if (!mapContainer) return;
clearAreas();
fetchAreaList(curZone).then((areas) => {
@@ -961,6 +961,9 @@
mapContainer.addChild(graphics);
}
});
+ if (callback) {
+ callback(areas);
+ }
});
};
@@ -1114,3 +1117,18 @@
areaDrawingCleanup();
}
};
+
+export const showAreas = (curZone, setShowAreas, setLoading) => {
+ setLoading(true);
+ loadAreas(curZone, null, (areas) => {
+ setLoading(false);
+ setShowAreas(true);
+ })
+};
+
+export const hideAreas = (curZone, setShowAreas) => {
+ clearAreas();
+ if (setShowAreas) {
+ setShowAreas(false);
+ }
+};
--
Gitblit v1.9.1