Files
ai-web/resources/views/admin/settings/show.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

233 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', '首页配置 - '.$module->name)
@section('head')
@include('admin.partials.modern-form-head')
@include('admin.partials.modern-index-head')
@endsection
@section('page_subtitle', '模块配置与条目列表已拆分,支持新增与单条编辑。')
@section('page_actions')
<a class="btn btn-outline-secondary" href="{{ route('admin.settings.index') }}">返回模块列表</a>
@endsection
@section('content')
<div class="card modern-index-toolbar mb-3">
<div class="card-body d-flex flex-wrap gap-2">
@foreach($moduleNav as $navItem)
<a
class="btn btn-sm {{ $navItem->id === $module->id ? 'btn-primary' : 'btn-outline-primary' }}"
href="{{ route('admin.settings.show', $navItem) }}"
>
{{ $navItem->name }}
</a>
@endforeach
</div>
</div>
<div class="card modern-form-card mb-3">
<div class="card-header">
<h3 class="card-title mb-0">模块信息</h3>
</div>
<div class="card-body">
<p class="required-tip"><span class="required-star">*</span> 为必填项</p>
<form method="post" action="{{ route('admin.settings.update', $module) }}" class="row g-3">
@csrf
@method('put')
<div class="col-md-4 field-required">
<label class="form-label">模块名称<span class="required-star">*</span></label>
<input type="text" class="form-control" name="name" value="{{ old('name', $module->name) }}" required>
</div>
<div class="col-md-4">
<label class="form-label">显示标题</label>
<input type="text" class="form-control" name="title" value="{{ old('title', $module->title) }}">
</div>
<div class="col-md-4">
<label class="form-label">副标题</label>
<input type="text" class="form-control" name="subtitle" value="{{ old('subtitle', $module->subtitle) }}">
</div>
<div class="col-md-3">
<label class="form-label">模块键名</label>
<input type="text" class="form-control" value="{{ $module->module_key }}" disabled>
</div>
<div class="col-md-3">
<label class="form-label">排序</label>
<input type="number" min="0" max="9999" class="form-control" name="sort_order" value="{{ old('sort_order', $module->sort_order) }}">
</div>
<div class="col-md-3">
<label class="form-label">数量上限</label>
<input type="number" min="1" max="30" class="form-control" name="limit" value="{{ old('limit', $module->limit) }}">
</div>
<div class="col-md-3 d-flex align-items-end">
<label class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" name="enabled" value="1" @checked(old('enabled', $module->enabled))>
<span class="form-check-label">启用模块</span>
</label>
</div>
<div class="col-md-3">
<label class="form-label">更多链接类型</label>
@php($moduleLinkType = old('more_link_type', $module->more_link_type))
<select class="form-select" name="more_link_type">
<option value="" @selected($moduleLinkType === null || $moduleLinkType === '')></option>
<option value="route" @selected($moduleLinkType === 'route')>内部路由</option>
<option value="url" @selected($moduleLinkType === 'url')>自定义 URL</option>
</select>
</div>
<div class="col-md-9">
<label class="form-label">更多链接目标</label>
<input type="text" class="form-control" name="more_link_target" value="{{ old('more_link_target', $module->more_link_target) }}" placeholder="如 tools.list 或 https://example.com" list="module-route-options">
</div>
@php($moduleExtra = old('extra', $module->extra ?? []))
<div class="col-md-6">
<label class="form-label">侧栏标题</label>
<input type="text" class="form-control" name="extra[side_title]" value="{{ data_get($moduleExtra, 'side_title') }}">
</div>
<div class="col-md-6">
<label class="form-label">侧栏副标题</label>
<input type="text" class="form-control" name="extra[side_subtitle]" value="{{ data_get($moduleExtra, 'side_subtitle') }}">
</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>
<div class="card modern-form-card mb-3">
<div class="card-header">
<h3 class="card-title mb-0">新增条目</h3>
</div>
<div class="card-body">
<form method="post" action="{{ route('admin.settings.items.store', $module) }}" class="row g-3">
@csrf
<div class="col-md-3">
<label class="form-label">标题</label>
<input type="text" class="form-control" name="title" placeholder="条目标题">
</div>
<div class="col-md-3">
<label class="form-label">副标题</label>
<input type="text" class="form-control" name="subtitle" placeholder="条目副标题">
</div>
<div class="col-md-3">
<label class="form-label">排序</label>
<input type="number" min="0" max="9999" class="form-control" name="sort_order" value="{{ (($module->items->max('sort_order') ?? 0) + 10) }}">
</div>
<div class="col-md-3 d-flex align-items-end">
<label class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" name="enabled" value="1" checked>
<span class="form-check-label">启用条目</span>
</label>
</div>
<div class="col-md-6">
<label class="form-label">图片路径(/storage/...</label>
<div class="input-group">
<input type="text" class="form-control" name="image_path" id="new-item-image-{{ $module->id }}" placeholder="/storage/markdown-images/...">
<button class="btn btn-outline-primary js-md-upload-btn" type="button" data-target="#new-item-image-{{ $module->id }}">上传</button>
</div>
</div>
<div class="col-md-3">
<label class="form-label">链接类型</label>
<select class="form-select" name="link_type">
<option value="route">内部路由</option>
<option value="url">自定义 URL</option>
</select>
</div>
<div class="col-md-3">
<label class="form-label">链接目标</label>
<input type="text" class="form-control" name="link_target" placeholder="如 tools.list 或 https://example.com" list="module-route-options">
</div>
<div class="col-12">
<div class="text-muted small mb-2">可选内部路由:
@foreach($routeOptions as $option)
<code class="me-1">{{ $option['value'] }}</code>
@endforeach
</div>
<button class="btn btn-outline-primary" type="submit">新增条目</button>
</div>
</form>
</div>
</div>
<div class="card modern-index-card">
<div class="card-header d-flex align-items-center justify-content-between">
<h3 class="card-title mb-0">条目列表</h3>
<small class="text-muted"> {{ number_format($module->items->count()) }} </small>
</div>
<div class="table-responsive">
<table class="table table-vcenter card-table modern-index-table">
<thead>
<tr>
<th>标题</th>
<th>链接</th>
<th>图片</th>
<th>状态</th>
<th>排序</th>
<th class="text-end">操作</th>
</tr>
</thead>
<tbody>
@forelse($module->items as $item)
<tr>
<td>
<div class="modern-index-title">{{ $item->title ?: '-' }}</div>
<div class="modern-index-summary">{{ $item->subtitle ?: '-' }}</div>
</td>
<td>
<div><span class="badge bg-indigo-lt text-indigo-fg">{{ $item->link_type }}</span></div>
<div class="modern-index-summary">{{ $item->link_target ?: '-' }}</div>
</td>
<td>
@if(!empty($item->image_path))
<img src="{{ $item->image_path }}" alt="item image" style="width: 88px; height: 48px; object-fit: cover; border-radius: .45rem; border: 1px solid #dbe5f4;">
@else
<span class="text-muted"></span>
@endif
</td>
<td>
@if($item->enabled)
<span class="badge bg-green-lt text-green-fg">启用</span>
@else
<span class="badge bg-secondary-lt">停用</span>
@endif
</td>
<td>{{ (int) $item->sort_order }}</td>
<td class="text-end">
<a class="btn btn-sm btn-outline-primary" href="{{ route('admin.settings.items.edit', ['module' => $module, 'item' => $item]) }}">修改</a>
<form method="post" action="{{ route('admin.settings.items.destroy', ['module' => $module, 'item' => $item]) }}" class="d-inline-block" onsubmit="return confirm('确认删除该条目?')">
@csrf
@method('delete')
<button class="btn btn-sm btn-outline-danger" type="submit">删除</button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="text-center text-muted py-5">当前模块暂无条目,请先新增。</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
<datalist id="module-route-options">
@foreach($routeOptions as $option)
<option value="{{ $option['value'] }}">{{ $option['name'] }}</option>
@endforeach
</datalist>
@endsection