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",