first commit
This commit is contained in:
28
Xboard/app/Providers/AuthServiceProvider.php
Normal file
28
Xboard/app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* 策略映射
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* 注册任何认证/授权服务
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
21
Xboard/app/Providers/BroadcastServiceProvider.php
Normal file
21
Xboard/app/Providers/BroadcastServiceProvider.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
40
Xboard/app/Providers/EventServiceProvider.php
Normal file
40
Xboard/app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\ServerRoute;
|
||||
use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use App\Observers\PlanObserver;
|
||||
use App\Observers\ServerObserver;
|
||||
use App\Observers\ServerRouteObserver;
|
||||
use App\Observers\UserObserver;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* 事件监听器映射
|
||||
* @var array<string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
];
|
||||
|
||||
/**
|
||||
* 注册任何事件
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
User::observe(UserObserver::class);
|
||||
Plan::observe(PlanObserver::class);
|
||||
Server::observe(ServerObserver::class);
|
||||
ServerRoute::observe(ServerRouteObserver::class);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
43
Xboard/app/Providers/HorizonServiceProvider.php
Normal file
43
Xboard/app/Providers/HorizonServiceProvider.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Horizon\Horizon;
|
||||
use Laravel\Horizon\HorizonApplicationServiceProvider;
|
||||
|
||||
class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
// Horizon::routeSmsNotificationsTo('15556667777');
|
||||
// Horizon::routeMailNotificationsTo('example@example.com');
|
||||
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
|
||||
|
||||
// Horizon::night();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Horizon gate.
|
||||
*
|
||||
* This gate determines who can access Horizon in non-local environments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function gate()
|
||||
{
|
||||
Gate::define('viewHorizon', function ($user) {
|
||||
return in_array($user->email, [
|
||||
//
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
43
Xboard/app/Providers/OctaneServiceProvider.php
Normal file
43
Xboard/app/Providers/OctaneServiceProvider.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Services\Plugin\HookManager;
|
||||
use App\Services\UpdateService;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Octane\Facades\Octane;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Laravel\Octane\Events\WorkerStarting;
|
||||
|
||||
class OctaneServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
if ($this->app->runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
if ($this->app->bound('octane')) {
|
||||
$this->app['events']->listen(WorkerStarting::class, function () {
|
||||
app(UpdateService::class)->updateVersionCache();
|
||||
HookManager::reset();
|
||||
});
|
||||
}
|
||||
// 每半钟执行一次调度检查
|
||||
Octane::tick('scheduler', function () {
|
||||
$lock = Cache::lock('scheduler-lock', 30);
|
||||
|
||||
if ($lock->get()) {
|
||||
try {
|
||||
Artisan::call('schedule:run');
|
||||
} finally {
|
||||
$lock->release();
|
||||
}
|
||||
}
|
||||
})->seconds(30);
|
||||
}
|
||||
}
|
||||
29
Xboard/app/Providers/PluginServiceProvider.php
Normal file
29
Xboard/app/Providers/PluginServiceProvider.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Plugin;
|
||||
use App\Services\Plugin\HookManager;
|
||||
use App\Services\Plugin\PluginManager;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Laravel\Octane\Events\WorkerStarting;
|
||||
|
||||
class PluginServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->scoped(PluginManager::class, function ($app) {
|
||||
return new PluginManager();
|
||||
});
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
if (!file_exists(base_path('plugins'))) {
|
||||
mkdir(base_path('plugins'), 0755, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
50
Xboard/app/Providers/ProtocolServiceProvider.php
Normal file
50
Xboard/app/Providers/ProtocolServiceProvider.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Support\ProtocolManager;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ProtocolServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* 注册服务
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->scoped('protocols.manager', function ($app) {
|
||||
return new ProtocolManager($app);
|
||||
});
|
||||
|
||||
$this->app->scoped('protocols.flags', function ($app) {
|
||||
return $app->make('protocols.manager')->getAllFlags();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动服务
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// 在启动时预加载协议类并缓存
|
||||
$this->app->make('protocols.manager')->registerAllProtocols();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供的服务
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [
|
||||
'protocols.manager',
|
||||
'protocols.flags',
|
||||
];
|
||||
}
|
||||
}
|
||||
87
Xboard/app/Providers/RouteServiceProvider.php
Normal file
87
Xboard/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// HTTPS scheme is forced per-request via middleware (Octane-safe).
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
$this->mapWebRoutes();
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::group([
|
||||
'prefix' => '/api/v1',
|
||||
'middleware' => 'api',
|
||||
'namespace' => $this->namespace
|
||||
], function ($router) {
|
||||
foreach (glob(app_path('Http//Routes//V1') . '/*.php') as $file) {
|
||||
$this->app->make('App\\Http\\Routes\\V1\\' . basename($file, '.php'))->map($router);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Route::group([
|
||||
'prefix' => '/api/v2',
|
||||
'middleware' => 'api',
|
||||
'namespace' => $this->namespace
|
||||
], function ($router) {
|
||||
foreach (glob(app_path('Http//Routes//V2') . '/*.php') as $file) {
|
||||
$this->app->make('App\\Http\\Routes\\V2\\' . basename($file, '.php'))->map($router);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
33
Xboard/app/Providers/SettingServiceProvider.php
Normal file
33
Xboard/app/Providers/SettingServiceProvider.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Support\Setting;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
|
||||
class SettingServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->scoped(Setting::class, function (Application $app) {
|
||||
return new Setting();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// App URL is forced per-request via middleware (Octane-safe).
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user