mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 11:02:48 +08:00
将所有主要逻辑代码迁移到extend中,并在service中注册调用;
This commit is contained in:
76
extend/think/UlthonAdminService.php
Normal file
76
extend/think/UlthonAdminService.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace think;
|
||||
|
||||
use app\common\event\AdminLoginSuccess\LogEvent;
|
||||
use app\common\event\AdminLoginType\DemoEvent;
|
||||
use app\common\provider\ExceptionHandle;
|
||||
use app\common\provider\Request;
|
||||
use app\common\provider\View;
|
||||
use think\app\Service as AppService;
|
||||
use think\captcha\CaptchaService;
|
||||
use think\facade\App;
|
||||
use think\migration\Service;
|
||||
|
||||
class UlthonAdminService extends \think\Service
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
// 绑定系统事件
|
||||
$event_listen = [
|
||||
'AppInit' => [],
|
||||
'HttpRun' => [],
|
||||
'HttpEnd' => [],
|
||||
'LogLevel' => [],
|
||||
'LogWrite' => [],
|
||||
'AdminLoginSuccess' => [
|
||||
LogEvent::class,
|
||||
],
|
||||
'AdminLoginType' => [
|
||||
DemoEvent::class,
|
||||
],
|
||||
];
|
||||
|
||||
$this->app->event->listenEvents($event_listen);
|
||||
|
||||
// 注册验证码服务
|
||||
$this->app->register(CaptchaService::class);
|
||||
|
||||
// 注册多应用服务
|
||||
$this->app->register(AppService::class);
|
||||
|
||||
// 注册数据库迁移服务
|
||||
$this->app->register(Service::class);
|
||||
|
||||
// 绑定标识容器
|
||||
|
||||
$provider_default = [
|
||||
'think\Request' => Request::class,
|
||||
'think\exception\Handle' => ExceptionHandle::class,
|
||||
'think\View' => View::class,
|
||||
];
|
||||
|
||||
$provider_setting = include App::getRootPath() . '/app/provider.php';
|
||||
|
||||
if (isset($provider_setting['think\App'])) {
|
||||
unset($provider_setting['think\App']);
|
||||
}
|
||||
|
||||
$provider = array_merge($provider_default, $provider_setting);
|
||||
|
||||
$this->app->bind($provider);
|
||||
|
||||
// 导入系统中间件
|
||||
|
||||
$middleware = [
|
||||
// 全局请求缓存
|
||||
// \think\middleware\CheckRequestCache::class,
|
||||
// 多语言加载
|
||||
// \think\middleware\LoadLangPack::class,
|
||||
// Session初始化
|
||||
100 => \think\middleware\SessionInit::class,
|
||||
];
|
||||
|
||||
$this->app->middleware->import($middleware);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user