Skip to content

Commit be69801

Browse files
committed
优化首页底部文案
1 parent ac507db commit be69801

File tree

9 files changed

+139
-6
lines changed

9 files changed

+139
-6
lines changed

app/Http/Controllers/Admin/SettingsController.php

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Http\Controllers\Controller;
66
use App\Http\Requests\Admin\GeneralSettingsRequest;
7+
use App\Settings\AppSettings;
78
use App\Settings\GeneralSettings;
89
use Illuminate\Http\Request;
910

@@ -24,4 +25,19 @@ public function updateGeneral(GeneralSettingsRequest $request, GeneralSettings $
2425

2526
return back()->with('success', '修改基础设置成功!');
2627
}
28+
29+
public function editApp(AppSettings $settings)
30+
{
31+
return view('admin.settings.app', compact('settings'));
32+
}
33+
34+
public function updateApp(Request $request, AppSettings $settings)
35+
{
36+
$settings->fill($request->only([
37+
'copyright',
38+
]));
39+
$settings->save();
40+
41+
return back()->with('success', '修改站点设置成功!');
42+
}
2743
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace App\Http\ViewComposers;
4+
5+
use App\Models\User;
6+
use App\Settings\AppSettings;
7+
use Illuminate\View\View;
8+
9+
class AppSettingComposer
10+
{
11+
public function compose(View $view)
12+
{
13+
$settings = app(AppSettings::class);
14+
$view->with('appSetting', $settings);
15+
}
16+
}

app/Providers/ViewServiceProvider.php

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Providers;
44

5+
use App\Http\ViewComposers\AppSettingComposer;
56
use App\Http\ViewComposers\FilterUserComposer;
67
use Illuminate\Support\Facades\View;
78
use Illuminate\Support\ServiceProvider;
@@ -25,6 +26,7 @@ public function register()
2526
*/
2627
public function boot()
2728
{
29+
View::composer(['home'], AppSettingComposer::class);
2830
View::composer(['admin.records.*', 'admin.feedback.index'], FilterUserComposer::class);
2931
}
3032
}

