From 40205396e2d21b3b2a1c3b2e27ddf403d1f9b8d4 Mon Sep 17 00:00:00 2001 From: chenlong Date: Thu, 7 Dec 2023 18:49:03 +0800 Subject: [PATCH] 1 --- Admin/Service/ApiDocService.php | 24 ++++++++++++++++++++++++ Admin/View/Document/view.php | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Admin/Service/ApiDocService.php b/Admin/Service/ApiDocService.php index b01a4b3..51cda0c 100644 --- a/Admin/Service/ApiDocService.php +++ b/Admin/Service/ApiDocService.php @@ -36,6 +36,8 @@ class ApiDocService $apiLists = $this->scan($getPath); + $apiLists = $this->apiGroup($apiLists); + return [ "title" => $appName . 'API 接口文档', "version" => array_unique(array_merge(...array_column($apiLists, 'version'))), @@ -312,4 +314,26 @@ class ApiDocService }); } } + + /** + * @param array $apiLists + * + * @return array + */ + private function apiGroup(array $apiLists): array + { + $newList = []; + + foreach ($apiLists as $apiList) { + $newList[$apiList['name']][] = $apiList; + } + + return array_map(function ($list) { + return [ + 'name' => $list[0]['name'], + 'children' => array_merge(...array_column($list, 'children')), + 'version' => array_merge(...array_column($list,'version')) + ]; + }, $newList); + } } \ No newline at end of file diff --git a/Admin/View/Document/view.php b/Admin/View/Document/view.php index 603ba17..24a35d6 100644 --- a/Admin/View/Document/view.php +++ b/Admin/View/Document/view.php @@ -300,7 +300,7 @@ } if (!/response\.data\.token/.test(this.scriptAfterRequest)) { this.scriptAfterRequest += `\nif(response.data.token){\n` - + ` localStorage.setItem("token", response.data.token);\n` + + ` localStorage.setItem("token", response.data.token.token);\n` + `}`; }