From a6fb1438ee0ecc1ee10ca09f3a5d09c0712404dc Mon Sep 17 00:00:00 2001 From: Working Date: Fri, 7 Jun 2024 08:40:23 +0800 Subject: [PATCH 1/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e311c8..0458c41 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ License

-> 这是一个基于laravel8.x和dcatadmin的模块化练习项目 +> 这是一个基于laravel8.x和dcatadmin的集成快速开发框架,包含api接口、后台管理等基础通用功能。 ### 初始化操作 ##### 1.加载依赖
From 8c4a728b25e7b5af1122edd629fa8e75c431db9f Mon Sep 17 00:00:00 2001 From: Working Date: Fri, 7 Jun 2024 13:04:32 +0800 Subject: [PATCH 2/4] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1950e30..999c5b4 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "laravel/tinker": "^2.5", "overtrue/easy-sms": "^2.6", "overtrue/laravel-lang": "^5.0", - "overtrue/laravel-socialite": "^2.1", + "overtrue/laravel-socialite": "3.0", "propaganistas/laravel-phone": "^4.4", "tymon/jwt-auth": "^1.0", "yansongda/pay": "^2.10" From d0d01d5579c8163ef8021a2d5c6a7536f5b361c8 Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 7 Jun 2024 13:34:56 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E9=9B=86=E6=88=90=E7=BC=93=E5=AD=98=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/ApiSwitchController.php | 105 ++++++++++++++++-- app/Admin/routes.php | 2 + 2 files changed, 100 insertions(+), 7 deletions(-) diff --git a/app/Admin/Controllers/ApiSwitchController.php b/app/Admin/Controllers/ApiSwitchController.php index 561455a..c3eeb61 100644 --- a/app/Admin/Controllers/ApiSwitchController.php +++ b/app/Admin/Controllers/ApiSwitchController.php @@ -13,18 +13,80 @@ class ApiSwitchController extends AdminController { + public function index(Content $content) { + Admin::script($this->javascript()); return $content ->header('API 功能开关') ->description('管理 API 功能的开启和关闭') ->body($this->form()); } + protected function javascript() + { + return <<title('注:如开关状态修改失败,请点击右侧清理缓存后再次尝试!'); $config = config('api_switch'); foreach ($config as $key => $enabled) { @@ -34,10 +96,10 @@ protected function form() $helpText = '关闭后api获取验证码为默认1234并且不会发送短信'; break; case '阿里通义千问': - $helpText = '关闭后则不再调用接口'; + $helpText = '关闭后则无法调用该接口'; break; case '微信登陆': - $helpText = '关闭后则不允许微信第三方登录'; + $helpText = '关闭后则不允许微信登录'; break; } // 直接使用switch组件 @@ -51,25 +113,32 @@ protected function form() // 隐藏继续创建按钮 $form->disableCreatingCheck(); - // 隐藏查看按钮 $form->disableViewCheck(); - - $form->disableHeader(); - +// $form->disableHeader(); // 隐藏顶部的列表按钮(返回按钮) $form->disableListButton(); + //隐藏提交按钮 + $form->disableSubmitButton(); // 设置表单提交的路由 $form->action(admin_url('api-switches')); + // 添加自定义按钮 + $form->tools(function (Form\Tools $tools) { + $tools->append('清除配置缓存'); + $tools->append('保存配置缓存'); + }); }); return $form; } + + + // 重命名方法以避免潜在的冲突 - public function save(Request $request) + protected function save(Request $request) { $data = $request->except(['_token', '_method', '_previous_']); $configData = "success('操作成功'); } + + //清理缓存配置 + protected function clearConfigCache() + { + try { + Artisan::call('config:clear'); + return JsonResponse::make()->success('配置缓存已清除'); + } catch (\Exception $e) { + return JsonResponse::make()->error('清除缓存失败: '.$e->getMessage()); + } + } + + //保存缓存配置 + protected function cacheConfig() + { + try { + Artisan::call('config:cache'); + return JsonResponse::make()->success('配置缓存已保存'); + } catch (\Exception $e) { + return JsonResponse::make()->error('保存缓存失败: '.$e->getMessage()); + } + } } diff --git a/app/Admin/routes.php b/app/Admin/routes.php index 79c4b56..ba686b6 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -16,6 +16,8 @@ $router->get('/', 'HomeController@index'); $router->get('/api-switches', [ApiSwitchController::class,'index']); $router->post('/api-switches', [ApiSwitchController::class,'save']); + $router->post('/api-switches/clear-cache', [ApiSwitchController::class,'clearConfigCache'])->name('api-switches.clear-cache'); + $router->post('/api-switches/cache-config', [ApiSwitchController::class,'cacheConfig'])->name('api-switches.cache-config'); From 67cf14fa1ac4829811bf2829b4928c525c3d1e8c Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 7 Jun 2024 14:03:27 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Actions/Grid/TextActions.php | 52 ++++++++++++++++++++++++++ config/admin.php | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 app/Admin/Actions/Grid/TextActions.php diff --git a/app/Admin/Actions/Grid/TextActions.php b/app/Admin/Actions/Grid/TextActions.php new file mode 100644 index 0000000..7ce9802 --- /dev/null +++ b/app/Admin/Actions/Grid/TextActions.php @@ -0,0 +1,52 @@ + ' . $label . '  '; + } + + /** + * @return string + */ + protected function getEditLabel() + { + $label = trans('admin.edit'); + + return '  '; + } + + /** + * @return string + */ + protected function getQuickEditLabel() + { + $label = trans('admin.edit'); + $label2 = trans('admin.quick_edit'); + + return '  '; + } + + /** + * @return string + */ + protected function getDeleteLabel() + { + $label = trans('admin.delete'); + + return '  '; + } +} diff --git a/config/admin.php b/config/admin.php index aa287af..f830949 100644 --- a/config/admin.php +++ b/config/admin.php @@ -169,7 +169,7 @@ 'grid' => [ // The global Grid action display class. - 'grid_action_class' => Dcat\Admin\Grid\Displayers\DropdownActions::class, + 'grid_action_class' => App\Admin\Actions\Grid\TextActions::class, // The global Grid batch action display class. 'batch_action_class' => Dcat\Admin\Grid\Tools\BatchActions::class,