diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 23d4001..ef9cc3a 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -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); + } } diff --git a/app/Http/Controllers/Console/Link.php b/app/Http/Controllers/Console/Link.php index c3f8fc2..9c89b3f 100644 --- a/app/Http/Controllers/Console/Link.php +++ b/app/Http/Controllers/Console/Link.php @@ -12,10 +12,15 @@ use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; +use Illuminate\Http\JsonResponse; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Illuminate\Mail\Message; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Response; +use Illuminate\Support\Facades\Validator; class Link extends Controller { @@ -27,9 +32,476 @@ public function __construct() $this->data = $data->data; } - public function ViewEdit(Request $request, $userId): Application|Factory|View|RedirectResponse + public function apiConsoleAdd(Request $request): JsonResponse + { + // 检查数据 + if (Auth::check()) { + if (Auth::user()->admin) { + // 处理获取数据 + $dataCheck = Validator::make($request->all(), [ + 'userEmail' => 'email', + 'userServerHost' => 'required|string', + 'userBlog' => 'required|string', + 'userUrl' => 'required|regex:#[a-zA-z]+://[^\s]*#', + 'userDescription' => 'required|string', + 'userIcon' => 'required|regex:#[a-zA-z]+://[^\s]*#', + 'checkRssJudge' => 'boolean', + 'userRss' => 'string|regex:#[a-zA-z]+://[^\s]*#', + 'userSelColor' => 'required|int', + 'userLocation' => 'required|string', + ]); + if ($dataCheck->fails()) { + $errorType = array_keys($dataCheck->failed()); + $i = 0; + foreach ($dataCheck->failed() as $valueData) { + $errorInfo[$errorType[$i]] = array_keys($valueData); + if ($i == 0) { + $errorSingle = [ + 'info' => $errorType[$i], + 'need' => $errorInfo[$errorType[$i]], + ]; + } + $i++; + } + $returnData = [ + 'output' => 'DataFormatError', + 'code' => 403, + 'data' => [ + 'message' => '输入内容有错误', + 'errorSingle' => $errorSingle, + 'error' => $errorInfo, + ], + ]; + } else { + if (empty($request->userEmail)) $request->userEmail = null; + if (empty($request->checkRssJudge)) $request->checkRssJudge = 0; + if (empty($request->userRss)) $request->userRss = null; + // 更新数据库 + DB::table('blog_link') + ->insert([ + 'blogOwnEmail' => $request->userEmail, + 'blogServerHost' => $request->userServerHost, + 'blogName' => $request->userBlog, + 'blogUrl' => $request->userUrl, + 'blogDescription' => $request->userDescription, + 'blogIcon' => $request->userIcon, + 'blogRssJudge' => $request->checkRssJudge, + 'blogRSS' => $request->userRss, + 'blogSetColor' => $request->userSelColor, + 'blogLocation' => $request->userLocation, + 'created_at' => date('Y-m-d H:i:s'), + ]); + $returnData = [ + 'output' => 'Success', + 'code' => 200, + 'data' => [ + 'message' => '数据插入成功', + ], + ]; + } + } else { + $returnData = [ + 'output' => 'NoPermission', + 'code' => 403, + 'data' => [ + 'message' => '没有权限', + ], + ]; + } + } else { + $returnData = [ + 'output' => 'PleaseLogin', + 'code' => 403, + 'data' => [ + 'message' => '请登录', + ], + ]; + } + return Response::json($returnData, $returnData['code']); + } + + public function apiConsoleEdit(Request $request): JsonResponse + { + // 检查用户是否登录 + if (Auth::check()) { + if (Auth::user()->admin) { + // 处理获取数据 + $dataCheck = Validator::make($request->all(), [ + 'userId' => 'required|int', + 'userEmail' => 'email', + 'userServerHost' => 'required|string', + 'userBlog' => 'required|string', + 'userUrl' => 'required|regex:#[a-zA-z]+://[^\s]*#', + 'userDescription' => 'required|string', + 'userIcon' => 'required|regex:#[a-zA-z]+://[^\s]*#', + 'checkRssJudge' => 'boolean', + 'userRss' => 'string|regex:#[a-zA-z]+://[^\s]*#', + 'userSelColor' => 'required|int', + 'userLocation' => 'required|string', + ]); + if ($dataCheck->fails()) { + $errorType = array_keys($dataCheck->failed()); + $i = 0; + foreach ($dataCheck->failed() as $valueData) { + $errorInfo[$errorType[$i]] = array_keys($valueData); + if ($i == 0) { + $errorSingle = [ + 'info' => $errorType[$i], + 'need' => $errorInfo[$errorType[$i]], + ]; + } + $i++; + } + $returnData = [ + 'output' => 'DataFormatError', + 'code' => 403, + 'data' => [ + 'message' => '输入内容有错误', + 'errorSingle' => $errorSingle, + 'error' => $errorInfo, + ], + ]; + } else { + if (empty($request->userEmail)) $request->userEmail = null; + if (empty($request->checkRssJudge)) $request->checkRssJudge = 0; + if (empty($request->userRss)) $request->userRss = null; + // 更新数据库 + DB::table('blog_link') + ->where([['id', '=', $request->userId]]) + ->update([ + 'blogOwnEmail' => $request->userEmail, + 'blogServerHost' => $request->userServerHost, + 'blogName' => $request->userBlog, + 'blogUrl' => $request->userUrl, + 'blogDescription' => $request->userDescription, + 'blogIcon' => $request->userIcon, + 'blogRssJudge' => $request->checkRssJudge, + 'blogRSS' => $request->userRss, + 'blogSetColor' => $request->userSelColor, + 'blogLocation' => $request->userLocation, + 'updated_at' => date('Y-m-d H:i:s') + ]); + $returnData = [ + 'output' => 'Success', + 'code' => 200, + 'data' => [ + 'message' => '数据成功更新', + ], + ]; + } + } else { + $returnData = [ + 'output' => 'NoPermission', + 'code' => 403, + 'data' => [ + 'message' => '没有权限', + ], + ]; + } + } else { + $returnData = [ + 'output' => 'PleaseLogin', + 'code' => 403, + 'data' => [ + 'message' => '请登录', + ], + ]; + } + return Response::json($returnData, $returnData['code']); + } + + public function apiConsoleCheck(Request $request): JsonResponse + { + // 检查用户是否登录 + if (Auth::check()) { + if (Auth::user()->admin) { + // 处理获取数据 + $dataCheck = Validator::make($request->all(), [ + 'userId' => 'required|int', + 'userEmail' => 'required|email', + 'userServerHost' => 'required|string', + 'userBlog' => 'required|string', + 'userUrl' => 'required|regex:#[a-zA-z]+://[^\s]*#', + 'userDescription' => 'required|string', + 'userIcon' => 'required|regex:#[a-zA-z]+://[^\s]*#', + 'checkRssJudge' => 'boolean', + 'userRss' => 'string|regex:#[a-zA-z]+://[^\s]*#', + 'userSelColor' => 'required|int', + 'userLocation' => 'required|string', + ]); + if ($dataCheck->fails()) { + $errorType = array_keys($dataCheck->failed()); + $i = 0; + foreach ($dataCheck->failed() as $valueData) { + $errorInfo[$errorType[$i]] = array_keys($valueData); + if ($i == 0) { + $errorSingle = [ + 'info' => $errorType[$i], + 'need' => $errorInfo[$errorType[$i]], + ]; + } + $i++; + } + $returnData = [ + 'output' => 'DataFormatError', + 'code' => 403, + 'data' => [ + 'message' => '输入内容有错误', + 'errorSingle' => $errorSingle, + 'error' => $errorInfo, + ], + ]; + } else { + // 更新数据库 + DB::table('blog_link') + ->where([['id', '=', $request->userId]]) + ->update([ + 'blogOwnEmail' => $request->userEmail, + 'blogServerHost' => $request->userServerHost, + 'blogName' => $request->userBlog, + 'blogUrl' => $request->userUrl, + 'blogDescription' => $request->userDescription, + 'blogIcon' => $request->userIcon, + 'blogRssJudge' => $request->checkRssJudge, + 'blogRSS' => $request->userRss, + 'blogSetColor' => $request->userSelColor, + 'blogLocation' => $request->userLocation, + 'updated_at' => date('Y-m-d H:i:s') + ]); + Mail::send('mail.link-console-verify', $request->all(), function (Message $mail) { + global $request; + $mail->from(env('MAIL_USERNAME'), env('APP_NAME')); + $mail->to($request->userEmail); + $mail->subject(env('APP_NAME') . '-友链审核通过通知'); + }); + $returnData = [ + 'output' => 'Success', + 'code' => 200, + 'data' => [ + 'message' => '数据成功更新', + ], + ]; + } + } else { + $returnData = [ + 'output' => 'NoPermission', + 'code' => 403, + 'data' => [ + 'message' => '没有权限', + ], + ]; + } + } else { + $returnData = [ + 'output' => 'PleaseLogin', + 'code' => 403, + 'data' => [ + 'message' => '请登录', + ], + ]; + } + return Response::json($returnData, $returnData['code']); + } + + public function apiConsoleCheckFail(Request $request): JsonResponse + { + // 检查用户是否登录 + if (Auth::check()) { + if (Auth::user()->admin) { + // 处理获取数据 + $dataCheck = Validator::make($request->all(), [ + 'userId' => 'required|int', + 'sendMail' => 'int', + 'sendReason' => 'string', + ]); + if ($dataCheck->fails()) { + $errorType = array_keys($dataCheck->failed()); + $i = 0; + foreach ($dataCheck->failed() as $valueData) { + $errorInfo[$errorType[$i]] = array_keys($valueData); + if ($i == 0) { + $errorSingle = [ + 'info' => $errorType[$i], + 'need' => $errorInfo[$errorType[$i]], + ]; + } + $i++; + } + $returnData = [ + 'output' => 'DataFormatError', + 'code' => 403, + 'data' => [ + 'message' => '输入内容有错误', + 'errorSingle' => $errorSingle, + 'error' => $errorInfo, + ], + ]; + } else { + // 获取数据 + $this->data['blog'] = DB::table('blog_link') + ->where([['id', '=', $request->userId]]) + ->get() + ->toArray(); + $this->data['reason'] = $request->sendReason; + if (!empty($this->data['blog'][0]->id)) { + // 更新数据库 + DB::table('blog_link') + ->where([['id', '=', $this->data['blog'][0]->id]]) + ->delete(); + if (!empty($request->sendMail) && !empty($this->data['blog'][0]->blogOwnEmail)) { + Mail::send('mail.link-console-refuse-verify', $this->data, function (Message $mail) { + global $request; + $mail->from(env('MAIL_USERNAME'), env('APP_NAME')); + $mail->to($this->data['blog'][0]->blogOwnEmail); + $mail->subject(env('APP_NAME') . '-友链审核未通过通知'); + }); + } + $returnData = [ + 'output' => 'Success', + 'code' => 200, + 'data' => [ + 'message' => '删除成功', + ], + ]; + } else { + $returnData = [ + 'output' => 'NoBlog', + 'code' => 403, + 'data' => [ + 'message' => '没有对应博客序列', + ], + ]; + } + } + } else { + $returnData = [ + 'output' => 'NoPermission', + 'code' => 403, + 'data' => [ + 'message' => '没有权限', + ], + ]; + } + } else { + $returnData = [ + 'output' => 'PleaseLogin', + 'code' => 403, + 'data' => [ + 'message' => '请登录', + ], + ]; + } + return Response::json($returnData, $returnData['code']); + } + + public function apiConsoleDelete(Request $request): JsonResponse + { + // 检查用户是否登录 + if (Auth::check()) { + if (Auth::user()->admin) { + // 处理获取数据 + $dataCheck = Validator::make($request->all(), [ + 'userId' => 'required|int', + 'sendMail' => 'int', + ]); + if ($dataCheck->fails()) { + $errorType = array_keys($dataCheck->failed()); + $i = 0; + foreach ($dataCheck->failed() as $valueData) { + $errorInfo[$errorType[$i]] = array_keys($valueData); + if ($i == 0) { + $errorSingle = [ + 'info' => $errorType[$i], + 'need' => $errorInfo[$errorType[$i]], + ]; + } + $i++; + } + $returnData = [ + 'output' => 'DataFormatError', + 'code' => 403, + 'data' => [ + 'message' => '输入内容有错误', + 'errorSingle' => $errorSingle, + 'error' => $errorInfo, + ], + ]; + } else { + // 获取数据 + $this->data['blog'] = DB::table('blog_link') + ->where([['id', '=', $request->userId]]) + ->get() + ->toArray(); + if (!empty($this->data['blog'][0]->id)) { + // 更新数据库 + DB::table('blog_link') + ->where([['id', '=', $this->data['blog'][0]->id]]) + ->delete(); + if (!empty($request->sendMail) && !empty($this->data['blog'][0]->blogOwnEmail)) { + Mail::send('mail.link-console-delete', $request->all(), function (Message $mail) { + global $request; + $mail->from(env('MAIL_USERNAME'), env('APP_NAME')); + $mail->to($this->data['blog'][0]->blogOwnEmail); + $mail->subject(env('APP_NAME') . '-友链被删除'); + }); + } + $returnData = [ + 'output' => 'Success', + 'code' => 200, + 'data' => [ + 'message' => '删除成功', + ], + ]; + } else { + $returnData = [ + 'output' => 'NoBlog', + 'code' => 403, + 'data' => [ + 'message' => '没有对应博客序列', + ], + ]; + } + } + } else { + $returnData = [ + 'output' => 'NoPermission', + 'code' => 403, + 'data' => [ + 'message' => '没有权限', + ], + ]; + } + } else { + $returnData = [ + 'output' => 'PleaseLogin', + 'code' => 403, + 'data' => [ + 'message' => '请登录', + ], + ]; + } + return Response::json($returnData, $returnData['code']); + } + + protected function viewEdit($userId): Application|Factory|View|RedirectResponse + { + $this->setDataForViewEditAndCheckAdmin($userId); + if ($this->data['blog'][0] != null) { + // 没有查询到执行删除 + $this->data['subDescriptionForLine'] = '友链修改'; + if ($this->data['blog'][0] == null) return Response::redirectTo(route('console.friends-link.list')); + return view('console.friends-link.edit', $this->data); + } else { + return Response::redirectTo(route('console.friends-link.check')); + } + } + + /** + * @param $userId + * @return void + */ + private function setDataForViewEditAndCheckAdmin($userId): void { - // 查找友链 $resultBlog = DB::table('blog_link') ->find($userId); $this->data['blog'] = [ @@ -39,16 +511,35 @@ public function ViewEdit(Request $request, $userId): Application|Factory|View|Re ->orderBy('sort') ->get() ->toArray(); - $this->data['blogColor'] = DB::table('blog_color') + $blogColor = DB::table('blog_color') ->orderBy('id') ->get() ->toArray(); - // 没有查询到执行删除 - if ($this->data['blog'][0] == null) return Response::redirectTo(route('console.friends-link.list')); - return view('console.friends-link.edit', $this->data); + for ($i = 0; !empty($blogColor[$i]->id); $i++) { + $blogColor[$i]->colorDarkType = str_replace('dark:', '', $blogColor[$i]->colorDarkType); + } + $this->data['blogColor'] = $blogColor; } - protected function ViewList(Request $request): Factory|View|Application|RedirectResponse + protected function viewCheckAdmin($userId): View|Factory|Application|RedirectResponse + { + $this->setDataForViewEditAndCheckAdmin($userId); + if ($this->data['blog'][0] != null) { + if ($this->data['blog'][0]->blogLocation == 0) { + // 用户期望位置替换显示 + $this->data['blog'][0]->blogLocation = $this->data['blog'][0]->blogUserLocation;// 没有查询到执行删除 + $this->data['subDescriptionForLine'] = '友链审核'; + if ($this->data['blog'][0] == null) return Response::redirectTo(route('console.friends-link.list')); + return view('console.friends-link.edit', $this->data); + } else { + return Response::redirectTo(route('console.friends-link.check')); + } + } else { + return Response::redirectTo(route('console.friends-link.check')); + } + } + + protected function viewList(Request $request): Factory|View|Application|RedirectResponse { $this->data['request'] = $request; $dataMarge = [ @@ -86,36 +577,62 @@ protected function ViewList(Request $request): Factory|View|Application|Redirect $this->data['blog'] = DB::select("SELECT * FROM xf_index.blog_link WHERE blogName LIKE '%$request->search%' OR blogUrl LIKE '%$request->search%' ORDER BY id"); } $this->data = array_merge($this->data, $dataMarge); + $blogColor = DB::table('blog_color') + ->orderBy('id') + ->get() + ->toArray(); + for ($i = 0; !empty($blogColor[$i]->id); $i++) { + $blogColor[$i]->colorLightType = str_replace('border-', 'ring-', $blogColor[$i]->colorLightType); + $blogColor[$i]->colorDarkType = str_replace('border-', 'ring-', $blogColor[$i]->colorDarkType); + } + $this->data['blogColor'] = $blogColor; return view('console.friends-link.list', $this->data); } - protected function ViewCheck(Request $request): Factory|View|Application + protected function viewCheck(): Factory|View|Application { // 检查是否存在含有未在本站分配位置 $this->data['blog'] = DB::table('blog_link') - ->whereIn('blog_link.blogLocation',[0]) + ->whereIn('blog_link.blogLocation', [0]) + ->orderBy('id', 'desc') ->get() ->toArray(); + $blogColor = DB::table('blog_color') + ->orderBy('id') + ->get() + ->toArray(); + for ($i = 0; !empty($blogColor[$i]->id); $i++) { + $blogColor[$i]->colorLightType = str_replace('border-', 'ring-', $blogColor[$i]->colorLightType); + $blogColor[$i]->colorDarkType = str_replace('border-', 'ring-', $blogColor[$i]->colorDarkType); + } + $this->data['blogColor'] = $blogColor; return view('console.friends-link.check', $this->data); } - protected function ViewAdd(Request $request): Factory|View|Application + protected function viewAdd(): Factory|View|Application { + $this->data['blogSort'] = DB::table('blog_sort') + ->orderBy('sort') + ->get() + ->toArray(); + $blogColor = DB::table('blog_color') + ->orderBy('id') + ->get() + ->toArray(); + for ($i = 0; !empty($blogColor[$i]->id); $i++) { + $blogColor[$i]->colorDarkType = str_replace('dark:', '', $blogColor[$i]->colorDarkType); + } + $this->data['blogColor'] = $blogColor; return view('console.friends-link.add', $this->data); } - protected function ViewSort(): Factory|View|Application + protected function viewSort(): Factory|View|Application { - return view('console.friends-link.sort',$this->data); + return view('console.friends-link.sort', $this->data); } - protected function ViewColor(): Factory|View|Application + protected function viewColor(): Factory|View|Application { - return view('console.friends-link.color',$this->data); - } - - protected function apiConsoleAdd() { - // 检查数据 - + return view('console.friends-link.color', $this->data); } } diff --git a/app/Http/Controllers/DataBase.php b/app/Http/Controllers/DataBase.php index fc73829..bfce5eb 100644 --- a/app/Http/Controllers/DataBase.php +++ b/app/Http/Controllers/DataBase.php @@ -21,6 +21,10 @@ public function __construct() ->toArray(); foreach ($result as $value) { $value->blog_rss_judge ? $value->blog_rss_judge = 1 : $value->blog_rss_judge = 0; + if ($value->blog_sel_color == 8) $value->blog_sel_color = 6; + if ($value->blog_sel_color == 2) $value->blog_sel_color = 8; + if ($value->blog_sel_color == 7) $value->blog_sel_color = 4; + if ($value->blog_sel_color == 5) $value->blog_sel_color = 3; DB::table('blog_link') ->insert([ 'blogName' => $value->blog_name, diff --git a/app/Http/Controllers/Function/Link.php b/app/Http/Controllers/Function/Link.php index 43b2e06..ec89271 100644 --- a/app/Http/Controllers/Function/Link.php +++ b/app/Http/Controllers/Function/Link.php @@ -99,6 +99,8 @@ public function apiCustomAdd(HttpRequest $request): JsonResponse ])->get()->toArray(); if (empty($resultBlog)) { + if (empty($request->checkRssJudge)) $request->checkRssJudge = 0; + if (empty($request->userRss)) $request->userRss = null; // 数据写入数据库 $insertData = DB::table('blog_link') ->insert([ @@ -113,6 +115,7 @@ public function apiCustomAdd(HttpRequest $request): JsonResponse 'blogSetColor' => $request->userSelColor, 'blogRemark' => $request->userRemark, 'blogServerHost' => $request->userServerHost, + 'created_at' => date('Y-m-d H:i:s'), ]); if ($insertData) { // 邮件发送系统 @@ -120,6 +123,12 @@ public function apiCustomAdd(HttpRequest $request): JsonResponse global $request; $mail->from(env('MAIL_USERNAME'), env('APP_NAME')); $mail->to($request->userEmail); + $mail->subject(env('APP_NAME') . '-友链申请成功'); + }); + Mail::send('mail.link-console-add', $request->toArray(), function (Message $mail) { + global $request; + $mail->from(env('MAIL_USERNAME'), env('APP_NAME')); + $mail->to($this->data['sqlEmail']); $mail->subject(env('APP_NAME') . '-友链等待审核通知'); }); // 消息成功通知 @@ -784,16 +793,21 @@ protected function viewEditFriend(HttpRequest $request, $friendId): Application| protected function viewLink(): Factory|View|Application { $this->data['webSubTitle'] = '友链'; - $this->getFriendsLink($this->data); + $this->data['blogLink'] = DB::table('blog_link') + ->whereNotIn('blog_link.blogLocation', [0]) + ->get() + ->toArray(); + $this->data['blogSort'] = DB::table('blog_sort') + ->orderBy('blog_sort.sort') + ->get() + ->toArray(); + $this->data['blogColor'] = DB::table('blog_color') + ->orderBy('id') + ->get() + ->toArray(); return view('function.link', $this->data); } - private function getFriendsLink(array &$data): void - { - $data['blogLink'] = DB::table('blog_link')->whereNotIn('blog_link.blogLocation', [0])->get()->toArray(); - $data['blogSort'] = DB::table('blog_sort')->orderBy('blog_sort.sort')->get()->toArray(); - } - protected function viewMakeFriend(): Factory|View|Application { $this->data['webSubTitle'] = '添加友链'; @@ -805,6 +819,8 @@ protected function viewMakeFriend(): Factory|View|Application ->orderBy('sort') ->get() ->toArray(); + $this->data['applicationRule'] = DB::table('info')->find(15)->data; + $this->data['applicationInfo'] = (new Index())->MarkdownToStringReplace(DB::table('info')->find(16)->data); return view('function.make-friend', $this->data); } diff --git a/app/Http/Controllers/Index.php b/app/Http/Controllers/Index.php index 8141898..e0c33be 100644 --- a/app/Http/Controllers/Index.php +++ b/app/Http/Controllers/Index.php @@ -25,7 +25,7 @@ public function __construct() 'webDescription' => empty($tempStorage = DB::table('info')->find(2)->data) ? '未定义副标题' : $tempStorage, 'webSubTitle' => empty($tempStorage = DB::table('info')->find(3)->data) ? '未定义小标题' : $tempStorage, 'webSubTitleDescription' => empty($tempStorage = DB::table('info')->find(4)->data) ? '未定义小标题内容' : $tempStorage, - 'webIcon' => empty($tempStorage = DB::table('info')->find(5)->data) ? asset('images/logo.jpg') : $tempStorage, + 'webIcon' => empty($tempStorage = DB::table('info')->find(5)->data) ? asset('images/favicon.png') : $tempStorage, 'webHeader' => DB::table('info')->find(7)->data, 'webFooter' => DB::table('info')->find(8)->data, 'webKeyword' => empty($tempStorage = DB::table('info')->find(6)->data) ? '筱锋,凌中的锋雨,xiao_lfeng' : $tempStorage, @@ -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,7 +64,19 @@ protected function ViewAboutMe(): Factory|View|Application return view('about', $this->data); } - private function MarkdownToStringReplace(string $dataBase): string + 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); + } + + public function MarkdownToStringReplace(string $dataBase): string { $decodeText = MarkdownExtra::defaultTransform($dataBase); $decodeText = str_replace('
', $decodeText);
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index b9872f6..516aded 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -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 当前友链 条 超级友链 条 待审友链 条 标题 副标题 标题 副标题 去去其他地方逛逛吧
+
+
- @foreach($blog as $blogValue)
-
@else
- 暂无待审核用户
+
+ 暂无待审核用户