title = '图标选择器'; $this->field = input('field', 'icon'); $this->fetch(realpath(__DIR__ . '/../../view/api/icon.html')); } /** * 网站压缩发布 * @login true */ public function push() { try { if (AdminService::instance()->isSuper()) { SystemService::instance()->pushRuntime(); $this->success('网站缓存加速成功!'); } else { $this->error('只有超级管理员才能操作!'); } } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { $this->error($exception->getMessage()); } } /** * 清理运行缓存 * @login true */ public function clear() { try { if (AdminService::instance()->isSuper()) { SystemService::instance()->clearRuntime(); $this->success('清理网站缓存成功!'); } else { $this->error('只有超级管理员才能操作!'); } } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { $this->error($exception->getMessage()); } } /** * 数据变更日志 * @login true * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function oplog() { if (AdminService::instance()->isSuper()) { $data = $this->_vali([ 'state.in:0,1' => '状态值范围错误!', 'state.require' => '状态值不能为空!', ]); sysconf('base.oplog_state', $data['state']); $this->success('数据变更日志切换成功!'); } else { $this->error('只有超级管理员才能操作!'); } } /** * 当前运行模式 * @login true */ public function debug() { if (AdminService::instance()->isSuper()) { if (input('state')) { SystemService::instance()->productMode(true); $this->success('已切换为生产模式!'); } else { SystemService::instance()->productMode(false); $this->success('已切换为开发模式!'); } } else { $this->error('只有超级管理员才能操作!'); } } /** * 优化数据库 * @login true */ public function optimize() { if (AdminService::instance()->isSuper()) { $this->_queue('优化数据库所有数据表', 'xadmin:database optimize', 0, [], 0, 0); } else { $this->error('只有超级管理员才能操作!'); } } /** * 清理系统配置 * @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->app->cache->delete('SystemConfig'); $GLOBALS['oplogs'] = []; $this->success('清理系统配置成功!'); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { $this->error($exception->getMessage()); } else { $this->error('只有超级管理员才能操作!'); } } }