mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
改进Route Response和request类
This commit is contained in:
@@ -37,9 +37,9 @@ class Request
|
||||
protected static $path;
|
||||
|
||||
/**
|
||||
* @var string 路由
|
||||
* @var array 路由
|
||||
*/
|
||||
protected static $route;
|
||||
protected static $route = [];
|
||||
|
||||
/**
|
||||
* @var array 调度信息
|
||||
@@ -435,10 +435,10 @@ class Request
|
||||
/**
|
||||
* 获取当前请求的路由
|
||||
* @access public
|
||||
* @param string $route 路由名称
|
||||
* @return string
|
||||
* @param array $route 路由名称
|
||||
* @return array
|
||||
*/
|
||||
public static function route($route = '')
|
||||
public static function route($route = [])
|
||||
{
|
||||
if (!empty($route)) {
|
||||
self::$route = $route;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace think;
|
||||
|
||||
use think\Config;
|
||||
use think\Url;
|
||||
use think\View;
|
||||
|
||||
class Response
|
||||
@@ -178,7 +179,8 @@ class Response
|
||||
$type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||
|
||||
if ('html' == $type) {
|
||||
$result = View::instance()->fetch(Config::get('dispatch_success_tmpl'), $result);
|
||||
$result = View::instance(Config::get('template'), Config::get('view_replace_str'))
|
||||
->fetch(Config::get('dispatch_success_tmpl'), $result);
|
||||
}
|
||||
self::type($type);
|
||||
return $result;
|
||||
@@ -211,7 +213,8 @@ class Response
|
||||
$type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||
|
||||
if ('html' == $type) {
|
||||
$result = View::instance()->fetch(Config::get('dispatch_error_tmpl'), $result);
|
||||
$result = View::instance(Config::get('template'), Config::get('view_replace_str'))
|
||||
->fetch(Config::get('dispatch_error_tmpl'), $result);
|
||||
}
|
||||
self::type($type);
|
||||
return $result;
|
||||
|
||||
@@ -418,7 +418,7 @@ class Route
|
||||
}
|
||||
$result = self::checkRule($key, $route, $url1, $pattern, $option);
|
||||
if (false !== $result) {
|
||||
Request::route($route);
|
||||
Request::route(['rule' => $key, 'route' => $route, 'pattern' => $pattern, 'option' => $option]);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -431,7 +431,7 @@ class Route
|
||||
// 规则路由
|
||||
$result = self::checkRule($rule, $route, $url, $pattern, $option);
|
||||
if (false !== $result) {
|
||||
Request::route($route);
|
||||
Request::route(['rule' => $rule, 'route' => $route, 'pattern' => $pattern, 'option' => $option]);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user