diff --git a/app/admin/controller/system/Log.php b/app/admin/controller/system/Log.php index 3564495..323c227 100644 --- a/app/admin/controller/system/Log.php +++ b/app/admin/controller/system/Log.php @@ -22,6 +22,7 @@ use think\response\Json; */ class Log extends AdminController { + protected array $ignoreLog = ['record']; public function __construct(App $app) { diff --git a/app/admin/middleware/SystemLog.php b/app/admin/middleware/SystemLog.php index 2779bd5..838c761 100644 --- a/app/admin/middleware/SystemLog.php +++ b/app/admin/middleware/SystemLog.php @@ -7,9 +7,11 @@ use app\admin\service\annotation\NodeAnnotation; use app\admin\service\SystemLogService; use app\common\traits\JumpTrait; use app\Request; +use ReflectionClass; use Closure; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\DocParser; +use ReflectionException; class SystemLog { @@ -26,9 +28,13 @@ class SystemLog 'mobile', ]; + /** + * @throws ReflectionException + */ public function handle(Request $request, Closure $next) { - $params = $request->param(); + $response = $next($request); + $params = $request->param(); if (isset($params['s'])) unset($params['s']); foreach ($params as $key => $val) { in_array($key, $this->sensitiveParams) && $params[$key] = "***********"; @@ -39,9 +45,18 @@ class SystemLog if (env('APP_DEBUG')) { trace(['url' => $url, 'method' => $method, 'params' => $params,], 'requestDebugInfo'); } - $response = $next($request); if ($request->isAjax()) { if (in_array($method, ['post', 'put', 'delete'])) { + + $controller = $request->controller(); + if (str_contains($controller, '.')) $controller = str_replace('.', '\\', $controller); + $action = $request->action(); + $controllerClass = 'app\\admin\\controller\\' . $controller; + $classObj = new ReflectionClass($controllerClass); + $properties = $classObj->getDefaultProperties(); + $ignoreLog = $properties['ignoreLog'] ?? []; + if (in_array($action, $ignoreLog)) return $response; + $title = ''; try { $pathInfo = $request->pathinfo();