From 0e6b6481dd4200fd463179bb570609a9dd79129d Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Tue, 13 Sep 2022 00:49:17 +0800 Subject: [PATCH] [admin] add category icon --- app/Console/Commands/Test.php | 2 +- .../Resources/System/AgentAllowResource.php | 2 +- .../Resources/System/AgentDenyResource.php | 2 +- .../Resources/System/CategoryIconResource.php | 115 ++++++++++++++++++ .../Pages/CreateCategoryIcon.php | 22 ++++ .../Pages/EditCategoryIcon.php | 29 +++++ .../Pages/ListCategoryIcons.php | 20 +++ resources/lang/zh_CN/admin.php | 1 + resources/lang/zh_CN/label.php | 15 +++ 9 files changed, 205 insertions(+), 3 deletions(-) create mode 100644 app/Filament/Resources/System/CategoryIconResource.php create mode 100644 app/Filament/Resources/System/CategoryIconResource/Pages/CreateCategoryIcon.php create mode 100644 app/Filament/Resources/System/CategoryIconResource/Pages/EditCategoryIcon.php create mode 100644 app/Filament/Resources/System/CategoryIconResource/Pages/ListCategoryIcons.php diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index e4d2104c..a5223644 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -87,7 +87,7 @@ class Test extends Command */ public function handle() { - + } diff --git a/app/Filament/Resources/System/AgentAllowResource.php b/app/Filament/Resources/System/AgentAllowResource.php index e1a323c3..9f093ff0 100644 --- a/app/Filament/Resources/System/AgentAllowResource.php +++ b/app/Filament/Resources/System/AgentAllowResource.php @@ -24,7 +24,7 @@ class AgentAllowResource extends Resource protected static ?string $navigationGroup = 'System'; - protected static ?int $navigationSort = 3; + protected static ?int $navigationSort = 4; protected static function getNavigationLabel(): string { diff --git a/app/Filament/Resources/System/AgentDenyResource.php b/app/Filament/Resources/System/AgentDenyResource.php index f6d0cd79..714d0eb7 100644 --- a/app/Filament/Resources/System/AgentDenyResource.php +++ b/app/Filament/Resources/System/AgentDenyResource.php @@ -21,7 +21,7 @@ class AgentDenyResource extends Resource protected static ?string $navigationGroup = 'System'; - protected static ?int $navigationSort = 4; + protected static ?int $navigationSort = 5; protected static function getNavigationLabel(): string { diff --git a/app/Filament/Resources/System/CategoryIconResource.php b/app/Filament/Resources/System/CategoryIconResource.php new file mode 100644 index 00000000..e1ac46df --- /dev/null +++ b/app/Filament/Resources/System/CategoryIconResource.php @@ -0,0 +1,115 @@ +schema([ + Forms\Components\TextInput::make('name')->label(__('label.name'))->required(), + Forms\Components\TextInput::make('folder') + ->label(__('label.icon.folder')) + ->helperText(__('label.icon.folder_help')) + ->required() + , + Forms\Components\Radio::make('multilang') + ->options(self::$yesOrNo) + ->default('no') + ->label(__('label.icon.multilang')) + ->helperText(__('label.icon.multilang_help')) + , + Forms\Components\Radio::make('secondicon') + ->options(self::$yesOrNo) + ->default('no') + ->label(__('label.icon.secondicon')) + ->helperText(__('label.icon.secondicon_help')) + , + Forms\Components\TextInput::make('cssfile') + ->label(__('label.icon.cssfile')) + ->helperText(__('label.icon.cssfile_help')) + , + Forms\Components\TextInput::make('designer') + ->label(__('label.icon.designer')) + ->helperText(__('label.icon.designer_help')) + , + Forms\Components\TextInput::make('comment') + ->label(__('label.icon.comment')) + ->helperText(__('label.icon.comment_help')) + , + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('id'), + Tables\Columns\TextColumn::make('name')->label(__('label.name')), + Tables\Columns\TextColumn::make('folder')->label(__('label.icon.folder')), + Tables\Columns\TextColumn::make('multilang')->label(__('label.icon.multilang')), + Tables\Columns\TextColumn::make('secondicon')->label(__('label.icon.secondicon')), + Tables\Columns\TextColumn::make('cssfile')->label(__('label.icon.cssfile')), + Tables\Columns\TextColumn::make('designer')->label(__('label.icon.designer')), + Tables\Columns\TextColumn::make('comment')->label(__('label.icon.comment')), + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListCategoryIcons::route('/'), + 'create' => Pages\CreateCategoryIcon::route('/create'), + 'edit' => Pages\EditCategoryIcon::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/System/CategoryIconResource/Pages/CreateCategoryIcon.php b/app/Filament/Resources/System/CategoryIconResource/Pages/CreateCategoryIcon.php new file mode 100644 index 00000000..85e78604 --- /dev/null +++ b/app/Filament/Resources/System/CategoryIconResource/Pages/CreateCategoryIcon.php @@ -0,0 +1,22 @@ + '角色', 'permissions' => '权限', 'section' => '分区', + 'icon' => '分类图标', ], 'resources' => [ 'agent_allow' => [ diff --git a/resources/lang/zh_CN/label.php b/resources/lang/zh_CN/label.php index 8b6c1f46..b9ba3dd6 100644 --- a/resources/lang/zh_CN/label.php +++ b/resources/lang/zh_CN/label.php @@ -257,4 +257,19 @@ return [ 'image_help' => '图片文件的名字。允许的字符:[a-z](小写),[0-9],[_./]。', ], ], + 'icon' => [ + 'label' => '分类图标', + 'folder' => '图标文件夹', + 'folder_help' => "分类图标所在的文件夹名。允许的字符:[a-z](小写),[0-9],[_./]。必须在末尾添加斜杠(/),如'mycaticon/'", + 'cssfile' => 'CSS 文件', + 'cssfile_help' => "为此分类图标指定CSS文件。填写完整路径,如'styles/scenetorrents.css'。若无请留空。允许的字符:[a-z](小写),[0-9],[_./]。", + 'multilang' => '多语言', + 'multilang_help' => "是否为不同语言使用不同的分类图标。如果设为'是',将多份图标分别放入命名如'en','chs'等的文件夹中。", + 'secondicon' => '第二图标', + 'secondicon_help' => "是否使用第二图标显示补充信息。如果设为'是',将第二图标放入普通图标目录下命名为'additional'的文件夹中。", + 'designer' => '设计者', + 'designer_help' => '此图标集的设计者。', + 'comment' => '说明', + 'comment_help' => '此图标集的说明。', + ], ];