From 6659a97cbaa76a522212067391f5ea6c03fb0651 Mon Sep 17 00:00:00 2001 From: Anyon Date: Mon, 16 Nov 2020 15:33:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=BC=94=E7=A4=BA=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/route/demo.php | 70 +++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/app/admin/route/demo.php b/app/admin/route/demo.php index d8ab5eb45..bc08bfbbc 100644 --- a/app/admin/route/demo.php +++ b/app/admin/route/demo.php @@ -15,33 +15,43 @@ use think\admin\service\SystemService; -// 演示环境禁止操作路由绑定 -if (SystemService::instance()->checkRunMode('demo')) { - app()->route->post('index/pass', function () { - return json(['code' => 0, 'info' => '演示环境禁止修改用户密码!']); - }); - app()->route->post('config/system', function () { - return json(['code' => 0, 'info' => '演示环境禁止修改系统配置!']); - }); - app()->route->post('config/storage', function () { - return json(['code' => 0, 'info' => '演示环境禁止修改系统配置!']); - }); - app()->route->post('menu/index', function () { - return json(['code' => 0, 'info' => '演示环境禁止给菜单排序!']); - }); - app()->route->post('menu/add', function () { - return json(['code' => 0, 'info' => '演示环境禁止添加菜单!']); - }); - app()->route->post('menu/edit', function () { - return json(['code' => 0, 'info' => '演示环境禁止编辑菜单!']); - }); - app()->route->post('menu/state', function () { - return json(['code' => 0, 'info' => '演示环境禁止禁用菜单!']); - }); - app()->route->post('menu/remove', function () { - return json(['code' => 0, 'info' => '演示环境禁止删除菜单!']); - }); - app()->route->post('user/pass', function () { - return json(['code' => 0, 'info' => '演示环境禁止修改用户密码!']); - }); -} +invoke(function (\think\App $app) { + /*! 非开发环境,清理限制文件 */ + if (!SystemService::instance()->checkRunMode('dev')) { + @unlink("{$app->getBasePath()}admin/controller/api/Update.php"); + @unlink("{$app->getBasePath()}admin/route/demo.php"); + @rmdir("{$app->getBasePath()}admin/route"); + return; + } + /*! 演示环境禁止操作路由绑定 */ + if (SystemService::instance()->checkRunMode('demo')) { + $app->route->post('index/pass', function () { + return json(['code' => 0, 'info' => '演示环境禁止修改用户密码!']); + }); + $app->route->post('config/system', function () { + return json(['code' => 0, 'info' => '演示环境禁止修改系统配置!']); + }); + $app->route->post('config/storage', function () { + return json(['code' => 0, 'info' => '演示环境禁止修改系统配置!']); + }); + $app->route->post('menu/index', function () { + return json(['code' => 0, 'info' => '演示环境禁止给菜单排序!']); + }); + $app->route->post('menu/add', function () { + return json(['code' => 0, 'info' => '演示环境禁止添加菜单!']); + }); + $app->route->post('menu/edit', function () { + return json(['code' => 0, 'info' => '演示环境禁止编辑菜单!']); + }); + $app->route->post('menu/state', function () { + return json(['code' => 0, 'info' => '演示环境禁止禁用菜单!']); + }); + $app->route->post('menu/remove', function () { + return json(['code' => 0, 'info' => '演示环境禁止删除菜单!']); + }); + $app->route->post('user/pass', function () { + return json(['code' => 0, 'info' => '演示环境禁止修改用户密码!']); + }); + } + +}); \ No newline at end of file