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` + `}`; }