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