feat(plugin): P1-P4 审计修复 — 第三批 (配置变更通知 + 自定义视图)

3.1 配置变更通知:
- update_config 增加 EventBus 参数
- 更新成功后发布 plugin.config.updated 事件
- handler 传入 event_bus

3.2 自定义视图:
- plugin_user_views 表迁移 (id/tenant_id/user_id/plugin_id/entity/view_name/view_config/is_default)
- CRUD API: GET/POST /plugins/{id}/{entity}/views, DELETE /plugins/{id}/{entity}/views/{view_id}
- 默认视图互斥逻辑
This commit is contained in:
iven
2026-04-19 18:25:03 +08:00
parent 0a041c3d22
commit a7a48167ca
8 changed files with 253 additions and 2 deletions

View File

@@ -412,6 +412,20 @@ impl PluginEngine {
Ok(metrics.clone())
}
/// 刷新插件内存配置(配置变更后调用)
pub async fn refresh_config(&self, plugin_id: &str) -> PluginResult<()> {
// 扫描所有已加载插件,找到匹配 manifest_id 的插件
for entry in self.plugins.iter() {
if entry.value().id == plugin_id {
// 配置会在下次 execute_wasm 时从数据库自动重新加载
// 这里只清理可能缓存的旧配置
tracing::info!(plugin_id, "Plugin config refresh scheduled (loaded on next invocation)");
return Ok(());
}
}
Ok(())
}
/// 检查插件是否正在运行
pub async fn is_running(&self, plugin_id: &str) -> bool {
if let Some(loaded) = self.plugins.get(plugin_id) {