Skip to content

Commit

Permalink
refactor(menu): 菜单排序无效问题 (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo authored Nov 15, 2024
1 parent 618bb66 commit 215decb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Http/CurrentUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / build Code coverage report (ubuntu-latest, 8.1, v5.1.3)

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.3 Swow-develop

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.3 Swoole-v5.1.5

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.3 Swoole-master

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.2 Swow-develop

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.2 Swoole-v5.0.3

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.1 Swow-develop

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.2 Swoole-v5.1.5

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.2 Swoole-master

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.1 Swoole-v5.0.3

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.1 Swoole-v5.1.5

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 71 in app/Http/CurrentUser.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.1 Swoole-master

Call to an undefined method Hyperf\Database\Query\Builder::with().
})->flatten();
}

Expand Down
11 changes: 11 additions & 0 deletions app/Repository/Permission/MenuRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -51,6 +61,7 @@ public function allTree(): Collection
return $this->model

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / build Code coverage report (ubuntu-latest, 8.1, v5.1.3)

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.3 Swow-develop

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.3 Swoole-v5.1.5

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.3 Swoole-master

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.2 Swow-develop

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.2 Swoole-v5.0.3

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.1 Swow-develop

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.2 Swoole-v5.1.5

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.2 Swoole-master

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.1 Swoole-v5.0.3

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.1 Swoole-v5.1.5

Call to an undefined method Hyperf\Database\Query\Builder::with().

Check failure on line 61 in app/Repository/Permission/MenuRepository.php

View workflow job for this annotation

GitHub Actions / Test on PHP8.1 Swoole-master

Call to an undefined method Hyperf\Database\Query\Builder::with().
->newQuery()
->where('parent_id', 0)
->orderBy('sort')
->with('children')
->get();
}
Expand Down
4 changes: 2 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 215decb

Please sign in to comment.