diff --git a/app/admin/controller/api/Plugs.php b/app/admin/controller/api/Plugs.php index 084b6337c..e9824f2a3 100644 --- a/app/admin/controller/api/Plugs.php +++ b/app/admin/controller/api/Plugs.php @@ -131,4 +131,33 @@ class Plugs extends Controller } } -} + /** + * 清理系统配置 + * @login true + */ + public function clearConfig() + { + if (AdminService::instance()->isSuper()) try { + $this->app->db->transaction(function () { + [$tmpdata, $alldata] = [[], []]; + foreach ($this->app->db->name('SystemConfig')->cursor() as $item) { + $tmpdata[$item['type']][$item['name']] = $item['value']; + ksort($tmpdata[$item['type']]); + } + ksort($tmpdata); + foreach ($tmpdata as $type => $items) foreach ($items as $name => $value) { + $alldata[] = ['type' => $type, 'name' => $name, 'value' => $value]; + } + $this->app->db->name('SystemConfig')->whereRaw('1=1')->delete(); + $this->app->db->name('SystemConfig')->insertAll($alldata); + }); + $this->success('清理系统配置成功!'); + } catch (HttpResponseException $exception) { + throw $exception; + } catch (\Exception $exception) { + $this->error($exception->getMessage()); + } else { + $this->error('只有超级管理员才能操作!'); + } + } +} \ No newline at end of file diff --git a/app/admin/view/config/index.html b/app/admin/view/config/index.html index 04324ea5e..19828d061 100644 --- a/app/admin/view/config/index.html +++ b/app/admin/view/config/index.html @@ -3,6 +3,7 @@ {block name="button"} 优化数据库 +清理重复配置 修改系统参数