fix: 修复页面间状态丢失问题并优化选择页面
- 修复选择审批人后再选择抄送人导致状态丢失的问题 - 使用独立的 sessionStorage key (selectedApprovers, selectedCc) - 组件每次挂载时从 sessionStorage 恢复状态 - 只在提交/保存成功后清除 sessionStorage - 优化人员选择页面布局和样式 - 更新 CLAUDE.md 文档记录问题和解决方案 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Util;
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Database\Eloquent\Model as EloquentModel;
|
||||
|
||||
class Db
|
||||
{
|
||||
private static ?Capsule $capsule = null;
|
||||
|
||||
public static function init(): void
|
||||
{
|
||||
if (self::$capsule !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$config = config('database');
|
||||
|
||||
self::$capsule = new Capsule();
|
||||
|
||||
// Add connection
|
||||
self::$capsule->addConnection([
|
||||
'driver' => 'mysql',
|
||||
'host' => getenv('DB_HOST') ?: '1Panel-mysql-409s',
|
||||
'port' => getenv('DB_PORT') ?: '3306',
|
||||
'database' => getenv('DB_DATABASE') ?: 'xserver',
|
||||
'username' => getenv('DB_USERNAME') ?: 'root',
|
||||
'password' => getenv('DB_PASSWORD') ?: 'mysql_xEsdPa',
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
]);
|
||||
|
||||
// Set event dispatcher
|
||||
self::$capsule->setEventDispatcher(new Dispatcher(new Container()));
|
||||
|
||||
// Make this Capsule instance available globally via static methods
|
||||
self::$capsule->setAsGlobal();
|
||||
|
||||
// Setup the Eloquent ORM
|
||||
self::$capsule->bootEloquent();
|
||||
}
|
||||
|
||||
public static function connection(?string $name = null): \Illuminate\Database\Connection
|
||||
{
|
||||
if (self::$capsule === null) {
|
||||
self::init();
|
||||
}
|
||||
return self::$capsule->connection($name);
|
||||
}
|
||||
|
||||
public static function table(string $table): \Illuminate\Database\Query\Builder
|
||||
{
|
||||
return self::connection()->table($table);
|
||||
}
|
||||
|
||||
public static function raw(string $value): \Illuminate\Database\Query\Expression
|
||||
{
|
||||
return self::connection()->raw($value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user