From a6bb9568fa90945772159e392ba4a363949ae0d4 Mon Sep 17 00:00:00 2001 From: liyukun <1099438829@qq.com> Date: Thu, 15 Jul 2021 16:57:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AppService.php | 2 +- app/BaseController.php | 3 ++- app/Request.php | 9 +------- app/admin/config/session.php | 1 + app/common/service/Curl.php | 2 +- app/common/service/Json.php | 2 +- app/index/config/route.php | 25 --------------------- config/app.php | 6 ++--- config/route.php | 2 +- public/index.php | 13 +---------- public/nginx.htaccess | 9 ++++---- app/admin/config/route.php => route/app.php | 18 +++++---------- 12 files changed, 22 insertions(+), 70 deletions(-) delete mode 100644 app/index/config/route.php rename app/admin/config/route.php => route/app.php (55%) diff --git a/app/AppService.php b/app/AppService.php index fe217ee..b2de7e7 100644 --- a/app/AppService.php +++ b/app/AppService.php @@ -3,7 +3,7 @@ declare (strict_types = 1); namespace app; -use app\common\utils\Json; +use app\common\service\Json; use think\Service; /** diff --git a/app/BaseController.php b/app/BaseController.php index 404e4df..f97d96e 100644 --- a/app/BaseController.php +++ b/app/BaseController.php @@ -151,6 +151,7 @@ abstract class BaseController } elseif ($url) { $url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : $this->app->route->buildUrl($url); } + $result = [ 'code' => 0, 'msg' => $msg, @@ -161,7 +162,7 @@ abstract class BaseController $type = $this->getResponseType(); if ($type == 'html'){ - $response = view(config('app.exception_tmpl'), $result); + $response = view(config('app.dispatch_success_tmpl'), $result); } else if ($type == 'json') { $response = json($result); } diff --git a/app/Request.php b/app/Request.php index 4d9da3f..fc9aba0 100644 --- a/app/Request.php +++ b/app/Request.php @@ -2,14 +2,7 @@ namespace app; // 应用请求对象类 -use Spatie\Macroable\Macroable; - -/** - * Class Request - * @package app - */ class Request extends \think\Request { - // 宏指令 - use Macroable; + } diff --git a/app/admin/config/session.php b/app/admin/config/session.php index c4fdf6f..040b6aa 100644 --- a/app/admin/config/session.php +++ b/app/admin/config/session.php @@ -7,4 +7,5 @@ return [ // 过期时间 'expire' => 1440, // 前缀 + 'prefix' => 'ape_admin', ]; diff --git a/app/common/service/Curl.php b/app/common/service/Curl.php index d774934..48aba35 100644 --- a/app/common/service/Curl.php +++ b/app/common/service/Curl.php @@ -1,7 +1,7 @@ -// +---------------------------------------------------------------------- - -// +---------------------------------------------------------------------- -// | 应用设置 -// +---------------------------------------------------------------------- - -return [ - // 是否强制使用路由 - 'url_route_must' => false, - // 合并路由规则 - 'route_rule_merge' => true, - // 路由是否完全匹配 - 'route_complete_match' => false, - // 是否自动转换URL中的控制器和操作名 - 'url_convert' => true, -]; diff --git a/config/app.php b/config/app.php index 313fc2a..6c0a8c1 100644 --- a/config/app.php +++ b/config/app.php @@ -18,10 +18,10 @@ return [ 'with_event' => true, // 默认应用 'default_app' => 'index', - // 开启应用快速访问 - 'app_express' => true, // 默认时区 'default_timezone' => 'Asia/Shanghai', + // 快捷访问 + 'app_express' => true, // 自动多应用模式 'auto_multi_app' => true, // 应用映射(自动多应用模式有效) @@ -29,7 +29,7 @@ return [ // 域名绑定(自动多应用模式有效) 'domain_bind' => [], // 禁止URL访问的应用列表(自动多应用模式有效) - 'deny_app_list' => ['common','addons'], + 'deny_app_list' => ['common'], // 异常页面的模板文件 'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl', diff --git a/config/route.php b/config/route.php index 955eeec..2f4cd12 100644 --- a/config/route.php +++ b/config/route.php @@ -27,7 +27,7 @@ return [ // 默认的路由变量规则 'default_route_pattern' => '[\w\.]+', // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则 - 'request_cache' => false, + 'request_cache_key' => false, // 请求缓存有效期 'request_cache_expire' => null, // 全局请求缓存排除规则 diff --git a/public/index.php b/public/index.php index ff67549..e3c0fe9 100644 --- a/public/index.php +++ b/public/index.php @@ -11,20 +11,9 @@ // [ 应用入口文件 ] namespace think; -//检测系统 - -/* -if(file_exists("./install/") && !file_exists("./install/install.lock")){ - if($_SERVER['PHP_SELF'] != '/index.php'){ - header("Content-type: text/html; charset=utf-8"); - exit("请在域名根目录下安装,如:
www.xxx.com/index.php 正确
www.xxx.com/www/index.php 错误,域名后面不能圈套目录, 但项目没有根目录存放限制,可以放在任意目录,apache虚拟主机配置一下即可"); - } - header('Location:/install/index.php'); - exit(); -} -*/ require __DIR__ . '/../vendor/autoload.php'; + // 执行HTTP应用并响应 $http = (new App())->http; diff --git a/public/nginx.htaccess b/public/nginx.htaccess index c540608..dc5e230 100644 --- a/public/nginx.htaccess +++ b/public/nginx.htaccess @@ -1,4 +1,5 @@ -if (!-e $request_filename) { - rewrite ^(.*)$ /index.php?s=/$1 last; - break; - } \ No newline at end of file +location / { + if (!-e $request_filename) { + rewrite ^(.*)$ /index.php?s=/$1 last; + } +} \ No newline at end of file diff --git a/app/admin/config/route.php b/route/app.php similarity index 55% rename from app/admin/config/route.php rename to route/app.php index 3ee9f40..d8e09e3 100644 --- a/app/admin/config/route.php +++ b/route/app.php @@ -8,18 +8,10 @@ // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- +use think\facade\Route; -// +---------------------------------------------------------------------- -// | 应用设置 -// +---------------------------------------------------------------------- +Route::get('think', function () { + return 'hello,ThinkPHP6!'; +}); -return [ - // 是否强制使用路由 - 'url_route_must' => false, - // 合并路由规则 - 'route_rule_merge' => true, - // 路由是否完全匹配 - 'route_complete_match' => false, - // 是否自动转换URL中的控制器和操作名 - 'url_convert' => true, -]; +Route::get('hello/:name', 'index/hello');