assign('configs', parent::getConfigs(['basics', 'upload', 'user', 'mail', 'other'])); } public function index() { if ($this->request->isPost()) { Db::startTrans(); try { $data = $this->request->post(); foreach ($data as $key => $value) { Config::where('name', $key)->setField('value', $value); } Db::commit(); } catch (Exception $e) { Db::rollback(); return $this->error($e->getMessage()); } return $this->success('保存成功'); } // 命名规则 $naming = \think\facade\Config::pull('naming'); $this->assign('naming', $naming); return $this->fetch(); } public function testMail() { if ($this->request->isPost()) { $email = $this->request->post('email'); $err = $this->sendMail($email, '测试', '这是一封测试邮件!'); if (true !== $err) { return $this->error($err); } return $this->success('发送成功'); } } }