Compare commits
5 Commits
8a52e35c94
...
7dae1b0470
Author | SHA1 | Date | |
---|---|---|---|
7dae1b0470 | |||
70e9146212 | |||
6597cbcaca | |||
8accafd615 | |||
f4de7d71bd |
@ -7,7 +7,13 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
@ -37,10 +43,26 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
public function register(): void
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理发现页面找不到之后返回内容
|
||||
*
|
||||
* @param Request $request 获取请求内容
|
||||
* @param Throwable $e 抛出错误
|
||||
* @return Response|JsonResponse|\Symfony\Component\HttpFoundation\Response|RedirectResponse
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function render($request, Throwable $e): Response|JsonResponse|\Symfony\Component\HttpFoundation\Response|RedirectResponse
|
||||
{
|
||||
if ($e instanceof ModelNotFoundException || $e instanceof NotFoundHttpException) {
|
||||
return response()->redirectToRoute('404');
|
||||
}
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,11 @@ public function __construct()
|
||||
$this->data = array_merge($this->data, ['GonganCode' => $data[0]]);
|
||||
}
|
||||
if (Auth::check()) {
|
||||
$this->data = array_merge($this->data,[
|
||||
$this->data = array_merge($this->data, [
|
||||
'userName' => Auth::user()->username,
|
||||
'userEmail' => Auth::user()->email,
|
||||
'userIcon' => Auth::user()->icon]);
|
||||
'userIcon' => Auth::user()->icon,
|
||||
'userAdmin' => Auth::user()->admin]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,6 +64,18 @@ protected function ViewAboutMe(): Factory|View|Application
|
||||
return view('about', $this->data);
|
||||
}
|
||||
|
||||
protected function viewPageNotFounded(): Factory|View|Application
|
||||
{
|
||||
$this->data['webSubTitle'] = '页面未找到';
|
||||
return view('modules.404', $this->data);
|
||||
}
|
||||
|
||||
protected function viewNoPermission(): Factory|View|Application
|
||||
{
|
||||
$this->data['webSubTitle'] = '没有权限';
|
||||
return view('modules.no-permission', $this->data);
|
||||
}
|
||||
|
||||
private function MarkdownToStringReplace(string $dataBase): string
|
||||
{
|
||||
$decodeText = MarkdownExtra::defaultTransform($dataBase);
|
||||
|
@ -8,6 +8,7 @@
|
||||
namespace App\Http;
|
||||
|
||||
use App\Http\Middleware\Authenticate;
|
||||
use App\Http\Middleware\CheckConsoleUser;
|
||||
use App\Http\Middleware\EncryptCookies;
|
||||
use App\Http\Middleware\RedirectIfAuthenticated;
|
||||
use App\Http\Middleware\VerifyCsrfToken;
|
||||
@ -76,6 +77,7 @@ class Kernel extends HttpKernel
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'authConsole' => CheckConsoleUser::class,
|
||||
'auth' => Authenticate::class,
|
||||
'auth.basic' => AuthenticateWithBasicAuth::class,
|
||||
'cache.headers' => SetCacheHeaders::class,
|
||||
|
37
app/Http/Middleware/CheckConsoleUser.php
Normal file
37
app/Http/Middleware/CheckConsoleUser.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||
* https://www.x-lf.com/
|
||||
*/
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CheckConsoleUser
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (Response|RedirectResponse) $next
|
||||
* @return RedirectResponse|Response|string
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response|string|RedirectResponse
|
||||
{
|
||||
if (Auth::check()) {
|
||||
if (Auth::user()->admin == 1) {
|
||||
return $next($request);
|
||||
} else {
|
||||
return redirect()->route('no-permission');
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
}
|
||||
}
|
@ -51,7 +51,7 @@ class="text-black dark:text-white">{{ $blogFriendsCheck }}</b> 条</p>
|
||||
<div class="flex-shrink-0">
|
||||
<img id="Lazy"
|
||||
class="w-10 h-10 p-1 rounded-full ring-2 {{ $blogColor[$blogValue->blogSetColor-1]->colorLightType }}
|
||||
{{ $blogColor[$blogValue->blogSetColor-1]->colorDarkType }} sm:me-4"
|
||||
{{ $blogColor[$blogValue->blogSetColor-1]->colorDarkType }} sm:me-4"
|
||||
src="{{ asset('images/avatar.png') }}" data-src="{{ $blogValue->blogIcon }}"
|
||||
alt="Bordered avatar">
|
||||
</div>
|
||||
@ -108,24 +108,30 @@ class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none
|
||||
</ul>
|
||||
</div>
|
||||
@elseif(!empty($request->search))
|
||||
<a href="{{ route('console.friends-link.list') }}" type="button" class="text-white mt-4 mb-10 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-3 py-2 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"><i class="bi bi-box-arrow-left me-1"></i> 返回友链列表</a>
|
||||
<a href="{{ route('console.friends-link.list') }}" type="button"
|
||||
class="text-white mt-4 mb-10 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-3 py-2 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"><i
|
||||
class="bi bi-box-arrow-left me-1"></i> 返回友链列表</a>
|
||||
@if(!empty($blog))
|
||||
<ul class="divide-y divide-gray-200 dark:divide-gray-700">
|
||||
@foreach($blog as $blogValue)
|
||||
<li class="py-3 sm:py-4">
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="flex-shrink-0">
|
||||
<img id="Lazy" class="w-10 h-10 rounded-full" src="{{ asset('images/avatar.png') }}" data-src="{{ $blogValue->blogIcon }}" alt="Neil image">
|
||||
</div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<p class="text-sm font-bold text-gray-900 truncate dark:text-white">
|
||||
{{ $blogValue->blogName }}
|
||||
</p>
|
||||
<p class="text-sm text-gray-400 truncate dark:text-gray-300">
|
||||
<a href="{{ $blogValue->blogUrl }}" target="_blank">{{ $blogValue->blogUrl }}</a>
|
||||
</p>
|
||||
</div>
|
||||
<a href="?" type="button" class="inline-flex items-center text-base font-semibold text-gray-900 dark:text-white">
|
||||
@foreach($blog as $blogValue)
|
||||
<li class="py-3 sm:py-4">
|
||||
<div class="flex items-center space-x-4">
|
||||
<div class="flex-shrink-0">
|
||||
<img id="Lazy"
|
||||
class="w-10 h-10 p-1 rounded-full ring-2 {{ $blogColor[$blogValue->blogSetColor-1]->colorLightType }}
|
||||
{{ $blogColor[$blogValue->blogSetColor-1]->colorDarkType }} sm:me-4"
|
||||
src="{{ asset('images/avatar.png') }}" data-src="{{ $blogValue->blogIcon }}"
|
||||
alt="Bordered avatar">
|
||||
</div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<p class="text-sm font-bold text-gray-900 truncate dark:text-white">
|
||||
{{ $blogValue->blogName }}
|
||||
</p>
|
||||
<p class="text-sm text-gray-400 truncate dark:text-gray-300">
|
||||
<a href="{{ $blogValue->blogUrl }}" target="_blank">{{ $blogValue->blogUrl }}</a>
|
||||
</p>
|
||||
</div>
|
||||
<a href="?" type="button" class="inline-flex items-center text-base font-semibold text-gray-900 dark:text-white">
|
||||
<a href="{{ route('console.friends-link.edit',$blogValue->id) }}" type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-3 py-2 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
|
||||
<i class="bi bi-pencil"></i>
|
||||
<span class="ps-1">编辑</span>
|
||||
|
@ -46,15 +46,19 @@ class="-m-2.5 inline-flex items-center justify-center rounded-md p-2.5 text-gray
|
||||
<div class="font-medium dark:text-white">
|
||||
<div class="text-right">{{ $userName }}</div>
|
||||
</div>
|
||||
<img id="avatarButton" type="button" data-dropdown-toggle="userDropdown" data-dropdown-placement="bottom-start" class="w-8 h-8 rounded-full cursor-pointer" src="{{ $userIcon }}" alt="">
|
||||
<img id="avatarButton" type="button" data-dropdown-toggle="userDropdown" data-dropdown-placement="bottom-start"
|
||||
class="w-8 h-8 rounded-full cursor-pointer" src="{{ $userIcon }}" alt="">
|
||||
<!-- Dropdown menu -->
|
||||
<div id="userDropdown" class="z-10 hidden bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700 dark:divide-gray-600">
|
||||
<ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="avatarButton">
|
||||
<li>
|
||||
<a href="{{ route('console.dashboard') }}" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
|
||||
<i class="bi bi-person-rolodex"></i>
|
||||
<span class="flex-1 ml-3 whitespace-nowrap">管理员</span>
|
||||
</a>
|
||||
@if($userAdmin)
|
||||
<a href="{{ route('console.dashboard') }}"
|
||||
class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
|
||||
<i class="bi bi-person-circle"></i>
|
||||
<span class="flex-1 ml-3 whitespace-nowrap">管理员</span>
|
||||
</a>
|
||||
@endif
|
||||
<a href="#" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
|
||||
<i class="bi bi-person-rolodex"></i>
|
||||
<span class="flex-1 ml-3 whitespace-nowrap">个人设置</span>
|
||||
@ -62,7 +66,8 @@ class="-m-2.5 inline-flex items-center justify-center rounded-md p-2.5 text-gray
|
||||
</li>
|
||||
</ul>
|
||||
<div class="py-1">
|
||||
<a href="{{ route('logout') }}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">
|
||||
<a href="{{ route('logout') }}"
|
||||
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">
|
||||
<i class="bi bi-box-arrow-left"></i>
|
||||
<span class="flex-1 ml-3 whitespace-nowrap">登出</span>
|
||||
</a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user