fix: 优化提示

This commit is contained in:
JaguarJack 2024-03-07 11:28:09 +08:00
parent 4606f9c792
commit e5be0ca2f8

View File

@ -20,23 +20,27 @@ class Components implements OptionInterface
public function get(): array public function get(): array
{ {
if ($module = request()->get('module')) { try {
$components = File::glob(CatchAdmin::getModuleViewsPath($module).'*'.DIRECTORY_SEPARATOR.'*.vue'); if ($module = request()->get('module')) {
$components = File::glob(CatchAdmin::getModuleViewsPath($module) . '*' . DIRECTORY_SEPARATOR . '*.vue');
foreach ($components as $component) { foreach ($components as $component) {
$_component = Str::of($component) $_component = Str::of($component)
->replace(CatchAdmin::moduleRootPath(), '') ->replace(CatchAdmin::moduleRootPath(), '')
->explode(DIRECTORY_SEPARATOR); ->explode(DIRECTORY_SEPARATOR);
$_component->shift(2); $_component->shift(2);
$this->components[] = [ $this->components[] = [
'label' => Str::of($_component->implode('/'))->replace('.vue', ''), 'label' => Str::of($_component->implode('/'))->replace('.vue', ''),
'value' => Str::of($component)->replace(CatchAdmin::moduleRootPath(), '')->prepend('/') 'value' => Str::of($component)->replace(CatchAdmin::moduleRootPath(), '')->prepend('/')
]; ];
}
} }
}
return $this->components; return $this->components;
} catch (\Throwable $exception) {
return [];
}
} }
} }