pub const EVENT_STUB: &str = r#"//! {%namespace%}::{%className%} 事件
//!
//! 由 `sz-rust make:event` 生成,对齐 PHP `make:event`。
//! 通过 `EventDispatcher::trigger({%className%}::name(), &payload)` 触发。
use serde_json::Value;
/// {%className%} 事件
///
/// 对齐 PHP `class {%className%} extends \think\Event`。
pub struct {%className%};
impl {%className%} {
/// 事件名称(用于监听器注册与触发)
pub fn name() -> &'static str {
"{%event_name%}"
}
/// 构造事件负载
///
/// 在此组装事件需要传递给监听器的数据。
pub fn payload(&self) -> Value {
Value::Null
}
}
"#;Expand description
Event 模板(对齐 PHP make:event)
PHP 原文生成继承 think\Event 的事件类,Rust 生成包含事件名与负载数据的结构体。