feat:动态权限

This commit is contained in:
JaguarJack
2022-12-10 18:29:42 +08:00
parent 8c537e6656
commit c4270a2fc8
46 changed files with 948 additions and 177 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace Modules\Options\Repository;
use Catch\CatchAdmin;
use Catch\Support\Composer;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class Components implements OptionInterface
{
/**
* @var array|string[]
*/
protected array $components = [
[
'label' => 'layout',
'value' => '/admin/layout/index.vue'
]
];
public function get(): array
{
if ($module = request()->get('module')) {
$components = File::glob(CatchAdmin::getModuleViewsPath($module) . '*/*.vue');
foreach ($components as $component) {
$this->components[] = [
'label' => Str::of($component)->explode(DIRECTORY_SEPARATOR)->pop(2)->pop(),
'value' => Str::of($component)->replace(CatchAdmin::moduleRootPath(), '')->prepend('/')
];
}
}
return $this->components;
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Modules\Options\Repository;
use Catch\CatchAdmin;
use Catch\Support\Composer;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class Controllers implements OptionInterface
{
public function get(): array
{
$controllers = [];
if ($module = request()->get('module')) {
$controllerFiles = File::glob(CatchAdmin::getModuleControllerPath($module) . '*.php');
foreach ($controllerFiles as $controllerFile) {
$controllers[] = [
'label' => Str::of(File::name($controllerFile))->remove('Controller'),
'value' => Str::of(File::name($controllerFile))->remove('Controller'),
];
}
}
return $controllers;
}
}