mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 19:12:48 +08:00
优化json格式化逻辑
This commit is contained in:
@@ -25,18 +25,29 @@ function json_message($data = [], $code = 0, $msg = '')
|
|||||||
{
|
{
|
||||||
if (is_string($data)) {
|
if (is_string($data)) {
|
||||||
|
|
||||||
|
if(strpos($data,'http') === 0 || strpos($data,'/') === 0){
|
||||||
|
$data = [
|
||||||
|
'jump_to_url'=>$data
|
||||||
|
];
|
||||||
|
}else{
|
||||||
|
|
||||||
$code = $code === 0 ? 500 : $code;
|
$code = $code === 0 ? 500 : $code;
|
||||||
$msg = $data;
|
$msg = $data;
|
||||||
$data = [];
|
$data = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else if($data instanceof Url){
|
||||||
|
$data = [
|
||||||
|
'jump_to_url'=>(string)$data
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return json([
|
return json([
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
'data' => $data
|
'data' => $data
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_system_config($name = '', $default = '')
|
function get_system_config($name = '', $default = '')
|
||||||
{
|
{
|
||||||
$list = Cache::get('system_config');
|
$list = Cache::get('system_config');
|
||||||
|
|||||||
Reference in New Issue
Block a user