private async void OnInsertKey(KeyboardEventArgs e) { if (e.Code == "Enter") { if (string.IsNullOrWhiteSpace(newTask.Title)) { await MsgSrv.Error("标题必须填写"); return; } isNewLoading = true; var result = await Http.PostAsJsonAsync("api/Task/SaveTask", newTask); if (result.IsSuccessStatusCode) { newTask.TaskId = await result.Content.ReadFromJsonAsync <Guid>(); // await Task.Delay(1000); if (OnInserted.HasDelegate) { await OnInserted.InvokeAsync(newTask); } newTask = NewTaskFunc?.Invoke(); } else { await MsgSrv.Error($"请求发生错误 {result.StatusCode}"); } isNewLoading = false; StateHasChanged(); } }
protected override void OnInitialized() { newTask = NewTaskFunc?.Invoke(); base.OnInitialized(); }