mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 19:12:48 +08:00
新增封装返回函数;
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
use app\common\service\AuthService;
|
use app\common\service\AuthService;
|
||||||
use think\facade\Cache;
|
use think\facade\Cache;
|
||||||
|
use think\route\Url;
|
||||||
|
|
||||||
if (!function_exists('__url')) {
|
if (!function_exists('__url')) {
|
||||||
|
|
||||||
@@ -122,3 +123,31 @@ if (!function_exists('auth')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function json_message($data = [], $code = 0, $msg = '')
|
||||||
|
{
|
||||||
|
if (is_string($data)) {
|
||||||
|
|
||||||
|
if (strpos($data, 'http') === 0 || strpos($data, '/') === 0) {
|
||||||
|
$data = [
|
||||||
|
'jump_to_url' => $data
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$code = $code === 0 ? 500 : $code;
|
||||||
|
$msg = $data;
|
||||||
|
$data = [];
|
||||||
|
}
|
||||||
|
} else if ($data instanceof Url) {
|
||||||
|
$data = [
|
||||||
|
'jump_to_url' => (string)$data
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => $code,
|
||||||
|
'msg' => $msg,
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user