From 0965c9192f254b49cf7561ab454efab99d3e215d Mon Sep 17 00:00:00 2001 From: "X.Mo" Date: Fri, 15 Nov 2024 23:31:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor(menu):=20=E8=8F=9C=E5=8D=95=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=97=A0=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/CurrentUser.php | 2 +- app/Repository/Permission/MenuRepository.php | 11 +++++++++++ web/package.json | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Http/CurrentUser.php b/app/Http/CurrentUser.php index cd115824..5ba352a2 100644 --- a/app/Http/CurrentUser.php +++ b/app/Http/CurrentUser.php @@ -68,7 +68,7 @@ public function globalMenuTreeList(): Collection { // @phpstan-ignore-next-line return $this->user()->roles()->get()->map(static function (Role $role) { - return $role->menus()->where('parent_id', 0)->with('children')->get(); + return $role->menus()->where('parent_id', 0)->orderBy('sort')->with('children')->get(); })->flatten(); } diff --git a/app/Repository/Permission/MenuRepository.php b/app/Repository/Permission/MenuRepository.php index 891fb1b1..35368f49 100644 --- a/app/Repository/Permission/MenuRepository.php +++ b/app/Repository/Permission/MenuRepository.php @@ -25,6 +25,16 @@ public function __construct( protected readonly Menu $model ) {} + public function enablePageOrderBy(): bool + { + return false; + } + + public function list(array $params = []): \Hyperf\Collection\Collection + { + return $this->perQuery($this->getQuery($params), $params)->orderBy('sort')->get(); + } + public function handleSearch(Builder $query, array $params): Builder { $whereInName = static function (Builder $query, array|string $code) { @@ -51,6 +61,7 @@ public function allTree(): Collection return $this->model ->newQuery() ->where('parent_id', 0) + ->orderBy('sort') ->with('children') ->get(); } diff --git a/web/package.json b/web/package.json index c8abe315..4ae2edda 100644 --- a/web/package.json +++ b/web/package.json @@ -21,8 +21,8 @@ "@imengyu/vue3-context-menu": "^1.4.2", "@mineadmin/echarts": "^1.0.1", "@mineadmin/form": "^1.0.21", - "@mineadmin/pro-table": "^1.0.27", - "@mineadmin/search": "^1.0.21", + "@mineadmin/pro-table": "^1.0.29", + "@mineadmin/search": "^1.0.23", "@mineadmin/table": "^1.0.29", "@vueuse/core": "^11.1.0", "@vueuse/integrations": "^11.1.0",