feat: 实现动态插件系统 (6阶段完成)

- 阶段1: 消息类型序列化 (Serialize/Deserialize, &'static str → String)
- 阶段2: FFI 边界类型 + Plugin SDK (plugin_abi, showen-plugin-sdk crate)
- 阶段3: PluginLoader + DynamicPlugin (libloading 动态加载 .so)
- 阶段4: 版本管理 + 错误策略 (VersionManager, PluginState, 自动回退)
- 阶段5: 远程仓库客户端 (HTTP 下载 + tar.gz 安装)
- 阶段6: 示例插件 + HTTP 管理 API + 全目录 README 文档

54/54 测试通过,0 warnings。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
showen
2026-03-13 03:38:08 +08:00
parent 5dcc1ad98e
commit 7135f28545
62 changed files with 3501 additions and 299 deletions

View File

@@ -1,19 +1,20 @@
use crate::core::config::AppConfig;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
/// 消息信封:包含来源、目的地、消息体
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Envelope {
pub from: &'static str,
pub from: String,
pub to: Destination,
pub message: Message,
}
/// 消息目的地
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Destination {
/// 点对点发送给指定插件
Plugin(&'static str),
Plugin(String),
/// 广播给所有插件
Broadcast,
/// 发给管理层自身
@@ -21,7 +22,7 @@ pub enum Destination {
}
/// 所有插件间通信的类型安全消息
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Message {
// ── 播放控制 ──
PlayerCommand(PlayerCommand),
@@ -48,12 +49,14 @@ pub enum Message {
},
// ── 配置 ──
/// Arc<AppConfig> 无法跨 FFI 序列化,动态插件通过 init 时传入的 JSON 获取配置
#[serde(skip)]
ConfigReloaded(Arc<AppConfig>),
ConfigReloadRequest,
// ── 系统 ──
Shutdown,
PluginReady(&'static str),
PluginReady(String),
// ── 扩展(未来插件用) ──
Custom {
@@ -62,7 +65,7 @@ pub enum Message {
},
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PlayerCommand {
Play,
Pause,
@@ -72,7 +75,7 @@ pub enum PlayerCommand {
ChangeScene(String),
}
#[derive(Debug, Clone, serde::Serialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PlayerStatusData {
pub running: bool,
pub paused: bool,
@@ -82,7 +85,7 @@ pub struct PlayerStatusData {
pub current_video: Option<String>,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum WifiCommand {
Scan,
Connect { ssid: String, password: String },