Files
ai-web/resources/views/admin/tools/form.blade.php
jiangdong.cheng a795b2c896
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
优化功能
2026-02-12 17:10:36 +08:00

198 lines
11 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@extends('layouts.admin')
@section('title', $item->exists ? '编辑工具' : '新建工具')
@section('head')
@include('admin.partials.modern-form-head')
@endsection
@section('content')
<div class="card modern-form-card">
<div class="card-header d-flex justify-content-between align-items-center">
<h3 class="card-title mb-0">{{ $item->exists ? '编辑工具' : '新建工具' }}</h3>
@if($item->exists)
<div class="d-flex gap-2">
<form method="post" action="{{ route('admin.tools.publish', $item) }}">
@csrf
<button class="btn btn-sm btn-success" type="submit">发布</button>
</form>
<form method="post" action="{{ route('admin.tools.mark-stale', $item) }}">
@csrf
<button class="btn btn-sm btn-warning" type="submit">标记失效</button>
</form>
</div>
@endif
</div>
<div class="card-body">
<p class="required-tip"><span class="required-star">*</span> 为必填项</p>
<form method="post" action="{{ $submitRoute }}" class="row g-3">
@csrf
@if($method !== 'POST') @method($method) @endif
<div class="col-12">
<section class="form-section">
<h4 class="form-section-title">基础信息</h4>
<p class="form-section-subtitle">填写工具的核心资料,便于检索、筛选和展示。</p>
<div class="row g-3">
<div class="col-md-6 field-required">
<label class="form-label">工具名称<span class="required-star">*</span></label>
<input class="form-control" name="name" value="{{ old('name', $item->name) }}" required>
<div class="form-hint">建议使用产品全名,避免缩写歧义。</div>
</div>
<div class="col-md-6 field-required">
<label class="form-label">Slug<span class="required-star">*</span></label>
<input class="form-control" name="slug" value="{{ old('slug', $item->slug) }}" required>
<div class="form-hint">默认自动生成,可手动调整为英文短链。</div>
</div>
<div class="col-md-3">
<label class="form-label">分类</label>
<select class="form-select" name="category_id">
<option value="">未分类</option>
@foreach($categories as $category)
<option value="{{ $category->id }}" @selected((string) old('category_id', $item->category_id) === (string) $category->id)>{{ $category->name }}</option>
@endforeach
</select>
</div>
<div class="col-md-3">
<label class="form-label">来源</label>
<select class="form-select" name="source_id">
<option value=""></option>
@foreach($sources as $source)
<option value="{{ $source->id }}" @selected((string) old('source_id', $item->source_id) === (string) $source->id)>{{ $source->name }}</option>
@endforeach
</select>
</div>
<div class="col-md-3 field-required">
<label class="form-label">价格类型<span class="required-star">*</span></label>
<input class="form-control" name="pricing_type" value="{{ old('pricing_type', $item->pricing_type ?: 'freemium') }}" required>
<div class="form-hint">示例:`free``freemium``paid`</div>
</div>
<div class="col-md-3">
<label class="form-label">平台</label>
<input class="form-control" name="platform" value="{{ old('platform', $item->platform) }}" placeholder="Web / iOS / Android">
</div>
<div class="col-md-3">
<label class="form-label">语言</label>
<input class="form-control" name="language" value="{{ old('language', $item->language) }}" placeholder="中文, English">
</div>
<div class="col-md-3 field-required">
<label class="form-label">状态<span class="required-star">*</span></label>
<select class="form-select" name="status" required>
@foreach($statusOptions as $status)
<option value="{{ $status->value }}" @selected(old('status', $item->status?->value) === $status->value)>{{ $status->value }}</option>
@endforeach
</select>
</div>
<div class="col-md-3 field-required">
<label class="form-label">来源等级<span class="required-star">*</span></label>
<select class="form-select" name="source_level" required>
@foreach(['official' => '官方', 'trusted_media' => '可信媒体', 'community' => '社区', 'unknown' => '未知'] as $value => $label)
<option value="{{ $value }}" @selected(old('source_level', $item->source_level?->value ?? 'unknown') === $value)>{{ $label }}</option>
@endforeach
</select>
</div>
<div class="col-md-3">
<label class="form-label">发布时间</label>
<input class="form-control" type="datetime-local" name="published_at" value="{{ old('published_at', optional($item->published_at)->format('Y-m-d\TH:i')) }}">
</div>
<div class="col-md-6">
<label class="form-label">官网 URL</label>
<input class="form-control" name="official_url" value="{{ old('official_url', $item->official_url) }}" placeholder="https://example.com">
</div>
<div class="col-md-6">
<label class="form-label">Logo URL</label>
<input class="form-control" name="logo_url" value="{{ old('logo_url', $item->logo_url) }}" placeholder="https://example.com/logo.png">
</div>
<div class="col-md-8 field-required">
<label class="form-label">摘要<span class="required-star">*</span></label>
<textarea class="form-control" name="summary" rows="2" required>{{ old('summary', $item->summary) }}</textarea>
<div class="form-hint">用于列表卡片,建议 50-120 字。</div>
</div>
<div class="col-md-4 d-flex flex-column justify-content-end gap-2">
<label class="form-check">
<input class="form-check-input" type="checkbox" name="has_api" value="1" @checked(old('has_api', $item->has_api))>
<span class="form-check-label">提供 API</span>
</label>
<label class="form-check">
<input class="form-check-input" type="checkbox" name="is_stale" value="1" @checked(old('is_stale', $item->is_stale))>
<span class="form-check-label">标记失效</span>
</label>
</div>
</div>
</section>
</div>
<div class="col-12">
<section class="form-section">
<h4 class="form-section-title">内容编辑</h4>
<p class="form-section-subtitle">左侧编辑 Markdown右侧实时预览支持一键上传图片。</p>
@include('admin.partials.markdown-editor', [
'field' => 'description',
'value' => $item->description,
'label' => '详细描述Markdown',
'required' => false,
'rows' => 16,
'previewId' => 'tool-description-preview',
'hint' => '可包含功能亮点、使用场景和注意事项。',
])
</section>
</div>
<div class="col-12">
<details class="advanced-panel">
<summary>高级设置SEO 与补充字段)</summary>
<div class="row g-3 mt-2">
<div class="col-md-6">
<label class="form-label">最后校验时间</label>
<input class="form-control" type="datetime-local" name="last_verified_at" value="{{ old('last_verified_at', optional($item->last_verified_at)->format('Y-m-d\TH:i')) }}">
</div>
<div class="col-md-6">
<label class="form-label">失效说明</label>
<textarea class="form-control" name="stale_note" rows="2">{{ old('stale_note', $item->stale_note) }}</textarea>
</div>
<div class="col-md-6">
<label class="form-label">SEO 标题</label>
<input class="form-control" name="seo_title" value="{{ old('seo_title', $item->seo_title) }}">
</div>
<div class="col-md-6">
<label class="form-label">SEO 描述</label>
<input class="form-control" name="seo_description" value="{{ old('seo_description', $item->seo_description) }}">
</div>
<div class="col-md-6">
<label class="form-label">H1</label>
<input class="form-control" name="h1" value="{{ old('h1', $item->h1) }}">
</div>
<div class="col-md-6">
<label class="form-label">Canonical URL</label>
<input class="form-control" name="canonical_url" value="{{ old('canonical_url', $item->canonical_url) }}" placeholder="https://example.com/tools/slug">
</div>
</div>
</details>
</div>
<div class="col-12">
<div class="editor-sticky-actions">
<small class="text-muted">建议先检查右侧预览,再保存。</small>
<button class="btn btn-primary" type="submit">保存工具</button>
</div>
</div>
</form>
</div>
</div>
@endsection
@section('scripts')
@include('admin.partials.modern-form-scripts')
@endsection