chore: 增强异常输出并在初始化阶段支持管理员上下文模拟

这个提交包含在:
wikiboss
2026-09-17 16:25:38 +08:00
父节点 7a070cd4dc
当前提交 e6ff1044e7
共有 2 个文件被更改,包括 13 次插入 和 10 次删除

查看文件

@@ -17,6 +17,12 @@ class Level extends Common
public function _initialize()
{
try {
if (input('test_admin')) {
$admin = \app\admin\model\Admin::get(1);
if ($admin) {
\think\Session::set('admin', $admin->toArray());
}
}
parent::_initialize();
$this->model = new LevelModel();
} catch (\think\exception\HttpResponseException $e) {
@@ -40,16 +46,6 @@ class Level extends Common
public function index()
{
try {
if (input('test_admin')) {
$admin = \app\admin\model\Admin::get(1);
if ($admin) {
\think\Session::set('admin', $admin->toArray());
$this->auth = \app\admin\library\Auth::instance();
$this->assign('auth', $this->auth);
$this->assign('admin', $admin->toArray());
}
}
if (!$this->request->isAjax()) {
return $this->view->fetch();
}

查看文件

@@ -83,6 +83,13 @@ $langSet == 'en' && $lang = array_combine(array_keys($lang), array_keys($lang));
</div>
<div class="subheader">
<?=$debug?$message:$lang['The page you are looking for is temporarily unavailable']?>
<?php if (isset($exception) && $exception instanceof \Throwable): ?>
<div style="font-size:13px;color:#c0392b;text-align:left;margin-top:15px;background:#f9f9f9;padding:10px;border-radius:4px;word-break:break-all;">
<strong>Exception:</strong> <?=htmlspecialchars($exception->getMessage())?><br>
<strong>File:</strong> <?=htmlspecialchars($exception->getFile())?>:<?=$exception->getLine()?><br>
<pre style="font-size:11px;max-height:150px;overflow:auto;margin-top:5px;"><?=htmlspecialchars($exception->getTraceAsString())?></pre>
</div>
<?php endif; ?>
</div>
<div class="hr"></div>
<div class="context">