Skip to content

Commit 0ab5d1c

Browse files
authored
doc: update sample code for IBaiduOcr (#328)
* doc: 移除不使用的代码 * refactor: 根据最新接口更新代码
1 parent ab46d91 commit 0ab5d1c

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

src/BootstrapBlazor.Shared/Demos/BaiduOcr/BaiduOcrNormal.razor

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@inject IBaiduOcr OcrService
2+
@inject ToastService ToastService
23

34
<ButtonUpload TValue="string" OnChange="@OnClickToUpload" BrowserButtonText="VATInvoice" ShowUploadFileList="false"></ButtonUpload>
45

@@ -92,8 +93,17 @@
9293
var payload = await file.GetBytesAsync(file.File.Size);
9394
if (payload?.Any() ?? false)
9495
{
95-
Invoice = await OcrService.CheckVatInvoiceAsync(payload);
96-
StateHasChanged();
96+
var result = await OcrService.CheckVatInvoiceAsync(payload);
97+
Invoice = result.Entity;
98+
if (result.Entity != null)
99+
{
100+
await ToastService.Success("Vat Invoice", "VAT Invoice success!");
101+
StateHasChanged();
102+
}
103+
else
104+
{
105+
await ToastService.Information("Vat Invoice", $"{result.ErrorCode}: {result.ErrorMessage}");
106+
}
97107
}
98108
}
99109
}

src/BootstrapBlazor.Shared/Demos/BaiduOcr/BaiduOcrNormal.razor.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)