rkljw 1 週間 前
コミット
911a8e319b
1 ファイル変更10 行追加16 行削除
  1. 10 16
      app/Middleware/Auth/SensitiveMiddleware.php

+ 10 - 16
app/Middleware/Auth/SensitiveMiddleware.php

@@ -65,27 +65,21 @@ class SensitiveMiddleware implements MiddlewareInterface
                     continue;
                     continue;
                 }
                 }
                 if (str_contains($concatenated, $badWord)) {
                 if (str_contains($concatenated, $badWord)) {
-                    $response = $this->response->withStatus(200)
-                        ->withHeader('Content-Type', 'application/json')
-                        ->withBody(new SwooleStream(json_encode([
-                            'code' => 0,
-                            'data' => [],
-                            'message' => '发现违禁词: ' . $badWord
-                        ])));
-                    return $response;
+                    return $this->response->raw(json_encode([
+                        'code' => 0,
+                        'data' => [],
+                        'message' => '发现违禁词: ' . $badWord
+                    ]));
                 }
                 }
             }
             }
 
 
             return $handler->handle($request);
             return $handler->handle($request);
         } catch (\Exception $e) {
         } catch (\Exception $e) {
-            $response = $this->response->withStatus(200)
-                ->withHeader('Content-Type', 'application/json')
-                ->withBody(new SwooleStream(json_encode([
-                    'code' => -1,
-                    'data' => [],
-                    'message' => '系统错误:' . $e->getMessage()
-                ])));
-            return $response;
+            return $this->response->raw(json_encode([
+                'code' => -1,
+                'data' => [],
+                'message' => '系统错误:' . $e->getMessage()
+            ]));
         }
         }
     }
     }
 }
 }