<MudDialog>
<DialogContent>
<div class="d-flex flex-column py-1">
<MudTextField @bind-Value="_url" InputType="InputType.Url" Label="图片地址" Variant="Variant.Text"></MudTextField>
</div>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">取消</MudButton>
<MudButton Color="Color.Primary" OnClick="Submit">确定</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter]
MudDialogInstance MudDialog { get; set; }
[Inject]
private IDialogService DialogService { get; set; }
string _url = "";
void Submit()
{
if (!_url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
DialogService.ShowMessageBox("提示", "只支持https协议的图片", "确定");
return;
}
var markdown = $"![]({_url})";
MudDialog.Close(DialogResult.Ok(markdown));
}
void Cancel() => MudDialog.Cancel();
}