🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 本质是修改文件的方法修改的配置文件 /** * 刷新配置文件 */ protected function refreshFile() { $config = []; foreach ($this->model->all() as $k => $v) { $value = $v->toArray(); if (in_array($value['type'], ['selects', 'checkbox', 'images', 'files'])) { $value['value'] = explode(',', $value['value']); } if ($value['type'] == 'array') { $value['value'] = (array)json_decode($value['value'], true); } $config[$value['name']] = $value['value']; } file_put_contents( APP_PATH . 'extra' . DS . 'site.php', '<?php' . "\n\nreturn " . var_export($config, true) . ";" ); } /** * 检测配置项是否存在 * @internal */ public function check() { $params = $this->request->post("row/a"); if ($params) { $config = $this->model->get($params); if (!$config) { return $this->success(); } else { return $this->error(__('Name already exist')); } } else { return $this->error(__('Invalid parameters')); } }