diff --git a/app/admin/controller/Config.php b/app/admin/controller/Config.php index 9c8f28c5e..d37a2a231 100644 --- a/app/admin/controller/Config.php +++ b/app/admin/controller/Config.php @@ -19,6 +19,7 @@ namespace app\admin\controller; use think\admin\Controller; use think\admin\service\AdminService; use think\admin\service\ModuleService; +use think\admin\service\RuntimeService; use think\admin\service\SystemService; use think\admin\storage\AliossStorage; use think\admin\storage\QiniuStorage; @@ -81,7 +82,7 @@ class Config extends Controller if ($post['xpath'] !== 'admin' && file_exists($this->app->getBasePath() . $post['xpath'])) { $this->error("后台入口名称{$post['xpath']}已经存在应用!"); } - SystemService::setRuntime(null, [$post['xpath'] => 'admin']); + RuntimeService::set(null, [$post['xpath'] => 'admin']); } // 修改网站 ICON 图标,替换 public/favicon.ico if (preg_match('#^https?://#', $post['site_icon'] ?? '')) try { diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index b9d1b02ab..9b5b1576f 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -21,6 +21,7 @@ use think\admin\extend\CodeExtend; use think\admin\model\SystemUser; use think\admin\service\AdminService; use think\admin\service\CaptchaService; +use think\admin\service\RuntimeService; use think\admin\service\SystemService; /** @@ -44,7 +45,7 @@ class Login extends Controller $this->redirect(sysuri('admin/index/index')); } else { // 当前运行模式 - $this->developMode = SystemService::checkRunMode(); + $this->developMode = RuntimeService::check(); // 后台背景处理 $images = str2arr(sysconf('login_image') ?: '', '|'); if (empty($images)) $images = [ diff --git a/app/admin/controller/api/System.php b/app/admin/controller/api/System.php index 750d57c8e..682e17c4f 100644 --- a/app/admin/controller/api/System.php +++ b/app/admin/controller/api/System.php @@ -19,7 +19,7 @@ namespace app\admin\controller\api; use think\admin\Controller; use think\admin\model\SystemConfig; use think\admin\service\AdminService; -use think\admin\service\SystemService; +use think\admin\service\RuntimeService; use think\exception\HttpResponseException; /** @@ -37,8 +37,7 @@ class System extends Controller public function push() { if (AdminService::isSuper()) try { - AdminService::clearCache(); - SystemService::pushRuntime(); + AdminService::clearCache() && RuntimeService::push(); sysoplog('系统运维管理', '刷新创建路由缓存'); $this->success('网站缓存加速成功!', 'javascript:location.reload()'); } catch (HttpResponseException $exception) { @@ -58,8 +57,7 @@ class System extends Controller public function clear() { if (AdminService::isSuper()) try { - AdminService::clearCache(); - SystemService::clearRuntime(); + AdminService::clearCache() && RuntimeService::clear(); sysoplog('系统运维管理', '清理网站日志缓存'); $this->success('清空日志缓存成功!', 'javascript:location.reload()'); } catch (HttpResponseException $exception) { @@ -79,11 +77,11 @@ class System extends Controller public function debug() { if (AdminService::isSuper()) if (input('state')) { - SystemService::setRuntime('product'); + RuntimeService::set('product'); sysoplog('系统运维管理', '开发模式切换为生产模式'); $this->success('已切换为生产模式!', 'javascript:location.reload()'); } else { - SystemService::setRuntime('debug'); + RuntimeService::set('debug'); sysoplog('系统运维管理', '生产模式切换为开发模式'); $this->success('已切换为开发模式!', 'javascript:location.reload()'); } else { diff --git a/app/admin/controller/api/Update.php b/app/admin/controller/api/Update.php index 570deb46f..88e44e135 100644 --- a/app/admin/controller/api/Update.php +++ b/app/admin/controller/api/Update.php @@ -18,7 +18,7 @@ namespace app\admin\controller\api; use think\admin\Controller; 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() { - if (!SystemService::checkRunMode()) { + if (!RuntimeService::check()) { $this->error('只允许访问本地或官方代码!'); } } diff --git a/app/admin/route/demo.php b/app/admin/route/demo.php index 3ccca9e20..0cf2286f5 100644 --- a/app/admin/route/demo.php +++ b/app/admin/route/demo.php @@ -15,17 +15,17 @@ // +---------------------------------------------------------------------- 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/route/demo.php'); @rmdir(Library::$sapp->getBasePath() . 'admin/route'); } /*! 演示环境禁止操作路由绑定 */ -if (SystemService::checkRunMode('demo')) { +if (RuntimeService::check('demo')) { Library::$sapp->route->post('index/pass', function () { return json(['code' => 0, 'info' => '演示环境禁止修改用户密码!']); });