From 09943775fd9d597914bf3da6be99cafff83785cf Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Sat, 7 Jun 2025 14:03:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9array=5Fflatten?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common.php | 12 ++++++++++++ app/index/common.php | 12 ------------ app/index/view/mobile/about_us/introduction.html | 4 ++-- app/index/view/mobile/attachment/video.html | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/common.php b/app/common.php index 37309be1..1fa13ee4 100644 --- a/app/common.php +++ b/app/common.php @@ -104,6 +104,18 @@ if (!function_exists('array_to_tree')) { } } +if (!function_exists('array_flatten')) { + /** + * 将多维数组转换为一维数组 + * @param array $array + * @return array + */ + function array_flatten(array $array, int $depth = 1): array + { + return \think\helper\Arr::flatten($array, $depth); + } +} + if (!function_exists('thumb')) { /** * 获取缩略图 diff --git a/app/index/common.php b/app/index/common.php index 7fc6e0a6..7e901805 100644 --- a/app/index/common.php +++ b/app/index/common.php @@ -111,15 +111,3 @@ if (!function_exists('lang_i18n')) { return Lang::get($lang_key, $vars, $lang); } } - -if (!function_exists('array_flatten')) { - /** - * 将多维数组转换为一维数组 - * @param array $array - * @return array - */ - function array_flatten(array $array, int $depth = 1): array - { - return \think\helper\Arr::flatten($array, $depth); - } -} diff --git a/app/index/view/mobile/about_us/introduction.html b/app/index/view/mobile/about_us/introduction.html index 603a1a34..b401bce3 100644 --- a/app/index/view/mobile/about_us/introduction.html +++ b/app/index/view/mobile/about_us/introduction.html @@ -29,7 +29,7 @@

{:lang_i18n('为您提供专属定制服务')}

- {assign name="flat_service" value=":\think\helper\Arr::flatMap(fn($item) => $item, $service)" /} + {assign name="flat_service" value=":array_flatten($service)" /} {volist name="flat_service" id="fs"}
@@ -43,7 +43,7 @@

{:lang_i18n('对于不同的情况')}

- {assign name="flat_difference" value=":\think\helper\Arr::flatMap(fn($item) => $item, $difference)" /} + {assign name="flat_difference" value=":array_flatten($difference)" /} {volist name="flat_difference" id="di"}
diff --git a/app/index/view/mobile/attachment/video.html b/app/index/view/mobile/attachment/video.html index 19d18ea6..71f4704d 100644 --- a/app/index/view/mobile/attachment/video.html +++ b/app/index/view/mobile/attachment/video.html @@ -20,7 +20,7 @@
{notempty name="videos"} - {assign name="flat_videos" value=":\think\helper\Arr::flatMap(fn($item) => $item->toArray(), $videos->items())" /} + {assign name="flat_videos" value=":array_flatten($videos->items())" /} {volist name="flat_videos" id="vo"}