webman迁移-优化

This commit is contained in:
2026-03-18 15:10:40 +08:00
parent ea77c7b3a1
commit e2ae55319e
70 changed files with 1278 additions and 137 deletions

View File

@@ -87,7 +87,14 @@ abstract class BaseController
unset($header['statusCode']);
$headers = array_merge(['Content-Type' => 'application/json'], $header);
$jsonBody = json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$options = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
if (defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
$options |= JSON_INVALID_UTF8_SUBSTITUTE;
}
$jsonBody = json_encode($body, $options);
if ($jsonBody === false) {
$jsonBody = '{"code":0,"msg":"JSON encode error","time":' . time() . ',"data":[]}';
}
return response($jsonBody, $statusCode, $headers);
}