页面优化,功能修复
This commit is contained in:
47
app/Http/Controllers/Admin/FeedbackController.php
Normal file
47
app/Http/Controllers/Admin/FeedbackController.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\FeedbackEntry;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FeedbackController extends Controller
|
||||
{
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$builder = FeedbackEntry::query()->latest('id');
|
||||
|
||||
if ($request->filled('type')) {
|
||||
$builder->where('feedback_type', (string) $request->string('type'));
|
||||
}
|
||||
|
||||
if ($request->filled('status')) {
|
||||
$builder->where('status', (string) $request->string('status'));
|
||||
}
|
||||
|
||||
return view('admin.feedback.index', [
|
||||
'items' => $builder->paginate(30)->withQueryString(),
|
||||
'filters' => $request->only(['type', 'status']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateStatus(FeedbackEntry $feedback, Request $request): RedirectResponse
|
||||
{
|
||||
$status = (string) $request->input('status', 'new');
|
||||
if (!in_array($status, ['new', 'reviewing', 'done'], true)) {
|
||||
$status = 'new';
|
||||
}
|
||||
|
||||
$feedback->update(['status' => $status]);
|
||||
|
||||
return redirect()
|
||||
->route('admin.feedback.index')
|
||||
->with('status', '反馈状态已更新');
|
||||
}
|
||||
}
|
||||
|
||||
76
app/Http/Controllers/Admin/SiteSettingController.php
Normal file
76
app/Http/Controllers/Admin/SiteSettingController.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\SiteSetting;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SiteSettingController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
$defaults = $this->defaultModules();
|
||||
$stored = SiteSetting::query()->where('setting_key', 'home_modules')->value('setting_value');
|
||||
|
||||
$modules = $defaults;
|
||||
if (is_array($stored)) {
|
||||
$storedByKey = collect($stored)->keyBy('key');
|
||||
$modules = array_map(function (array $module) use ($storedByKey): array {
|
||||
$saved = $storedByKey->get($module['key']);
|
||||
if (is_array($saved)) {
|
||||
$module['enabled'] = (bool) ($saved['enabled'] ?? true);
|
||||
$module['limit'] = (int) ($saved['limit'] ?? $module['limit']);
|
||||
}
|
||||
|
||||
return $module;
|
||||
}, $defaults);
|
||||
}
|
||||
|
||||
return view('admin.settings.index', [
|
||||
'modules' => $modules,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$payload = [];
|
||||
foreach ($this->defaultModules() as $module) {
|
||||
$key = $module['key'];
|
||||
$payload[] = [
|
||||
'key' => $key,
|
||||
'label' => $module['label'],
|
||||
'enabled' => $request->boolean("modules.{$key}.enabled", true),
|
||||
'limit' => max(1, min(30, (int) $request->input("modules.{$key}.limit", $module['limit']))),
|
||||
];
|
||||
}
|
||||
|
||||
SiteSetting::query()->updateOrCreate(
|
||||
['setting_key' => 'home_modules'],
|
||||
['setting_value' => $payload],
|
||||
);
|
||||
|
||||
return redirect()
|
||||
->route('admin.settings.index')
|
||||
->with('status', '首页模块配置已更新');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{key:string,label:string,enabled:bool,limit:int}>
|
||||
*/
|
||||
private function defaultModules(): array
|
||||
{
|
||||
return [
|
||||
['key' => 'hot_tools', 'label' => '热门工具', 'enabled' => true, 'limit' => 18],
|
||||
['key' => 'latest_tools', 'label' => '最新收录', 'enabled' => true, 'limit' => 18],
|
||||
['key' => 'category_sections', 'label' => '分类分块', 'enabled' => true, 'limit' => 18],
|
||||
['key' => 'channel_cards', 'label' => '频道卡片区', 'enabled' => true, 'limit' => 1],
|
||||
['key' => 'promo_banners', 'label' => '横幅推荐区', 'enabled' => true, 'limit' => 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ class UploadController extends Controller
|
||||
Storage::disk('public')->put($mainPath, $mainBinary);
|
||||
Storage::disk('public')->put($thumbPath, $thumbBinary);
|
||||
|
||||
$mainUrl = Storage::disk('public')->url($mainPath);
|
||||
$thumbUrl = Storage::disk('public')->url($thumbPath);
|
||||
$mainUrl = '/storage/'.ltrim($mainPath, '/');
|
||||
$thumbUrl = '/storage/'.ltrim($thumbPath, '/');
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
|
||||
Reference in New Issue
Block a user