From b2b1693a2f494f8e244b92303876545a4c56ca8b Mon Sep 17 00:00:00 2001 From: Wisp X <1591788658@qq.com> Date: Wed, 17 Aug 2022 10:28:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=91=8A=E6=94=AF=E6=8C=81=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E6=89=93=E5=BC=80=20(Closed=20#504)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Providers/AppServiceProvider.php | 5 ++++- resources/views/common/notice.blade.php | 11 ++++++++--- resources/views/layouts/header.blade.php | 5 ++--- resources/views/layouts/notice.blade.php | 15 +++++++++++++++ resources/views/welcome.blade.php | 5 ++--- 5 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 resources/views/layouts/notice.blade.php diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2929342a..b96eccfb 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -46,7 +46,10 @@ class AppServiceProvider extends ServiceProvider View::composer('*', function (\Illuminate\View\View $view) { /** @var Group $group */ $group = Auth::check() ? Auth::user()->group : Group::query()->where('is_guest', true)->first(); - $view->with('_group', $group); + $view->with([ + '_group' => $group, + '_is_notice' => strip_tags(Utils::config(ConfigKey::SiteNotice)), + ]); }); } } diff --git a/resources/views/common/notice.blade.php b/resources/views/common/notice.blade.php index e4d868cd..e0fd2935 100644 --- a/resources/views/common/notice.blade.php +++ b/resources/views/common/notice.blade.php @@ -1,4 +1,4 @@ -@if(strip_tags(\App\Utils::config(\App\Enums\ConfigKey::SiteNotice))) +@if($_is_notice)
@@ -12,10 +12,15 @@ @push('scripts') diff --git a/resources/views/layouts/header.blade.php b/resources/views/layouts/header.blade.php index 5efb9b86..56506eb2 100644 --- a/resources/views/layouts/header.blade.php +++ b/resources/views/layouts/header.blade.php @@ -7,9 +7,8 @@ @yield('title', \App\Utils::config(\App\Enums\ConfigKey::AppName))
- @if($_group->strategies->isNotEmpty()) - @include('layouts.strategies') - @endif + @includeWhen($_is_notice, 'layouts.notice') + @includeWhen($_group->strategies->isNotEmpty(), 'layouts.strategies') @include('layouts.user-nav')
diff --git a/resources/views/layouts/notice.blade.php b/resources/views/layouts/notice.blade.php new file mode 100644 index 00000000..d4a0667a --- /dev/null +++ b/resources/views/layouts/notice.blade.php @@ -0,0 +1,15 @@ +@if($_is_notice) + + @push('scripts') + + @endpush +@endif diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index c4cb875a..228a5205 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -10,9 +10,8 @@ {{ \App\Utils::config(\App\Enums\ConfigKey::AppName) }}
- @if($_group->strategies->isNotEmpty()) - @include('layouts.strategies') - @endif + @includeWhen($_is_notice, 'layouts.notice') + @includeWhen($_group->strategies->isNotEmpty(), 'layouts.strategies') @if(Auth::check()) @include('layouts.user-nav')