From 2a22ccfe93dc9585a906b493d61e54449c267511 Mon Sep 17 00:00:00 2001 From: Working Date: Sun, 17 Mar 2024 08:39:33 +0800 Subject: [PATCH 1/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cfb20c..4c2beb6 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ **[propaganistas/laravel-phone](https://github.com/Propaganistas/Laravel-Phone)**
**[overtrue/easy-sms](https://github.com/overtrue/easy-sms)**
**[overtrue/laravel-socialite](https://github.com/overtrue/laravel-socialite)**
-开发后台阿里云短信、第三方登录开关按钮和配置基础注册登录三方登录api接口 +开发后台阿里云短信、第三方登录开关按钮(开关请注意config/api_switch.php权限问题)和配置基础注册登录三方登录api接口 From ca6edb5dbd97dc57fd92722b13a81bcd2aa58371 Mon Sep 17 00:00:00 2001 From: Working Date: Fri, 7 Jun 2024 08:37:14 +0800 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c2beb6..24439d8 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ License

-> 这是一个基于laravel8.x和dcatadmin的模块化练习项目 +> 这是一个基于laravel8.x和dcatadmin的集成快速开发框架,包含api接口、后台管理等基础通用功能。 ### 初始化操作 ##### 1.加载依赖
From 0769dec9a5c65c990740a2552e3902d851177471 Mon Sep 17 00:00:00 2001 From: Working Date: Fri, 7 Jun 2024 13:03:49 +0800 Subject: [PATCH 3/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7cb132d..d0bb7bf 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,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" }, From fda06b9803866931ae5ec6a2e8db6e53bde4279f Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 7 Jun 2024 13:14:53 +0800 Subject: [PATCH 4/6] =?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 2c4aeb1..80f2a62 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) { @@ -33,8 +95,8 @@ protected function form() case '阿里云短信': $helpText = '关闭后api获取验证码为默认1234并且不会发送短信'; break; - case '微信登陆': - $helpText = '关闭后则不允许微信第三方登录'; + case '微信小程序登陆': + $helpText = '关闭后则不允许微信小程序登录'; break; } // 直接使用switch组件 @@ -48,25 +110,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 357326047ec57fbe1007bec1c50dc62b5ead97d7 Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 7 Jun 2024 13:31:25 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/ApiSwitchController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Admin/Controllers/ApiSwitchController.php b/app/Admin/Controllers/ApiSwitchController.php index 80f2a62..7a4f136 100644 --- a/app/Admin/Controllers/ApiSwitchController.php +++ b/app/Admin/Controllers/ApiSwitchController.php @@ -95,8 +95,8 @@ protected function form() case '阿里云短信': $helpText = '关闭后api获取验证码为默认1234并且不会发送短信'; break; - case '微信小程序登陆': - $helpText = '关闭后则不允许微信小程序登录'; + case '微信登陆': + $helpText = '关闭后则不允许微信登录'; break; } // 直接使用switch组件 From 8967fd118338c460bcd4e9c4f4e47bb1cb2b8cf1 Mon Sep 17 00:00:00 2001 From: liu Date: Fri, 7 Jun 2024 13:58:05 +0800 Subject: [PATCH 6/6] =?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,