setRequest($request); if ($this->useSystemSettings) { // 检查数据库连接 try { Db::execute('SELECT 1'); } catch (PDOException $e) { return $this->error(mb_convert_encoding($e->getMessage(), 'UTF-8', 'UTF-8,GBK,GB2312,BIG5')); } // IP 检查 $ipCheckResponse = ip_check(null, $request); if ($ipCheckResponse !== null) { return $ipCheckResponse; } // 时区设定 set_timezone(); } // 语言包由 LoadLangPack 中间件加载 return null; } /** * 从 Request 或路由解析控制器路径(如 user/user) * 优先从 $request->controller 解析,否则从 path 解析 */ protected function getControllerPath(WebmanRequest $request): ?string { return get_controller_path($request); } /** * 从 Request 解析应用名(api 或 admin) */ protected function getAppFromRequest(WebmanRequest $request): string { $path = trim($request->path(), '/'); $parts = explode('/', $path); return $parts[0] ?? 'api'; } }