mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改系统运行服务
This commit is contained in:
parent
983496fd9c
commit
90228f0ff6
@ -19,6 +19,7 @@ namespace app\admin\controller;
|
|||||||
use think\admin\Controller;
|
use think\admin\Controller;
|
||||||
use think\admin\service\AdminService;
|
use think\admin\service\AdminService;
|
||||||
use think\admin\service\ModuleService;
|
use think\admin\service\ModuleService;
|
||||||
|
use think\admin\service\RuntimeService;
|
||||||
use think\admin\service\SystemService;
|
use think\admin\service\SystemService;
|
||||||
use think\admin\storage\AliossStorage;
|
use think\admin\storage\AliossStorage;
|
||||||
use think\admin\storage\QiniuStorage;
|
use think\admin\storage\QiniuStorage;
|
||||||
@ -81,7 +82,7 @@ class Config extends Controller
|
|||||||
if ($post['xpath'] !== 'admin' && file_exists($this->app->getBasePath() . $post['xpath'])) {
|
if ($post['xpath'] !== 'admin' && file_exists($this->app->getBasePath() . $post['xpath'])) {
|
||||||
$this->error("后台入口名称{$post['xpath']}已经存在应用!");
|
$this->error("后台入口名称{$post['xpath']}已经存在应用!");
|
||||||
}
|
}
|
||||||
SystemService::setRuntime(null, [$post['xpath'] => 'admin']);
|
RuntimeService::set(null, [$post['xpath'] => 'admin']);
|
||||||
}
|
}
|
||||||
// 修改网站 ICON 图标,替换 public/favicon.ico
|
// 修改网站 ICON 图标,替换 public/favicon.ico
|
||||||
if (preg_match('#^https?://#', $post['site_icon'] ?? '')) try {
|
if (preg_match('#^https?://#', $post['site_icon'] ?? '')) try {
|
||||||
|
@ -21,6 +21,7 @@ use think\admin\extend\CodeExtend;
|
|||||||
use think\admin\model\SystemUser;
|
use think\admin\model\SystemUser;
|
||||||
use think\admin\service\AdminService;
|
use think\admin\service\AdminService;
|
||||||
use think\admin\service\CaptchaService;
|
use think\admin\service\CaptchaService;
|
||||||
|
use think\admin\service\RuntimeService;
|
||||||
use think\admin\service\SystemService;
|
use think\admin\service\SystemService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +45,7 @@ class Login extends Controller
|
|||||||
$this->redirect(sysuri('admin/index/index'));
|
$this->redirect(sysuri('admin/index/index'));
|
||||||
} else {
|
} else {
|
||||||
// 当前运行模式
|
// 当前运行模式
|
||||||
$this->developMode = SystemService::checkRunMode();
|
$this->developMode = RuntimeService::check();
|
||||||
// 后台背景处理
|
// 后台背景处理
|
||||||
$images = str2arr(sysconf('login_image') ?: '', '|');
|
$images = str2arr(sysconf('login_image') ?: '', '|');
|
||||||
if (empty($images)) $images = [
|
if (empty($images)) $images = [
|
||||||
|
@ -19,7 +19,7 @@ namespace app\admin\controller\api;
|
|||||||
use think\admin\Controller;
|
use think\admin\Controller;
|
||||||
use think\admin\model\SystemConfig;
|
use think\admin\model\SystemConfig;
|
||||||
use think\admin\service\AdminService;
|
use think\admin\service\AdminService;
|
||||||
use think\admin\service\SystemService;
|
use think\admin\service\RuntimeService;
|
||||||
use think\exception\HttpResponseException;
|
use think\exception\HttpResponseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,8 +37,7 @@ class System extends Controller
|
|||||||
public function push()
|
public function push()
|
||||||
{
|
{
|
||||||
if (AdminService::isSuper()) try {
|
if (AdminService::isSuper()) try {
|
||||||
AdminService::clearCache();
|
AdminService::clearCache() && RuntimeService::push();
|
||||||
SystemService::pushRuntime();
|
|
||||||
sysoplog('系统运维管理', '刷新创建路由缓存');
|
sysoplog('系统运维管理', '刷新创建路由缓存');
|
||||||
$this->success('网站缓存加速成功!', 'javascript:location.reload()');
|
$this->success('网站缓存加速成功!', 'javascript:location.reload()');
|
||||||
} catch (HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
@ -58,8 +57,7 @@ class System extends Controller
|
|||||||
public function clear()
|
public function clear()
|
||||||
{
|
{
|
||||||
if (AdminService::isSuper()) try {
|
if (AdminService::isSuper()) try {
|
||||||
AdminService::clearCache();
|
AdminService::clearCache() && RuntimeService::clear();
|
||||||
SystemService::clearRuntime();
|
|
||||||
sysoplog('系统运维管理', '清理网站日志缓存');
|
sysoplog('系统运维管理', '清理网站日志缓存');
|
||||||
$this->success('清空日志缓存成功!', 'javascript:location.reload()');
|
$this->success('清空日志缓存成功!', 'javascript:location.reload()');
|
||||||
} catch (HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
@ -79,11 +77,11 @@ class System extends Controller
|
|||||||
public function debug()
|
public function debug()
|
||||||
{
|
{
|
||||||
if (AdminService::isSuper()) if (input('state')) {
|
if (AdminService::isSuper()) if (input('state')) {
|
||||||
SystemService::setRuntime('product');
|
RuntimeService::set('product');
|
||||||
sysoplog('系统运维管理', '开发模式切换为生产模式');
|
sysoplog('系统运维管理', '开发模式切换为生产模式');
|
||||||
$this->success('已切换为生产模式!', 'javascript:location.reload()');
|
$this->success('已切换为生产模式!', 'javascript:location.reload()');
|
||||||
} else {
|
} else {
|
||||||
SystemService::setRuntime('debug');
|
RuntimeService::set('debug');
|
||||||
sysoplog('系统运维管理', '生产模式切换为开发模式');
|
sysoplog('系统运维管理', '生产模式切换为开发模式');
|
||||||
$this->success('已切换为开发模式!', 'javascript:location.reload()');
|
$this->success('已切换为开发模式!', 'javascript:location.reload()');
|
||||||
} else {
|
} else {
|
||||||
|
@ -18,7 +18,7 @@ namespace app\admin\controller\api;
|
|||||||
|
|
||||||
use think\admin\Controller;
|
use think\admin\Controller;
|
||||||
use think\admin\service\ModuleService;
|
use think\admin\service\ModuleService;
|
||||||
use think\admin\service\SystemService;
|
use think\admin\service\RuntimeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装服务端支持
|
* 安装服务端支持
|
||||||
@ -33,7 +33,7 @@ class Update extends Controller
|
|||||||
*/
|
*/
|
||||||
protected function initialize()
|
protected function initialize()
|
||||||
{
|
{
|
||||||
if (!SystemService::checkRunMode()) {
|
if (!RuntimeService::check()) {
|
||||||
$this->error('只允许访问本地或官方代码!');
|
$this->error('只允许访问本地或官方代码!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,17 +15,17 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
use think\admin\Library;
|
use think\admin\Library;
|
||||||
use think\admin\service\SystemService;
|
use think\admin\service\RuntimeService;
|
||||||
|
|
||||||
/*! 非开发环境,清理限制文件 */
|
/*! 非开发环境,清理限制文件 */
|
||||||
if (Library::$sapp->request->isGet() && !SystemService::checkRunMode()) {
|
if (Library::$sapp->request->isGet() && !RuntimeService::check()) {
|
||||||
@unlink(Library::$sapp->getBasePath() . 'admin/controller/api/Update.php');
|
@unlink(Library::$sapp->getBasePath() . 'admin/controller/api/Update.php');
|
||||||
@unlink(Library::$sapp->getBasePath() . 'admin/route/demo.php');
|
@unlink(Library::$sapp->getBasePath() . 'admin/route/demo.php');
|
||||||
@rmdir(Library::$sapp->getBasePath() . 'admin/route');
|
@rmdir(Library::$sapp->getBasePath() . 'admin/route');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! 演示环境禁止操作路由绑定 */
|
/*! 演示环境禁止操作路由绑定 */
|
||||||
if (SystemService::checkRunMode('demo')) {
|
if (RuntimeService::check('demo')) {
|
||||||
Library::$sapp->route->post('index/pass', function () {
|
Library::$sapp->route->post('index/pass', function () {
|
||||||
return json(['code' => 0, 'info' => '演示环境禁止修改用户密码!']);
|
return json(['code' => 0, 'info' => '演示环境禁止修改用户密码!']);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user