初始化

This commit is contained in:
2026-08-08 18:27:38 +08:00
parent efc150c937
commit 060eb79c09
336 changed files with 24613 additions and 15 deletions
@@ -0,0 +1,84 @@
@extends('admin.layout')
@php $editing = isset($article) && $article; @endphp
@section('title', $editing ? '编辑文章' : '新建文章')
@section('page-title', $editing ? '编辑文章' : '新建文章')
@section('content')
<form method="POST" action="{{ $editing ? route('admin.articles.update', $article) : route('admin.articles.store') }}" class="form-card">
@csrf
@if ($editing) @method('PUT') @endif
<div class="field">
<label>标题</label>
<input name="title" class="input" value="{{ old('title', $article?->title ?? '') }}" required>
</div>
<div class="field">
<label>Slug</label>
<input name="slug" class="input" value="{{ old('slug', $article?->slug ?? '') }}" required>
</div>
<div class="field">
<label>分类</label>
<select name="category_id" class="select">
<option value="">无分类</option>
@foreach ($categories as $c)
<option value="{{ $c->id }}" @selected(old('category_id', $article?->category_id) == $c->id)>{{ $c->name }}</option>
@endforeach
</select>
</div>
<div class="field">
<label>作者</label>
<input name="author" class="input" value="{{ old('author', $article?->author ?? '') }}">
</div>
<div class="field">
<label>摘要</label>
<input name="summary" class="input" value="{{ old('summary', $article?->summary ?? '') }}">
</div>
<div class="field">
<label>正文(富文本)</label>
<x-rich-editor name="body" :value="old('body', $article?->body ?? '')" />
</div>
<div class="field">
<label>封面图(可选,支持上传)</label>
<input type="file" id="cover-file" accept="image/*" style="margin-bottom:8px;">
<div style="display:flex; gap:8px; align-items:center;">
<input name="cover" id="cover-url" class="input" style="flex:1;" value="{{ old('cover', $article?->cover ?? '') }}" placeholder="图片地址(可上传或粘贴 URL">
<button type="button" class="btn" onclick="uploadFile('cover')">上传</button>
</div>
<p class="form-hint">仅「专题报道」版式会使用封面图。支持 jpg/png/gif/webp,单张 5MB。</p>
</div>
<div class="field">
<label>状态</label>
<select name="status" class="select">
<option value="approved" @selected(old('status', $article?->status ?? 'approved') === 'approved')>已发布</option>
<option value="draft" @selected(old('status', $article?->status ?? '') === 'draft')>草稿</option>
</select>
</div>
<div class="field">
<label>版式模板</label>
<select name="template" class="select">
@foreach (App\Models\Article::TEMPLATES as $key => $label)
<option value="{{ $key }}" @selected(old('template', $article?->template ?? 'standard') === $key)>{{ $label }}</option>
@endforeach
</select>
</div>
<div class="field">
<label>SEO 标题(留空则使用文章标题)</label>
<input name="seo_title" class="input" value="{{ old('seo_title', $article?->seo_title ?? '') }}">
</div>
<div class="field">
<label>SEO 描述(留空则使用摘要)</label>
<input name="seo_description" class="input" value="{{ old('seo_description', $article?->seo_description ?? '') }}">
</div>
<div class="field">
<label>发布时间</label>
<input type="date" name="published_at" class="input" value="{{ old('published_at', $article?->published_at?->format('Y-m-d')) }}">
</div>
<div class="form-actions">
<button class="btn btn-primary">保存</button>
<a href="{{ route('admin.articles.index') }}" class="btn">取消</a>
</div>
</form>
@endsection
@@ -0,0 +1,39 @@
@extends('admin.layout')
@section('title', '文章管理')
@section('page-title', '文章管理')
@section('actions')
<a href="{{ route('admin.articles.create') }}" class="btn btn-primary btn-sm"><x-icon name="plus" :size="16"/> 新建文章</a>
@endsection
@section('content')
<table class="data-table">
<thead><tr><th>标题</th><th>分类</th><th>状态</th><th>发布时间</th><th>操作</th></tr></thead>
<tbody>
@forelse ($articles as $a)
<tr>
<td>{{ $a->title }}</td>
<td>{{ $a->category?->name ?: '-' }}</td>
<td>
@if ($a->status === 'approved') 已发布
@elseif ($a->status === 'pending') <span class="text-warning">待审</span>
@elseif ($a->status === 'rejected') <span class="text-danger">已驳回</span>
@else 草稿
@endif
</td>
<td class="muted">{{ $a->published_at?->format('Y-m-d') ?: '-' }}</td>
<td class="row-actions">
<a href="{{ route('admin.articles.edit', $a) }}" class="btn btn-sm"><x-icon name="edit" :size="16"/></a>
<form method="POST" action="{{ route('admin.articles.destroy', $a) }}" onsubmit="return confirm('确认删除该文章?')">
@csrf @method('DELETE')
<button class="btn btn-sm btn-danger"><x-icon name="trash" :size="16"/></button>
</form>
</td>
</tr>
@empty
<tr><td colspan="5" class="muted">暂无文章。</td></tr>
@endforelse
</tbody>
</table>
{{ $articles->links('pagination::bootstrap-5') }}
@endsection