app/Settings/AppSettings.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
4+
namespace App\Settings;
5+
6+
7+
use Spatie\LaravelSettings\Settings;
8+
9+
class AppSettings extends Settings
10+
{
11+
12+
public string $copyright;
13+
14+
public static function group(): string
15+
{
16+
return 'app';
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Spatie\LaravelSettings\Migrations\SettingsMigration;
4+
5+
class CreateAppSettings extends SettingsMigration
6+
{
7+
public function up(): void
8+
{
9+
$this->migrator->add('app.copyright', '');
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@extends('layouts.admin')
2+
@section('title', '系统设置-站点')
3+
4+
@section('breadcrumb')
5+
<nav>
6+
<ul class="flex items-center">
7+
<li>
8+
<a href="{{ route('admin.dashboard') }}" class="text-indigo-600 hover:text-indigo-400">仪表盘</a>
9+
</li>
10+
<li class="px-2 sm:px-3 opacity-50">
11+
/
12+
</li>
13+
<li>
14+
<a href="javascript:;" class="text-indigo-600 hover:text-indigo-400">系统设置</a>
15+
</li>
16+
<li class="px-2 sm:px-3 opacity-50">
17+
/
18+
</li>
19+
<li>
20+
站点
21+
</li>
22+
</ul>
23+
</nav>
24+
@endsection
25+
26+
@section('content')
27+
<div class="flex flex-col rounded shadow-sm bg-white overflow-hidden">
28+
<div class="py-4 px-5 lg:px-6 flex-grow w-full bg-gray-50">
29+
<span class="text-gray-900">站点设置</span>
30+
</div>
31+
<div class="p-5 lg:p-6 flex-grow w-full">
32+
<form action="{{ route('admin.settings.update.app') }}" method="post" class="space-y-6">
33+
<div hidden>
34+
@csrf
35+
@method('put')
36+
</div>
37+
<div class="space-y-1 md:space-y-0 md:flex md:items-center">
38+
<label for="copyright" class="font-semibold md:w-1/5 flex-none md:mr-6 text-right">底部描述</label>
39+
<input type="text" id="copyright" name="copyright" value="{{ old('copyright', $settings->copyright) }}" class="block border border-gray-200 rounded px-3 py-2 leading-6 w-full md:w-3/5 focus:border-indigo-500 focus:ring focus:ring-indigo-500 focus:ring-opacity-50" placeholder="请输入底部描述" />
40+
</div>
41+
<div class="md:w-4/5 ml-auto space-x-2">
42+
<button type="submit" class="inline-flex justify-center items-center space-x-2 border font-semibold focus:outline-none md:ml-6 px-4 py-2 leading-5 text-sm rounded border-indigo-700 bg-indigo-700 text-white hover:text-white hover:bg-indigo-800 hover:border-indigo-800 focus:ring focus:ring-indigo-500 focus:ring-opacity-50 active:bg-indigo-700 active:border-indigo-700">
43+
确认
44+
</button>
45+
</div>
46+
</form>
47+
</div>
48+
</div>
49+
@endsection

resources/views/home.blade.php

+23-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,29 @@
22
@section('title', '首页')
33

44
@section('content')
5-
<div class="flex flex-col items-center justify-center min-h-screen">
6-
<div class="space-y-4 text-center">
7-
<h3 class="text-3xl text-gray-900">识字卡后端 API </h3>
8-
<a href="{{ route('admin.dashboard') }}" class="inline-flex justify-center items-center space-x-2 border font-semibold focus:outline-none md:ml-2 px-3 py-2 leading-5 text-sm rounded border-indigo-700 bg-indigo-700 text-white hover:text-white hover:bg-indigo-800 hover:border-indigo-800 focus:ring focus:ring-indigo-500 focus:ring-opacity-50 active:bg-indigo-700 active:border-indigo-700">
9-
后台登录
10-
</a>
5+
<div class="flex-1 flex items-center justify-center">
6+
<div class="max-w-6xl mx-auto px-4 lg:px-8 w-full">
7+
<div class="space-y-4 text-center">
8+
<h3 class="text-3xl text-gray-900">识字卡后端 API </h3>
9+
<a href="{{ route('admin.dashboard') }}" class="inline-flex justify-center items-center space-x-2 border font-semibold focus:outline-none md:ml-2 px-3 py-2 leading-5 text-sm rounded border-indigo-700 bg-indigo-700 text-white hover:text-white hover:bg-indigo-800 hover:border-indigo-800 focus:ring focus:ring-indigo-500 focus:ring-opacity-50 active:bg-indigo-700 active:border-indigo-700">
10+
后台登录
11+
</a>
12+
</div>
1113
</div>
1214
</div>
15+
<footer class="flex flex-none items-center bg-white">
16+
<div class="text-center text-gray-500 flex flex-col md:text-left md:flex-row md:justify-between text-sm max-w-6xl mx-auto px-4 lg:px-8 w-full">
17+
<div class="pt-4 pb-1 md:pb-4">
18+
<a href="#" target="_blank" class="font-medium text-indigo-600 hover:text-indigo-400">嘟嘟识字卡</a> © 2021
19+
{!! $appSetting->copyright !!}
20+
</div>
21+
<div class="pb-4 pt-1 md:pt-4 inline-flex items-center justify-center">
22+
<span>由</span>
23+
<a href="#" target="_blank" class="font-medium text-indigo-600 hover:text-indigo-400 mx-1">hipig</a>
24+
<span>设计和编码</span>
25+
<svg class="w-4 h-4 mx-1 text-red-600" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
26+
<path fill-rule="evenodd" d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" clip-rule="evenodd"></path>
27+
</svg> </div>
28+
</div>
29+
</footer>
1330
@endsection

resources/views/partials/admin/sidebar.blade.php

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class="inline-flex justify-center items-center space-x-2 border font-semibold fo
3939
<x-sidebar.group label="系统">
4040
<x-sidebar.item label="系统设置" icon="heroicon-o-cog" :active="if_route_pattern('admin.settings.*')">
4141
<x-sidebar.subitem label="基础" href="{{ route('admin.settings.edit.general') }}" :active="if_route('admin.settings.edit.general')"></x-sidebar.subitem>
42+
<x-sidebar.subitem label="站点" href="{{ route('admin.settings.edit.app') }}" :active="if_route('admin.settings.edit.app')"></x-sidebar.subitem>
4243
</x-sidebar.item>
4344
{{-- <x-sidebar.item label="管理员" icon="heroicon-o-shield-check"></x-sidebar.item>--}}
4445
{{-- <x-sidebar.item label="角色" icon="heroicon-o-lock-closed"></x-sidebar.item>--}}

routes/web.php

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
Route::prefix('settings')->group(function () {
5050
Route::get('general', [Admin\SettingsController::class, 'editGeneral'])->name('settings.edit.general');
5151
Route::put('general', [Admin\SettingsController::class, 'updateGeneral'])->name('settings.update.general');
52+
53+
Route::get('app', [Admin\SettingsController::class, 'editApp'])->name('settings.edit.app');
54+
Route::put('app', [Admin\SettingsController::class, 'updateApp'])->name('settings.update.app');
5255
});
5356

5457
Route::prefix('records')->group(function () {

0 commit comments

Comments
 (0)