- 创建一个组件类,用[NavPlugin]标识插件,框架自动将项目添加到顶部导航编辑模式下的下拉菜单中
[NavPlugin("连接", "link")]
class NavLink : PluginBase<LinkInfo>
{
public override void Config(Func<object, Task<Result>> onConfig)
{
var model = new FormModel<LinkInfo>(Parent, true)
{
Title = "添加连接",
Data = new LinkInfo(),
OnSave = d => onConfig?.Invoke(d)
};
Parent.UI.ShowForm(model);
}
protected override void BuildRender(RenderTreeBuilder builder)
{
Parameter = Utils.FromJson<LinkInfo>(Plugin?.Setting);
if (Parameter == null)
return;
// 此处为顶部导航插件呈现逻辑
}
}