From 48c825951caafa1c51b0e20a2ee852d31ed44b41 Mon Sep 17 00:00:00 2001 From: air <30444667+sszdot@users.noreply.github.com> Date: Tue, 23 Sep 2025 12:12:04 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afactor=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E4=BC=98=E5=8C=96=E4=BA=86=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=20=E5=9C=B0=E5=9B=BE=E8=A1=A8=E7=9A=84=E7=BB=93=E6=9E=84=20=20?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E5=AD=97=E6=AE=B5=20?= =?UTF-8?q?=E3=80=90=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E6=8E=A5=E5=8F=A3=E5=AD=97=E6=AE=B5=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E3=80=90=E5=BD=B1=20=20=E5=93=8D=E3=80=91?= =?UTF-8?q?=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PlaneController.class.php | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/FlyCube/MpApi/Controller/PlaneController.class.php b/FlyCube/MpApi/Controller/PlaneController.class.php index bcfbab5..cf9e0d4 100644 --- a/FlyCube/MpApi/Controller/PlaneController.class.php +++ b/FlyCube/MpApi/Controller/PlaneController.class.php @@ -1103,7 +1103,7 @@ class PlaneController extends PublicController { $where['is_active'] = 1; $mapStyleDb = D('map_styles'); - $field = array('id', 'name', 'sprite', 'glyphs', 'version', 'source_name', 'source_type', 'tile_size', 'tiles', 'attribution', 'layer_id', 'layer_type', 'layer_source', 'sort_order'); + $field = array('id', 'name', 'sprite', 'glyphs', 'tiles', 'sort_order'); $list = $mapStyleDb->where($where)->field($field)->order('sort_order ASC')->select(); if ($list) { @@ -1151,9 +1151,8 @@ class PlaneController extends PublicController */ public function addMapStyle() { - // 必填字段校验 - $required = ['name', 'version', 'source_name', 'source_type', 'tile_size', 'tiles', 'layer_id', 'layer_type', 'layer_source']; + $required = ['name', 'tiles']; foreach ($required as $key) { if (!isset($_REQUEST[$key]) || $_REQUEST[$key] === '') { echo json_encode(['status' => 0, 'msg' => '参数缺失: ' . $key]); @@ -1161,22 +1160,14 @@ class PlaneController extends PublicController } } - $data = []; - $data['name'] = $_REQUEST['name']; - $data['sprite'] = isset($_REQUEST['sprite']) ? $_REQUEST['sprite'] : ''; - $data['glyphs'] = isset($_REQUEST['glyphs']) ? $_REQUEST['glyphs'] : ''; - $data['version'] = intval($_REQUEST['version']); - $data['source_name'] = $_REQUEST['source_name']; - $data['source_type'] = $_REQUEST['source_type']; - $data['tile_size'] = intval($_REQUEST['tile_size']); - // tiles 直接保存为字符串(JSON),getMapStyleList 时再 decode - $data['tiles'] = $_REQUEST['tiles']; - $data['attribution'] = isset($_REQUEST['attribution']) ? $_REQUEST['attribution'] : ''; - $data['layer_id'] = $_REQUEST['layer_id']; - $data['layer_type'] = $_REQUEST['layer_type']; - $data['layer_source'] = $_REQUEST['layer_source']; - $data['is_active'] = isset($_REQUEST['is_active']) ? intval($_REQUEST['is_active']) : 1; - $data['sort_order'] = isset($_REQUEST['sort_order']) ? intval($_REQUEST['sort_order']) : 0; + $data = [ + 'name' => $_REQUEST['name'], + 'sprite' => $_REQUEST['sprite'] ?? '', + 'glyphs' => $_REQUEST['glyphs'] ?? 'mapbox://fonts/mapbox/{fontstack}/{range}.pbf', + 'tiles' => is_array($_REQUEST['tiles']) ? json_encode($_REQUEST['tiles']) : $_REQUEST['tiles'], + 'is_active' => isset($_REQUEST['is_active']) ? intval($_REQUEST['is_active']) : 1, + 'sort_order' => isset($_REQUEST['sort_order']) ? intval($_REQUEST['sort_order']) : 0 + ]; $db = D('map_styles'); if ($db->data($data)->add()) { @@ -1191,7 +1182,6 @@ class PlaneController extends PublicController */ public function saveMapStyle() { - if (!isset($_REQUEST['id']) || $_REQUEST['id'] === '') { echo json_encode(['status' => 0, 'msg' => '参数缺失: id']); return; @@ -1203,15 +1193,9 @@ class PlaneController extends PublicController if (isset($_REQUEST['name'])) $data['name'] = $_REQUEST['name']; if (isset($_REQUEST['sprite'])) $data['sprite'] = $_REQUEST['sprite']; if (isset($_REQUEST['glyphs'])) $data['glyphs'] = $_REQUEST['glyphs']; - if (isset($_REQUEST['version'])) $data['version'] = intval($_REQUEST['version']); - if (isset($_REQUEST['source_name'])) $data['source_name'] = $_REQUEST['source_name']; - if (isset($_REQUEST['source_type'])) $data['source_type'] = $_REQUEST['source_type']; - if (isset($_REQUEST['tile_size'])) $data['tile_size'] = intval($_REQUEST['tile_size']); - if (isset($_REQUEST['tiles'])) $data['tiles'] = $_REQUEST['tiles']; - if (isset($_REQUEST['attribution'])) $data['attribution'] = $_REQUEST['attribution']; - if (isset($_REQUEST['layer_id'])) $data['layer_id'] = $_REQUEST['layer_id']; - if (isset($_REQUEST['layer_type'])) $data['layer_type'] = $_REQUEST['layer_type']; - if (isset($_REQUEST['layer_source'])) $data['layer_source'] = $_REQUEST['layer_source']; + if (isset($_REQUEST['tiles'])) { + $data['tiles'] = is_array($_REQUEST['tiles']) ? json_encode($_REQUEST['tiles']) : $_REQUEST['tiles']; + } if (isset($_REQUEST['is_active'])) $data['is_active'] = intval($_REQUEST['is_active']); if (isset($_REQUEST['sort_order'])) $data['sort_order'] = intval($_REQUEST['sort_order']);