From adcd2efd074eb3160c429ea8a5dfd537db1d1304 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期三, 17 十二月 2025 14:37:06 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/map/tool.js | 72 ++++++++++++++++++++++++++++++++---
1 files changed, 65 insertions(+), 7 deletions(-)
diff --git a/zy-acs-flow/src/map/tool.js b/zy-acs-flow/src/map/tool.js
index 380fbf3..2bd45c6 100644
--- a/zy-acs-flow/src/map/tool.js
+++ b/zy-acs-flow/src/map/tool.js
@@ -911,11 +911,22 @@
const addAreaLabel = (draft, text, from, to) => {
const centerX = (from.x + to.x) / 2;
const centerY = (from.y + to.y) / 2;
- const label = new PIXI.Text(text, {
- fill: themeMode === 'dark' ? '#f1f2f6' : '#535353ff',
- fontSize: 20 / Math.abs(mapContainer.scale.x || 1),
- fontWeight: 'bold',
+ const currentScale = Math.abs(mapContainer.scale.x || 1);
+ const labelStyle = new PIXI.TextStyle({
+ fontFamily: 'Inter, "Segoe UI", sans-serif',
+ fill: themeMode === 'dark' ? '#f1f2f6' : '#606060ff',
+ fontSize: Math.max(16, 20 / currentScale),
+ fontWeight: 600,
+ letterSpacing: 10,
+ // stroke: themeMode === 'dark' ? '#1e272e' : '#ffffff',
+ // strokeThickness: Math.max(1, 2 / currentScale),
+ // dropShadow: true,
+ // dropShadowColor: themeMode === 'dark' ? '#00000066' : '#95a5a6',
+ // dropShadowBlur: 1.5,
+ // dropShadowAngle: Math.PI / 4,
+ // dropShadowDistance: 2,
});
+ const label = new PIXI.Text(text ?? '', labelStyle);
label.anchor.set(0.5);
label.position.set(centerX, centerY);
label.rotation = rotationParseNum(MAP_DEFAULT_ROTATION);
@@ -923,7 +934,29 @@
draft.addChild(label);
};
-export const loadAreas = (curZone, setCurSprite) => {
+export const updateAreaSpriteName = (sprite, newName) => {
+ if (!sprite || sprite?.data?.type !== DEVICE_TYPE.AREA) {
+ return;
+ }
+ sprite.data.name = newName;
+ const label = sprite.children?.find((child) => child instanceof PIXI.Text);
+ if (label) {
+ label.text = newName ?? '';
+ }
+};
+
+export const removeAreaSprite = (sprite) => {
+ if (!sprite || sprite?.data?.type !== DEVICE_TYPE.AREA) {
+ return;
+ }
+ const parent = sprite.parent || mapContainer;
+ if (parent) {
+ parent.removeChild(sprite);
+ }
+ sprite.destroy({ children: true, texture: false, baseTexture: false });
+};
+
+export const loadAreas = (curZone, setCurSprite, callback) => {
if (!mapContainer) return;
clearAreas();
fetchAreaList(curZone).then((areas) => {
@@ -939,6 +972,9 @@
mapContainer.addChild(graphics);
}
});
+ if (callback) {
+ callback(areas);
+ }
});
};
@@ -961,8 +997,11 @@
const draft = new PIXI.Graphics();
draft.name = id ? `area_${id}` : 'area_' + generateID();
- draft.zIndex = DEVICE_Z_INDEX.AREA;
- draft.lineStyle(2 / Math.abs(mapContainer.scale.x || 1), AREA_BORDER_COLOR, 0.9);
+ draft.zIndex = 0;
+ if (setCurSprite) {
+ draft.zIndex = DEVICE_Z_INDEX.AREA;
+ }
+ draft.lineStyle(1 / Math.abs(mapContainer.scale.x || 1), AREA_BORDER_COLOR, 0.9);
draft.beginFill(areaColor, 0.18);
draft.drawRect(
Math.min(from.x, to.x),
@@ -1086,3 +1125,22 @@
stage.on('pointerup', handleUp);
return true;
};
+
+export const cancelAreaDrawing = () => {
+ if (areaDrawingCleanup) {
+ areaDrawingCleanup();
+ }
+};
+
+export const showAreas = (curZone, setShowAreas, setLoading) => {
+ setLoading(true);
+ loadAreas(curZone, null, (areas) => {
+ setLoading(false);
+ setShowAreas(true);
+ })
+};
+
+export const hideAreas = (curZone, setShowAreas) => {
+ clearAreas();
+ setShowAreas(false);
+};
--
Gitblit v1.9.1