mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
页面跳转的error和success模板分开 \think\controller类添加result方法 用于单独返回不同格式的api数据
This commit is contained in:
@@ -91,7 +91,8 @@ return [
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
// 默认跳转页面对应的模板文件
|
// 默认跳转页面对应的模板文件
|
||||||
'dispatch_jump_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||||
|
'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
|
||||||
// 默认的模板引擎
|
// 默认的模板引擎
|
||||||
'template_engine' => 'Think',
|
'template_engine' => 'Think',
|
||||||
|
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ 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 = \think\View::instance()->fetch(Config::get('dispatch_jump_tmpl'), $result);
|
$result = \think\View::instance()->fetch(Config::get('dispatch_success_tmpl'), $result);
|
||||||
}
|
}
|
||||||
self::type($type);
|
self::type($type);
|
||||||
return $result;
|
return $result;
|
||||||
@@ -214,7 +214,7 @@ 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 = \think\View::instance()->fetch(Config::get('dispatch_jump_tmpl'), $result);
|
$result = \think\View::instance()->fetch(Config::get('dispatch_error_tmpl'), $result);
|
||||||
}
|
}
|
||||||
self::type($type);
|
self::type($type);
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
@@ -46,6 +46,20 @@ trait Jump
|
|||||||
return Response::success($msg, $data, $url, $wait);
|
return Response::success($msg, $data, $url, $wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回封装后的API数据到客户端
|
||||||
|
* @access public
|
||||||
|
* @param mixed $data 要返回的数据
|
||||||
|
* @param integer $code 返回的code
|
||||||
|
* @param mixed $msg 提示信息
|
||||||
|
* @param string $type 返回数据格式
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function result($data, $code = 0, $msg = '', $type = '')
|
||||||
|
{
|
||||||
|
return Response::result($data, $code, $msg, $type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL重定向
|
* URL重定向
|
||||||
* @access protected
|
* @access protected
|
||||||
|
|||||||
Reference in New Issue
Block a user