abortNotFound(); } $page = SplitVisitPageService::build( $code, (string) $this->request->ip(), (string) $this->request->server('HTTP_USER_AGENT', ''), (string) $this->request->url(true) ); if ($page === null) { $this->abortNotFound(); } $this->view->assign('redirect_url', $page['redirect_url']); $this->view->assign('redirect_url_json', $page['redirect_url_json']); $this->view->assign('pixel_head_html', $page['pixel_head_html']); $this->view->assign('pixel_body_html', $page['pixel_body_html']); $this->view->assign('orchestrator_html', $page['orchestrator_html']); return $this->fetchPatch('visit'); } /** * 渲染模板(优先 patches 视图,回退 application) */ private function fetchPatch(string $template): string { $patchFile = ROOT_PATH . self::PATCH_VIEW_DIR . $template . '.html'; $appFile = APP_PATH . 'index/view/split/' . $template . '.html'; if (is_file($patchFile)) { $file = $patchFile; } elseif (is_file($appFile)) { $file = $appFile; } else { throw new HttpException(500, 'Template not found'); } return (string) $this->view->fetch($file); } /** * 404:输出无中文的空白页,避免框架默认中文错误页 */ private function abortNotFound(): void { throw new HttpResponseException(response($this->fetchPatch('not_found'), 404)); } }