feat: new xboard

This commit is contained in:
xboard
2025-01-21 14:57:54 +08:00
parent de18cfe596
commit 0f43fff242
373 changed files with 17923 additions and 20264 deletions
-28
View File
@@ -1,28 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->app['view']->addNamespace('theme', public_path() . '/theme');
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Laravel\Octane\Facades\Octane;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Artisan;
class OctaneSchedulerProvider extends ServiceProvider
{
public function register(): void
{
}
public function boot(): void
{
if ($this->app->runningInConsole()) {
return;
}
// 每半钟执行一次调度检查
Octane::tick('scheduler', function () {
$lock = Cache::lock('scheduler-lock', 30);
if ($lock->get()) {
try {
Artisan::call('schedule:run');
} finally {
$lock->release();
}
}
})->seconds(30);
}
}
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Providers;
use App\Models\Plugin;
use App\Services\Plugin\PluginManager;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\DB;
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);
}
try {
$plugins = Plugin::query()
->where('is_enabled', true)
->get();
foreach ($plugins as $plugin) {
$manager = $this->app->make(PluginManager::class);
$manager->enable($plugin->code);
}
} catch (\Exception $e) {
\Log::error('Failed to load plugins: ' . $e->getMessage());
}
}
}
+1 -2
View File
@@ -15,8 +15,7 @@ class SettingServiceProvider extends ServiceProvider
*/
public function register()
{
$this->app->bind(Setting::class, function (Application $app) {
$this->app->scoped(Setting::class, function (Application $app) {
return new Setting();
});