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

133 lines
6.7 KiB
PHP

@extends('layouts.site')
@section('page_class', 'page-guides')
@section('title', 'AI 教程学习 - AIWeb')
@section('meta_description', '从入门到实战的 AI 教程集合,按难度分层学习并落地工作流。')
@section('canonical', route('guides.index'))
@section('content')
@php
$icons = ['bi-book', 'bi-layers', 'bi-rocket'];
$resetDifficultyFilters = 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['difficulty'])) active @endif" href="{{ route('guides.index', $resetDifficultyFilters) }}">
<i class="bi bi-stars"></i>
<span>全部教程</span>
<small>{{ $guideStats['total'] ?? 0 }}</small>
</a>
@foreach($difficultyOptions as $index => $option)
<a class="channel-link @if(($filters['difficulty'] ?? '') === $option['value']) active @endif" href="{{ route('guides.by-topic', $option['value']) }}">
<i class="bi {{ $icons[$index % count($icons)] }}"></i>
<span>{{ $option['label'] }}</span>
<small>{{ $option['count'] }}</small>
</a>
@endforeach
</nav>
</aside>
<section class="channel-main">
<x-portal.top-nav active="guides" status-label="教程总量" :status-value="$guideStats['total'] ?? 0" />
<nav class="channel-mobile-nav" aria-label="移动分类导航">
<a class="channel-link @if(empty($filters['difficulty'])) active @endif" href="{{ route('guides.index', $resetDifficultyFilters) }}">
<i class="bi bi-stars"></i>
<span>全部教程</span>
<small>{{ $guideStats['total'] ?? 0 }}</small>
</a>
@foreach($difficultyOptions as $index => $option)
<a class="channel-link @if(($filters['difficulty'] ?? '') === $option['value']) active @endif" href="{{ route('guides.by-topic', $option['value']) }}">
<i class="bi {{ $icons[$index % count($icons)] }}"></i>
<span>{{ $option['label'] }}</span>
<small>{{ $option['count'] }}</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">按难度分层与场景化路线组织,帮助你稳定构建可复用 AI 工作流。</p>
<form class="channel-search" method="get" action="{{ route('guides.index') }}" role="search" aria-label="搜索 AI 教程">
<input type="search" name="q" value="{{ $filters['q'] ?? '' }}" placeholder="搜索教程标题或关键词,如 提示词 / 自动化 / 数据分析" autocomplete="off" spellcheck="false">
<select name="difficulty" aria-label="按难度筛选">
<option value="">全部难度</option>
@foreach($difficultyOptions as $option)
<option value="{{ $option['value'] }}" @selected(($filters['difficulty'] ?? '') === $option['value'])>{{ $option['label'] }}</option>
@endforeach
</select>
<input type="text" value="按发布时间排序" readonly aria-label="排序方式">
<a class="btn btn-outline-secondary" href="{{ route('guides.index') }}">重置</a>
<button class="btn btn-primary" type="submit"><i class="bi bi-search"></i> 搜索</button>
</form>
<x-portal.stat-grid
:stats="[
['label' => '教程总量', 'value' => $guideStats['total'] ?? 0],
['label' => '入门教程', 'value' => $guideStats['beginner'] ?? 0],
['label' => '进阶教程', 'value' => $guideStats['advanced'] ?? 0],
['label' => '7天更新', 'value' => $guideStats['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="entity-grid">
@foreach($items as $guide)
<article class="entity-card">
<a class="entity-title" href="{{ route('guides.show', $guide->slug) }}">{{ $guide->title }}</a>
<div class="entity-meta">{{ $guide->difficulty }} · {{ $guide->updated_at?->format('Y-m-d') }}</div>
<p class="entity-desc line-clamp-2">{{ $guide->excerpt }}</p>
<div class="d-flex align-items-center justify-content-between gap-2">
<span class="chip">实战教程</span>
<a class="btn btn-sm btn-outline-primary" href="{{ route('guides.show', $guide->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('tools.index')"
:items="$sidebarTools"
:item-url="fn ($tool) => route('tools.show', $tool->slug)"
:item-title="fn ($tool) => $tool->name"
:item-meta="fn ($tool) => $tool->pricing_type"
empty-text="暂无工具"
/>
<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="暂无模型"
/>
</aside>
</section>
</section>
</div>
@endsection