0, 'msg' => '只有超级管理员可以执行此操作', ], JSON_UNESCAPED_UNICODE); $response->getBody()->write($payload); return $response ->withStatus(403) ->withHeader('Content-Type', 'application/json; charset=utf-8'); } if (AdminCsrf::requiresProtection($request->getMethod()) && !AdminCsrf::verify($request)) { $payload = json_encode([ 'ret' => 0, 'msg' => '页面安全令牌已失效,请刷新页面后重试', ], JSON_UNESCAPED_UNICODE); $response->getBody()->write($payload); return $response ->withStatus(419) ->withHeader('Content-Type', 'application/json; charset=utf-8'); } return $next($request, $response); } }