mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
简化slog类
This commit is contained in:
@@ -107,10 +107,7 @@ class App
|
||||
// 操作方法执行完成监听
|
||||
Hook::listen('action_end', $data);
|
||||
// 返回数据
|
||||
Response::returnData($data, $config['default_return_type']);
|
||||
if ($config['response_exit']) {
|
||||
exit;
|
||||
}
|
||||
Response::returnData($data, $config['default_return_type'], $config['response_exit']);
|
||||
} else {
|
||||
// 操作方法不是Public 抛出异常
|
||||
throw new \ReflectionException();
|
||||
|
||||
@@ -70,6 +70,7 @@ class Error
|
||||
{
|
||||
// 记录日志
|
||||
Log::save();
|
||||
\org\Slog::sendLog();
|
||||
if ($e = error_get_last()) {
|
||||
switch ($e['type']) {
|
||||
case E_ERROR:
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
|
||||
namespace think;
|
||||
|
||||
use think\Config as Config;
|
||||
use think\Transform as Transform;
|
||||
use think\Url as Url;
|
||||
|
||||
class Response
|
||||
{
|
||||
|
||||
@@ -23,9 +19,10 @@ class Response
|
||||
* @access protected
|
||||
* @param mixed $data 要返回的数据
|
||||
* @param String $type 返回数据格式
|
||||
* @param bool $exit 是否终止执行
|
||||
* @return void
|
||||
*/
|
||||
public static function returnData($data, $type = '')
|
||||
public static function returnData($data, $type = '', $exit = true)
|
||||
{
|
||||
$headers = [
|
||||
'json' => 'application/json',
|
||||
@@ -55,7 +52,11 @@ class Response
|
||||
$data = $handler . '(' . Transform::jsonEncode($data) . ');';
|
||||
break;
|
||||
}
|
||||
echo $data;
|
||||
if ($exit) {
|
||||
exit($data);
|
||||
} else {
|
||||
echo $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,10 +71,10 @@ class Response
|
||||
public static function result($data, $code = 0, $msg = '', $type = '')
|
||||
{
|
||||
$result = [
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
'time' => NOW_TIME,
|
||||
'data' => $data
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
'time' => NOW_TIME,
|
||||
'data' => $data,
|
||||
];
|
||||
self::returnData($result, $type);
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ namespace think;
|
||||
class View
|
||||
{
|
||||
// 模板引擎实例
|
||||
protected $engine = null;
|
||||
protected $engine = null;
|
||||
// 模板主题名称
|
||||
protected $theme = '';
|
||||
protected $theme = '';
|
||||
// 模板变量
|
||||
protected $data = [];
|
||||
protected $data = [];
|
||||
// 视图参数
|
||||
protected $config = [
|
||||
protected $config = [
|
||||
'theme_on' => false,
|
||||
'auto_detect_theme' => false,
|
||||
'var_theme' => 't',
|
||||
@@ -35,7 +35,7 @@ class View
|
||||
|
||||
public function __construct(array $config = [])
|
||||
{
|
||||
$this->config(empty($config) ? Config::get() : $config);
|
||||
$this->config($config);
|
||||
$this->engine($this->config['engine_type']);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user