M5: Workerman 常驻服务 + AI 审核/润色插件 + 支付插件(支付宝/微信/沙箱)+ 会员插件(套餐/订阅/付费文章)

This commit is contained in:
ak
2026-08-11 18:29:35 +08:00
parent f77c96d3aa
commit 1d1df43cee
52 changed files with 1914 additions and 20 deletions
+6 -4
View File
@@ -68,12 +68,14 @@ class PluginManager
public function isEnabled(string $plugin): bool
{
[$vendor, $name] = array_pad(explode('.', $plugin), 2, $plugin);
if (\Illuminate\Support\Facades\Schema::hasTable('plugin_records')) {
[$vendor, $name] = array_pad(explode('.', $plugin), 2, $plugin);
$record = PluginRecord::query()->where('vendor', $vendor)->where('name', $name)->first();
$record = PluginRecord::query()->where('vendor', $vendor)->where('name', $name)->first();
if ($record) {
return (bool) $record->enabled;
if ($record) {
return (bool) $record->enabled;
}
}
return in_array($plugin, config('plugins.enabled', []), true);
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Blog\Support;
/**
* 从已启用插件的 manifest 中收集 Filament 页面/资源。
*/
class PluginPages
{
public static function pages(): array
{
return self::collect('filament_pages');
}
public static function resources(): array
{
return self::collect('filament_resources');
}
private static function collect(string $key): array
{
$manager = app(PluginManager::class);
$classes = [];
foreach ($manager->all() as $pluginKey => $plugin) {
if (! $plugin['enabled']) {
continue;
}
$manifest = $manager->manifest($pluginKey);
foreach ($manifest[$key] ?? [] as $class) {
if (class_exists($class)) {
$classes[] = $class;
}
}
}
return $classes;
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Blog\Support;
use Workerman\Connection\TcpConnection;
/**
* Workerman WebSocket 广播器:任务执行中向后台推送进度。
*/
class WorkermanBroadcaster
{
/** @var array<int, TcpConnection> */
public static array $connections = [];
public static function add(TcpConnection $connection): void
{
self::$connections[spl_object_id($connection)] = $connection;
}
public static function remove(TcpConnection $connection): void
{
unset(self::$connections[spl_object_id($connection)]);
}
public static function send(string $event, array $data = []): void
{
$message = json_encode(['event' => $event, 'data' => $data], JSON_UNESCAPED_UNICODE);
foreach (self::$connections as $connection) {
$connection->send($message);
}
}
}