Files
ai-web/resources/views/public/news/index.blade.php
2026-02-12 13:06:12 +08:00

137 lines
7.1 KiB
PHP

@extends('layouts.site')
@section('page_class', 'page-news')
@section('title', 'AI 资讯文章 - AIWeb')
@section('meta_description', '追踪 AI 行业动态、模型发布与产品更新,快速获取高价值信息。')
@section('canonical', route('news.index'))
@section('content')
@php
$icons = ['bi-newspaper', 'bi-lightning', 'bi-megaphone', 'bi-globe', 'bi-broadcast', 'bi-bookmark-star'];
$resetCategoryFilters = array_filter([
'q' => $filters['q'] ?? null,
], fn ($value) => $value !== null && $value !== '');
@endphp
<div class="channel-layout">
<aside class="channel-sidebar" aria-label="资讯分类">
<div class="channel-brand"><span class="channel-brand-mark">AI</span>AI资讯库</div>
<nav class="channel-links">
<a class="channel-link @if(empty($filters['category'])) active @endif" href="{{ route('news.index', $resetCategoryFilters) }}">
<i class="bi bi-stars"></i>
<span>全部资讯</span>
<small>{{ $newsStats['total'] ?? 0 }}</small>
</a>
@foreach($categories as $index => $category)
<a class="channel-link @if(($filters['category'] ?? '') === $category->slug) active @endif" href="{{ route('news.index', array_filter(array_merge($filters, ['category' => $category->slug]))) }}">
<i class="bi {{ $icons[$index % count($icons)] }}"></i>
<span>{{ $category->name }}</span>
<small>{{ $category->published_articles_count ?? 0 }}</small>
</a>
@endforeach
</nav>
</aside>
<section class="channel-main">
<x-portal.top-nav active="news" status-label="资讯总量" :status-value="$newsStats['total'] ?? 0" />
<nav class="channel-mobile-nav" aria-label="移动分类导航">
<a class="channel-link @if(empty($filters['category'])) active @endif" href="{{ route('news.index', $resetCategoryFilters) }}">
<i class="bi bi-stars"></i>
<span>全部资讯</span>
<small>{{ $newsStats['total'] ?? 0 }}</small>
</a>
@foreach($categories as $index => $category)
<a class="channel-link @if(($filters['category'] ?? '') === $category->slug) active @endif" href="{{ route('news.index', array_filter(array_merge($filters, ['category' => $category->slug]))) }}">
<i class="bi {{ $icons[$index % count($icons)] }}"></i>
<span>{{ $category->name }}</span>
<small>{{ $category->published_articles_count ?? 0 }}</small>
</a>
@endforeach
</nav>
<section class="channel-hero">
<span class="channel-chip">AIWEB.CN</span>
<h1 class="channel-title">AI资讯文章</h1>
<p class="channel-subtitle">聚合行业快讯与深度内容,帮助你快速判断趋势与机会窗口。</p>
<form class="channel-search" method="get" action="{{ route('news.index') }}" role="search" aria-label="搜索 AI 资讯">
<input type="search" name="q" value="{{ $filters['q'] ?? '' }}" placeholder="搜索资讯标题或关键词,如 开源 / 融资 / 发布" autocomplete="off" spellcheck="false">
<select name="category" aria-label="按分类筛选">
<option value="">全部分类</option>
@foreach($categories as $category)
<option value="{{ $category->slug }}" @selected(($filters['category'] ?? '') === $category->slug)>{{ $category->name }}</option>
@endforeach
</select>
<input type="text" value="按发布时间排序" readonly aria-label="排序方式">
<a class="btn btn-outline-secondary" href="{{ route('news.index') }}">重置</a>
<button class="btn btn-primary" type="submit"><i class="bi bi-search"></i> 搜索</button>
</form>
<x-portal.stat-grid
:stats="[
['label' => '资讯总量', 'value' => $newsStats['total'] ?? 0],
['label' => '今日新增', 'value' => $newsStats['today'] ?? 0],
['label' => '高可信来源', 'value' => $newsStats['high_source'] ?? 0],
['label' => '7天更新', 'value' => $newsStats['updated_7d'] ?? 0],
]"
/>
</section>
<section class="channel-body">
<section class="channel-panel">
<header class="channel-panel-head">
<h2 class="channel-panel-title">资讯列表</h2>
</header>
@if($items->isNotEmpty())
<div class="channel-list">
@foreach($items as $article)
<article class="entity-card">
<a class="entity-title" href="{{ route('news.show', $article->slug) }}">{{ $article->title }}</a>
<div class="entity-meta">{{ $article->source_level?->label() ?? '来源未知' }} · {{ $article->published_at?->format('Y-m-d H:i') }}</div>
<p class="entity-desc line-clamp-2">{{ $article->excerpt }}</p>
<div class="d-flex align-items-center justify-content-between gap-2">
@if($article->is_stale)
<span class="chip">可能过期</span>
@else
<span class="chip">已验证</span>
@endif
<a class="btn btn-sm btn-outline-primary" href="{{ route('news.show', $article->slug) }}">阅读</a>
</div>
</article>
@endforeach
</div>
<div class="mt-3">{{ $items->links() }}</div>
@else
<p class="text-muted-soft mb-0">暂无资讯数据</p>
@endif
</section>
<aside class="channel-list">
<x-portal.side-list-section
title="热门模型"
:more-url="route('models.index')"
:items="$sidebarModels"
:item-url="fn ($model) => route('models.show', $model->slug)"
:item-title="fn ($model) => $model->name"
:item-meta="fn ($model) => '综合 '.$model->total_score.' 分'"
empty-text="暂无数据"
/>
<x-portal.side-list-section
title="推荐教程"
:more-url="route('guides.index')"
:items="$sidebarGuides"
:item-url="fn ($guide) => route('guides.show', $guide->slug)"
:item-title="fn ($guide) => $guide->title"
:item-meta="fn ($guide) => $guide->difficulty"
empty-text="暂无教程"
/>
</aside>
</section>
</section>
</div>
@endsection