title = '图标选择器';
$this->field = $this->app->request->get('field', 'icon');
$this->fetch(realpath(__DIR__ . '/../../view/api/icon.html'));
}
/**
* 当前运行模式
* @login true
*/
public function debug()
{
if (AdminService::instance()->isSuper()) if (input('state')) {
SystemService::instance()->setRuntime('product');
sysoplog('系统运维管理', '由开发模式切换为产品模式');
$this->success('已切换为产品模式!');
} else {
SystemService::instance()->setRuntime('debug');
sysoplog('系统运维管理', '由产品模式切换为开发模式');
$this->success('已切换为开发模式!');
} else {
$this->error('只有超级管理员才能操作!');
}
}
/**
* 检查任务状态
* @login true
*/
public function queue()
{
if (AdminService::instance()->isSuper()) try {
$message = $this->app->console->call('xadmin:queue', ['status'])->fetch();
if (preg_match('/process.*?\d+.*?running/', $message, $attrs)) {
echo '' . $message . '';
} else {
echo '' . $message . '';
}
} catch (\Exception $exception) {
echo '' . $exception->getMessage() . '';
} else {
echo '只有超级管理员才能操作!';
}
}
/**
* 优化数据库
* @login true
*/
public function optimize()
{
if (AdminService::instance()->isSuper()) {
sysoplog('系统运维管理', '创建数据库优化任务');
$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'] = [];
sysoplog('系统运维管理', '清理系统配置成功');
$this->success('清理系统配置成功!');
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $exception) {
$this->error($exception->getMessage());
} else {
$this->error('只有超级管理员才能操作!');
}
}
/**
* 网站压缩发布
* @login true
*/
public function pushRuntime()
{
if (AdminService::instance()->isSuper()) try {
AdminService::instance()->clearCache();
SystemService::instance()->pushRuntime();
sysoplog('系统运维管理', '网站缓存加速成功');
$this->success('网站缓存加速成功!');
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $exception) {
$this->error($exception->getMessage());
} else {
$this->error('只有超级管理员才能操作!');
}
}
/**
* 清理运行缓存
* @login true
*/
public function clearRuntime()
{
if (AdminService::instance()->isSuper()) try {
AdminService::instance()->clearCache();
SystemService::instance()->clearRuntime();
sysoplog('系统运维管理', '清理网站缓存日志');
$this->success('清理网站缓存成功!');
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $exception) {
$this->error($exception->getMessage());
} else {
$this->error('只有超级管理员才能操作!');
}
}
}