diff --git a/README.md b/README.md
index 1cfb20c..24439d8 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
-> 这是一个基于laravel8.x和dcatadmin的模块化练习项目
+> 这是一个基于laravel8.x和dcatadmin的集成快速开发框架,包含api接口、后台管理等基础通用功能。
### 初始化操作
##### 1.加载依赖
@@ -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接口
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/app/Admin/Controllers/ApiSwitchController.php b/app/Admin/Controllers/ApiSwitchController.php
index 2c4aeb1..7a4f136 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,7 +96,7 @@ protected function form()
$helpText = '关闭后api获取验证码为默认1234并且不会发送短信';
break;
case '微信登陆':
- $helpText = '关闭后则不允许微信第三方登录';
+ $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');
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"
},
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,