Files
ai-web/resources/views/public/tools/index.blade.php

289 lines
13 KiB
PHP
Raw Normal View History

2026-02-12 10:31:53 +08:00
@extends('layouts.site')
@section('page_class', 'page-tools')
2026-02-12 10:57:53 +08:00
@section('title', 'AI工具集 - AIWeb')
2026-02-12 15:37:49 +08:00
@section('meta_description', 'AI工具集首页按分类分块浏览工具左侧菜单可定位到对应模块。')
2026-02-12 10:31:53 +08:00
@section('canonical', route('tools.index'))
@section('head')
2026-02-16 01:23:58 +08:00
@vite('resources/css/tool_index.css')
2026-02-12 10:31:53 +08:00
@endsection
@section('content')
@php
2026-02-16 01:23:58 +08:00
$icons = ['bi-stars', 'bi-pencil', 'bi-image', 'bi-camera-video', 'bi-briefcase', 'bi-cpu', 'bi-chat-dots', 'bi-code-slash', 'bi-kanban'];
$channelModule = $modules['channel_cards'] ?? null;
$bannerModule = $modules['promo_banners'] ?? null;
$hotModule = $modules['hot_tools'] ?? null;
$latestModule = $modules['latest_tools'] ?? null;
$categoryModule = $modules['category_sections'] ?? null;
$moduleOrder = collect($modules)->sortBy('sort_order')->pluck('module_key')->values();
2026-02-12 17:10:36 +08:00
2026-02-16 01:23:58 +08:00
$channelItems = collect(data_get($channelModule, 'items', []))->take((int) data_get($channelModule, 'limit', 5));
$bannerItems = collect(data_get($bannerModule, 'items', []))->take((int) data_get($bannerModule, 'limit', 2));
2026-02-12 10:31:53 +08:00
@endphp
2026-02-12 10:57:53 +08:00
<div class="tool-home">
<aside class="tool-side" aria-label="工具分类侧边栏">
2026-02-12 15:37:49 +08:00
<div class="tool-side-logo"><span class="tool-side-logo-dot">AI</span>{{ data_get($categoryModule, 'extra.side_title', 'AI工具集') }}</div>
2026-02-12 10:57:53 +08:00
<nav class="tool-side-links">
2026-02-12 17:10:36 +08:00
@if(data_get($channelModule, 'enabled', true) === true)
2026-02-16 01:23:58 +08:00
<a class="tool-side-link" href="#section-channel">
<i class="bi bi-grid"></i>
<span>{{ data_get($channelModule, 'title', '频道卡片') }}</span>
<small>{{ $channelItems->count() }}</small>
</a>
2026-02-12 17:10:36 +08:00
@endif
@if(data_get($bannerModule, 'enabled', true) === true)
2026-02-16 01:23:58 +08:00
<a class="tool-side-link" href="#section-banner">
<i class="bi bi-megaphone"></i>
<span>{{ data_get($bannerModule, 'title', '横幅推荐') }}</span>
<small>{{ $bannerItems->count() }}</small>
</a>
2026-02-12 17:10:36 +08:00
@endif
2026-02-12 15:37:49 +08:00
@if(data_get($hotModule, 'enabled', true) === true)
2026-02-16 01:23:58 +08:00
<a class="tool-side-link" href="#section-hot">
<i class="bi bi-fire"></i>
<span>{{ data_get($hotModule, 'title', '热门工具') }}</span>
<small>{{ $hotTools->count() }}</small>
</a>
2026-02-12 13:06:12 +08:00
@endif
2026-02-12 15:37:49 +08:00
@if(data_get($latestModule, 'enabled', true) === true)
2026-02-16 01:23:58 +08:00
<a class="tool-side-link" href="#section-latest">
<i class="bi bi-clock-history"></i>
<span>{{ data_get($latestModule, 'title', '最新收录') }}</span>
<small>{{ $latestTools->count() }}</small>
</a>
2026-02-12 13:06:12 +08:00
@endif
2026-02-12 15:37:49 +08:00
@if(data_get($categoryModule, 'enabled', true) === true)
2026-02-16 01:23:58 +08:00
@foreach($categorySections as $index => $section)
<a class="tool-side-link" href="#section-{{ $section['slug'] }}">
<i class="bi {{ $icons[$index % count($icons)] }}"></i>
<span>{{ $section['name'] }}</span>
<small>{{ $section['count'] }}</small>
</a>
@endforeach
2026-02-12 13:06:12 +08:00
@endif
2026-02-12 10:31:53 +08:00
</nav>
</aside>
2026-02-12 10:57:53 +08:00
<section class="tool-main">
<section class="tool-hero">
2026-03-09 21:38:02 +08:00
<span class="tool-chip">AIBASE.CN</span>
<h1 class="tool-title">AI工具集</h1>
<p class="tool-sub">10000+精选AI工具集合涵盖写作、图像、视频、编程等多个领域</p>
2026-02-12 10:31:53 +08:00
2026-02-12 10:57:53 +08:00
<form class="tool-search" method="get" action="{{ route('tools.list') }}" role="search" aria-label="站内 AI 工具搜索">
2026-02-12 10:31:53 +08:00
<input type="hidden" name="tab" value="{{ $activeTab }}">
2026-03-09 21:38:02 +08:00
<input type="search" name="q" value="{{ $filters['q'] ?? '' }}" placeholder="输入关键词搜索AI工具写作、图像、自动化" autocomplete="off" spellcheck="false">
2026-02-12 10:31:53 +08:00
<button class="btn btn-primary" type="submit"><i class="bi bi-search"></i> 搜索</button>
</form>
2026-03-09 21:38:02 +08:00
<div class="tool-kpis">
<div class="tool-kpi">
<span class="label">工具总数</span>
<span class="value">{{ $toolStats['total'] }}</span>
</div>
<div class="tool-kpi">
<span class="label">API支持</span>
<span class="value">{{ $toolStats['api'] }}</span>
</div>
<div class="tool-kpi">
<span class="label">免费工具</span>
<span class="value">{{ $toolStats['free'] }}</span>
</div>
<div class="tool-kpi">
<span class="label">7日更新</span>
<span class="value">{{ $toolStats['updated_7d'] }}</span>
</div>
</div>
2026-02-12 10:57:53 +08:00
<nav class="channel-tabs justify-content-center" aria-label="筛选模式">
@foreach($tabOptions as $tab)
2026-02-16 01:23:58 +08:00
<a class="channel-tab @if($activeTab === $tab['key']) active @endif" href="{{ route('tools.index', array_filter(array_merge($filters, ['tab' => $tab['key']]))) }}">{{ $tab['label'] }}</a>
2026-02-12 10:57:53 +08:00
@endforeach
2026-02-12 10:31:53 +08:00
</nav>
</section>
2026-03-09 21:38:02 +08:00
@if(data_get($channelModule, 'enabled', true) === true)
<section id="section-channel" class="tool-section" aria-label="频道卡片">
<header class="tool-section-head">
<h2><i class="bi bi-grid text-primary"></i> {{ data_get($channelModule, 'title', '频道卡片') }}</h2>
</header>
<div class="tool-channel">
<div class="tool-channel-mini">
<a href="{{ route('home') }}"><i class="bi bi-house"></i><br>首页</a>
<a href="{{ route('tools.list') }}"><i class="bi bi-tools"></i><br>工具</a>
<a href="{{ route('models.index') }}"><i class="bi bi-cpu"></i><br>模型</a>
<a href="{{ route('news.index') }}"><i class="bi bi-newspaper"></i><br>资讯</a>
<a href="{{ route('guides.index') }}"><i class="bi bi-journal-code"></i><br>教程</a>
</div>
@forelse($channelItems as $channel)
<a class="tool-channel-card" href="{{ $channel['url'] ?: 'javascript:void(0)' }}" @if(!empty($channel['image_path'])) style="background-image:url('{{ $channel['image_path'] }}');" @endif>
<span>{{ $channel['title'] ?: '频道入口' }}</span>
</a>
@empty
<div class="tool-channel-card"><span>频道入口</span></div>
@endforelse
</div>
</section>
@endif
2026-02-12 15:37:49 +08:00
@foreach($moduleOrder as $moduleKey)
2026-02-16 01:23:58 +08:00
@if($moduleKey === 'promo_banners' && data_get($bannerModule, 'enabled', true) === true)
<section id="section-banner" class="tool-section" aria-label="横幅推荐">
<header class="tool-section-head">
<h2><i class="bi bi-megaphone text-primary"></i> {{ data_get($bannerModule, 'title', '横幅推荐') }}</h2>
<a href="{{ route('tools.list') }}">查看更多</a>
</header>
2026-02-12 17:10:36 +08:00
2026-02-16 01:23:58 +08:00
<div class="tool-banner-row">
@forelse($bannerItems as $banner)
<a class="tool-banner @if($loop->index % 2 === 1) alt @endif" href="{{ $banner['url'] ?: 'javascript:void(0)' }}" @if(!empty($banner['image_path'])) style="background-image:url('{{ $banner['image_path'] }}'); background-size:cover;" @endif>
<b>{{ $banner['title'] ?: '精选推荐' }}</b>
<small>{{ $banner['subtitle'] ?: '查看详情' }}</small>
</a>
@empty
<article class="tool-banner"><b>暂无横幅推荐</b><small>请在后台配置</small></article>
@endforelse
</div>
</section>
@endif
2026-02-12 10:31:53 +08:00
2026-02-16 01:23:58 +08:00
@if($moduleKey === 'hot_tools' && data_get($hotModule, 'enabled', true) === true)
<section id="section-hot" class="tool-section" aria-label="热门工具">
<header class="tool-section-head">
<h2><i class="bi bi-fire text-danger"></i> {{ data_get($hotModule, 'title', '热门工具') }}</h2>
@php($hotMore = data_get($hotModule, 'more_url') ?: route('tools.list', ['tab' => 'recommended']))
<a href="{{ $hotMore }}">查看更多</a>
</header>
<x-portal.tool-grid :tools="$hotTools" />
</section>
@endif
@if($moduleKey === 'latest_tools' && data_get($latestModule, 'enabled', true) === true)
<section id="section-latest" class="tool-section" aria-label="最新收录">
<header class="tool-section-head">
<h2><i class="bi bi-clock-history text-primary"></i> {{ data_get($latestModule, 'title', '最新收录') }}</h2>
@php($latestMore = data_get($latestModule, 'more_url') ?: route('tools.list', ['tab' => 'latest']))
<a href="{{ $latestMore }}">查看更多</a>
</header>
<x-portal.tool-grid :tools="$latestTools" />
</section>
@endif
@if($moduleKey === 'category_sections' && data_get($categoryModule, 'enabled', true) === true)
@foreach($categorySections as $section)
<section id="section-{{ $section['slug'] }}" class="tool-section" aria-label="{{ $section['name'] }}工具">
<header class="tool-section-head">
<h2><i class="bi bi-grid-3x3-gap text-primary"></i> {{ $section['name'] }}</h2>
<a href="{{ route('tools.list', ['category' => $section['slug']]) }}">查看更多</a>
</header>
@if($section['tools']->isNotEmpty())
<x-portal.tool-grid :tools="$section['tools']" />
@else
<p class="text-muted-soft mb-0">该分类暂未收录工具</p>
2026-02-12 15:37:49 +08:00
@endif
2026-02-16 01:23:58 +08:00
</section>
@endforeach
@endif
2026-02-12 10:57:53 +08:00
@endforeach
2026-02-12 10:31:53 +08:00
</section>
</div>
@endsection
2026-02-12 10:57:53 +08:00
2026-02-12 13:06:12 +08:00
@section('scripts')
<script>
(() => {
const links = Array.from(document.querySelectorAll('.tool-side-link[href^="#section-"]'));
2026-02-12 17:10:36 +08:00
const sections = Array.from(document.querySelectorAll('[id^="section-"]'));
2026-02-12 13:06:12 +08:00
if (!links.length || !sections.length || !('IntersectionObserver' in window)) {
return;
}
const setActive = (activeId) => {
links.forEach((link) => {
const id = link.getAttribute('href')?.replace('#', '') || '';
link.classList.toggle('is-active', id === activeId);
});
};
const syncHash = (id) => {
const hash = `#${id}`;
if (window.location.hash !== hash) {
history.replaceState(null, '', hash);
}
};
links.forEach((link) => {
link.addEventListener('click', (event) => {
const id = link.getAttribute('href')?.replace('#', '');
if (!id) {
return;
}
const target = document.getElementById(id);
if (!target) {
return;
}
event.preventDefault();
setActive(id);
syncHash(id);
2026-02-16 01:23:58 +08:00
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
2026-02-12 13:06:12 +08:00
});
});
const observer = new IntersectionObserver((entries) => {
const visible = entries
.filter((entry) => entry.isIntersecting)
.sort((a, b) => b.intersectionRatio - a.intersectionRatio);
if (!visible.length) {
return;
}
const top = visible[0].target;
if (top instanceof HTMLElement) {
setActive(top.id);
syncHash(top.id);
}
}, {
rootMargin: '-18% 0px -64% 0px',
threshold: [0.2, 0.45, 0.7],
});
sections.forEach((section) => observer.observe(section));
if (window.location.hash) {
const hashId = window.location.hash.replace('#', '');
const target = document.getElementById(hashId);
if (target) {
setActive(hashId);
window.requestAnimationFrame(() => {
2026-02-16 01:23:58 +08:00
target.scrollIntoView({
behavior: 'auto',
block: 'start'
});
2026-02-12 13:06:12 +08:00
});
} else {
setActive(sections[0].id);
syncHash(sections[0].id);
}
} else {
setActive(sections[0].id);
syncHash(sections[0].id);
}
})();
</script>
2026-02-16 01:23:58 +08:00
@endsection