@php use App\Models\Competition; use Illuminate\Support\Facades\File; $slug = 'hsxt'; try { $resolved = Competition::query() ->whereIn('status', ['published', 'signup_open', 'signup_closed', 'reviewing']) ->orderBy('id') ->value('slug'); if (! is_string($resolved) || trim($resolved) === '') { $resolved = Competition::query()->orderBy('id')->value('slug'); } if (is_string($resolved) && trim($resolved) !== '') { $slug = trim($resolved); } } catch (Throwable) { // 测试环境可能尚未建 competitions 表,回退默认 slug } // 生产 SPA base 为 /admin/(与 ChannelEntryController、Vite BASE_URL 一致) // 资源用根相对路径,避免 APP_URL 写成 https 后证书无效导致图片/样式全部加载失败。 $participantLoginUrl = '/admin/c/'.rawurlencode($slug).'/login'; $audienceLoginUrl = '/admin/c/'.rawurlencode($slug).'/audience/login'; $homeUrl = '/'; $homeEnUrl = '/en'; $participantLoginEnUrl = '/frontend/prototype/login-en.html?role=user'; $audienceLoginEnUrl = '/frontend/prototype/login-en.html?role=audience'; $eventSiteRelative = $eventSiteRelative ?? 'frontend/event-site.html'; $eventSitePath = public_path($eventSiteRelative); abort_unless(File::isFile($eventSitePath), 503, '赛事官网原型 '.$eventSiteRelative.' 不存在'); $html = File::get($eventSitePath); $assetBase = '/frontend/assets'; $html = str_replace( [ 'url("assets/', "url('assets/", 'src="assets/', "src='assets/", 'href="event-site-en.html"', "href='event-site-en.html'", 'href="event-site.html"', "href='event-site.html'", 'href="login.html"', "href='login.html'", 'href="prototype/login-en.html?role=user"', "href='prototype/login-en.html?role=user'", 'href="prototype/login-en.html?role=audience"', "href='prototype/login-en.html?role=audience'", 'href="login-en.html?role=user"', "href='login-en.html?role=user'", 'href="login-en.html?role=audience"', "href='login-en.html?role=audience'", 'href="layout.html?role=user&lang=en"', "href='layout.html?role=user&lang=en'", 'href="layout.html?role=audience&lang=en"', "href='layout.html?role=audience&lang=en'", 'href="layout.html?role=user&lang=en"', "href='layout.html?role=user&lang=en'", 'href="layout.html?role=audience&lang=en"', "href='layout.html?role=audience&lang=en'", 'href="layout.html?role=audience"', "href='layout.html?role=audience'", ], [ 'url("'.$assetBase.'/', "url('".$assetBase.'/', 'src="'.$assetBase.'/', "src='".$assetBase.'/', 'href="'.$homeEnUrl.'"', "href='".$homeEnUrl."'", 'href="'.$homeUrl.'"', "href='".$homeUrl."'", 'href="'.$participantLoginUrl.'"', "href='".$participantLoginUrl."'", 'href="'.$participantLoginEnUrl.'"', "href='".$participantLoginEnUrl."'", 'href="'.$audienceLoginEnUrl.'"', "href='".$audienceLoginEnUrl."'", 'href="'.$participantLoginEnUrl.'"', "href='".$participantLoginEnUrl."'", 'href="'.$audienceLoginEnUrl.'"', "href='".$audienceLoginEnUrl."'", 'href="'.$participantLoginEnUrl.'"', "href='".$participantLoginEnUrl."'", 'href="'.$audienceLoginEnUrl.'"', "href='".$audienceLoginEnUrl."'", 'href="'.$participantLoginEnUrl.'"', "href='".$participantLoginEnUrl."'", 'href="'.$audienceLoginEnUrl.'"', "href='".$audienceLoginEnUrl."'", 'href="'.$audienceLoginUrl.'"', "href='".$audienceLoginUrl."'", ], $html ); if (! empty($publicSourceCode)) { $script = ''; $html = preg_replace('/<\/head>/i', $script."\n", $html, 1) ?? ($html.$script); } @endphp {!! $html !!}