success('网站缓存加速成功!', 'javascript:location.reload()'); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { trace_file($exception); $this->error($exception->getMessage()); } else { $this->error('请使用超管账号操作!'); } } /** * 清理运行缓存 * @login true */ public function clear() { if (AdminService::isSuper()) try { RuntimeService::clear() && sysoplog('系统运维管理', '清理网站日志缓存'); $this->success('清空日志缓存成功!', 'javascript:location.reload()'); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { trace_file($exception); $this->error($exception->getMessage()); } else { $this->error('请使用超管账号操作!'); } } /** * 当前运行模式 * @login true */ public function debug() { if (AdminService::isSuper()) if (input('state')) { RuntimeService::set('product'); sysoplog('系统运维管理', '开发模式切换为生产模式'); $this->success('已切换为生产模式!', 'javascript:location.reload()'); } else { RuntimeService::set('debug'); sysoplog('系统运维管理', '生产模式切换为开发模式'); $this->success('已切换为开发模式!', 'javascript:location.reload()'); } else { $this->error('请使用超管账号操作!'); } } /** * 修改富文本编辑器 * @return void * @throws \think\admin\Exception */ public function editor() { if (AdminService::isSuper()) { $editor = input('editor', 'auto'); sysconf('base.editor', $editor); sysoplog('系统运维管理', "切换编辑器为{$editor}"); $this->success('已切换后台编辑器!', 'javascript:location.reload()'); } else { $this->error('请使用超管账号操作!'); } } /** * 清理系统配置 * @login true */ public function config() { if (AdminService::isSuper()) try { [$tmpdata, $newdata] = [[], []]; foreach (SystemConfig::mk()->order('type,name asc')->cursor() as $item) { $tmpdata[$item['type']][$item['name']] = $item['value']; } foreach ($tmpdata as $type => $items) foreach ($items as $name => $value) { $newdata[] = ['type' => $type, 'name' => $name, 'value' => $value]; } $this->app->db->transaction(function () use ($newdata) { SystemConfig::mQuery()->empty()->insertAll($newdata); }); $this->app->cache->delete('SystemConfig'); sysoplog('系统运维管理', '清理系统配置参数'); $this->success('清理系统配置成功!', 'javascript:location.reload()'); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { trace_file($exception); $this->error($exception->getMessage()); } else { $this->error('请使用超管账号操作!'); } } }