Skip to content

Commit 12e04c9

Browse files
committed
打赏人数
1 parent af44b45 commit 12e04c9

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed
Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
<MudDialog>
22
<DialogContent>
3-
<MudPaper Elevation="0" Class="px-3 py-2 d-flex flex-column align-center">
4-
<MudText Typo="Typo.subtitle1" Class="mb-2" Color="Color.Secondary">
5-
如果你喜欢这款软件,不妨支持一下作者!
6-
</MudText>
3+
<MudPaper Elevation="0" Class="d-flex flex-column align-center">
4+
<MudStack Row="true" Justify="Justify.SpaceBetween" Class="mb-2">
5+
<MudText Typo="Typo.subtitle1" Color="Color.Secondary">
6+
如果你喜欢这款软件,不妨支持一下作者!
7+
</MudText>
8+
<MudIconButton Icon="@Icons.Material.Filled.Close"
9+
Color="Color.Default"
10+
Size="Size.Small"
11+
OnClick="Close" />
12+
</MudStack>
713

8-
<MudChip T="string" Label="true">请使用微信扫一扫</MudChip>
14+
<MudPaper Class="py-2 mb-3" Width="320px" Style="background-color: rgba(255, 165, 0, 0.15); border-radius: 8px;">
15+
<MudText Typo="Typo.body1" Style="color: #FF7043;" Align="Align.Center">
16+
💖 请使用 <strong>微信</strong> 扫码 💖
17+
</MudText>
18+
</MudPaper>
919

1020
<MudImage Src="images/wxPay.jpg"
1121
Width="320" Height="320"
@@ -14,16 +24,24 @@
1424

1525
<MudDivider Class="my-2" />
1626

17-
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mb-1">
18-
已有 <strong>5</strong> 人支持
19-
</MudText>
27+
<MudStack Row="true" Spacing="6" AlignItems="AlignItems.Center">
28+
<MudText Typo="Typo.subtitle1" Color="Color.Secondary">
29+
已有
30+
<strong>
31+
@if (_donationCount.HasValue)
32+
{
33+
@_donationCount
34+
}
35+
else
36+
{
37+
@("loading")
38+
}
39+
</strong>
40+
人支持
41+
</MudText>
2042

21-
<MudButton Variant="Variant.Filled" Color="Color.Primary" Href="https://jiuling.cc/donation">
22-
查看打赏记录
23-
</MudButton>
43+
<MudLink Href="https://jiuling.cc/donation" Color="Color.Secondary" Underline="Underline.None">查看赞赏记录</MudLink>
44+
</MudStack>
2445
</MudPaper>
2546
</DialogContent>
26-
<DialogActions>
27-
<MudButton OnClick="Close">关闭</MudButton>
28-
</DialogActions>
2947
</MudDialog>
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
namespace ComputerLock.Components;
1+

2+
using System.Net.Http;
3+
using System.Text.Json;
4+
5+
namespace ComputerLock.Components;
26

37
public partial class Donation
48
{
59
[CascadingParameter]
610
private IMudDialogInstance MudDialog { get; set; } = null!;
711
private void Close() => MudDialog.Cancel();
12+
13+
private int? _donationCount;
14+
private static readonly HttpClient HttpClient = new HttpClient();
15+
protected override async Task OnInitializedAsync()
16+
{
17+
await base.OnInitializedAsync();
18+
var json = await HttpClient.GetStringAsync("https://www.jiuling.cc/api/donation/list");
19+
using JsonDocument doc = JsonDocument.Parse(json);
20+
if (doc.RootElement.ValueKind == JsonValueKind.Array)
21+
{
22+
_donationCount = doc.RootElement.GetArrayLength();
23+
}
24+
}
825
}

0 commit comments

Comments
 (0)