优化界面

This commit is contained in:
jiangdong.cheng
2026-02-12 10:31:53 +08:00
parent aa16c9f8c2
commit a633234239
13 changed files with 1856 additions and 749 deletions

View File

@@ -7,7 +7,6 @@ namespace App\Http\Controllers\Site;
use App\Http\Controllers\Controller;
use App\Models\AiModel;
use App\Models\Article;
use App\Models\Category;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
@@ -30,9 +29,30 @@ class ModelController extends Controller
$builder->where('deployment_mode', (string) $request->string('deployment'));
}
$modalityCounts = AiModel::query()
->published()
->selectRaw('modality, COUNT(*) as aggregate')
->groupBy('modality')
->pluck('aggregate', 'modality');
$modalityOptions = [
['value' => 'text', 'label' => '文本', 'count' => (int) ($modalityCounts['text'] ?? 0)],
['value' => 'multimodal', 'label' => '多模态', 'count' => (int) ($modalityCounts['multimodal'] ?? 0)],
['value' => 'image', 'label' => '图像', 'count' => (int) ($modalityCounts['image'] ?? 0)],
['value' => 'audio', 'label' => '音频', 'count' => (int) ($modalityCounts['audio'] ?? 0)],
];
$modelStats = [
'total' => AiModel::query()->published()->count(),
'multimodal' => AiModel::query()->published()->where('modality', 'multimodal')->count(),
'api' => AiModel::query()->published()->where('deployment_mode', 'api')->count(),
'updated_7d' => AiModel::query()->published()->where('updated_at', '>=', now()->subDays(7))->count(),
];
return view('public.models.index', [
'items' => $builder->orderByDesc('total_score')->paginate(18)->withQueryString(),
'categories' => Category::query()->where('type', 'model')->where('is_active', true)->orderBy('name')->get(),
'modalityOptions' => $modalityOptions,
'modelStats' => $modelStats,
'filters' => $request->only(['q', 'modality', 'deployment']),
'sidebarTools' => \App\Models\Tool::published()->latest('published_at')->limit(6)->get(),
'sidebarNews' => Article::published()->latest('published_at')->limit(6)->get(),