Skip to content

Commit 88a2bd9

Browse files
committed
refactor: 更新示例
1 parent 2d0d195 commit 88a2bd9

File tree

3 files changed

+152
-8
lines changed

3 files changed

+152
-8
lines changed

src/BootstrapBlazor/Components/Upload/ButtonUpload.razor.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,6 @@ public partial class ButtonUpload<TValue>
8686
[Parameter]
8787
public RenderFragment? ChildContent { get; set; }
8888

89-
[Inject]
90-
[NotNull]
91-
private IStringLocalizer<UploadBase<TValue>>? Localizer { get; set; }
92-
93-
[Inject]
94-
[NotNull]
95-
private IIconTheme? IconTheme { get; set; }
96-
9789
/// <summary>
9890
/// 获得/设置 设置文件格式图标回调委托
9991
/// </summary>
@@ -190,6 +182,14 @@ public partial class ButtonUpload<TValue>
190182
[Parameter]
191183
public Func<UploadFile, Task>? OnCancel { get; set; }
192184

185+
[Inject]
186+
[NotNull]
187+
private IStringLocalizer<UploadBase<TValue>>? Localizer { get; set; }
188+
189+
[Inject]
190+
[NotNull]
191+
private IIconTheme? IconTheme { get; set; }
192+
193193
private string? ClassString => CssBuilder.Default("upload")
194194
.AddClassFromAttributes(AdditionalAttributes)
195195
.Build();

src/BootstrapBlazor/Components/Upload/DropUpload.razor

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,17 @@
4848
}
4949
</div>
5050
}
51+
@if (ShowUploadFileList)
52+
{
53+
<UploadPreviewList Items="GetUploadFiles()" IsDisabled="@IsDisabled" ShowProgress="@ShowProgress"
54+
OnGetFileFormat="@OnGetFileFormat" OnCancel="OnCancel" CancelIcon="@CancelIcon" LoadingIcon="@LoadingIcon"
55+
InvalidStatusIcon="@InvalidStatusIcon" ValidStatusIcon="@ValidStatusIcon"
56+
ShowDownloadButton="@ShowDownloadButton" DownloadIcon="@DownloadIcon" OnDownload="@OnDownload"
57+
DeleteIcon="@DeleteIcon" OnDelete="@OnFileDelete"
58+
FileIconExcel="@FileIconExcel" FileIconDocx="@FileIconDocx" FileIconPPT="@FileIconPPT"
59+
FileIconAudio="@FileIconAudio" FileIconVideo="@FileIconVideo"
60+
FileIconCode="@FileIconCode" FileIconPdf="@FileIconPdf" FileIconZip="@FileIconZip"
61+
FileIconArchive="@FileIconArchive" FileIconImage="@FileIconImage" FileIconFile="@FileIconFile"></UploadPreviewList>
62+
}
5163
<InputFile AdditionalAttributes="@GetUploadAdditionalAttributes()" OnChange="OnFileChange"/>
5264
</div>

src/BootstrapBlazor/Components/Upload/DropUpload.razor.cs

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,138 @@ public partial class DropUpload
6363
[NotNull]
6464
public string? FooterText { get; set; }
6565

66+
/// <summary>
67+
/// 获得/设置 是否显示上传列表 默认 true
68+
/// </summary>
69+
[Parameter]
70+
public bool ShowUploadFileList { get; set; } = true;
71+
72+
/// <summary>
73+
/// 获得/设置 设置文件格式图标回调委托
74+
/// </summary>
75+
[Parameter]
76+
public Func<string?, string>? OnGetFileFormat { get; set; }
77+
78+
/// <summary>
79+
/// 获得/设置 取消图标
80+
/// </summary>
81+
[Parameter]
82+
public string? CancelIcon { get; set; }
83+
84+
/// <summary>
85+
/// 获得/设置 点击取消按钮回调此方法 默认 null
86+
/// </summary>
87+
[Parameter]
88+
public Func<UploadFile, Task>? OnCancel { get; set; }
89+
90+
/// <summary>
91+
/// 获得/设置 是否显示下载按钮 默认 false
92+
/// </summary>
93+
[Parameter]
94+
public bool ShowDownloadButton { get; set; }
95+
96+
/// <summary>
97+
/// 获得/设置 点击下载按钮回调方法 默认 null
98+
/// </summary>
99+
[Parameter]
100+
public Func<UploadFile, Task>? OnDownload { get; set; }
101+
102+
/// <summary>
103+
/// 获得/设置 下载按钮图标
104+
/// </summary>
105+
[Parameter]
106+
public string? DownloadIcon { get; set; }
107+
108+
/// <summary>
109+
/// 获得/设置 加载中图标
110+
/// </summary>
111+
[Parameter]
112+
public string? LoadingIcon { get; set; }
113+
114+
/// <summary>
115+
/// 获得/设置 上传失败状态图标
116+
/// </summary>
117+
[Parameter]
118+
public string? InvalidStatusIcon { get; set; }
119+
120+
/// <summary>
121+
/// 获得/设置 上传成功状态图标
122+
/// </summary>
123+
[Parameter]
124+
public string? ValidStatusIcon { get; set; }
125+
126+
/// <summary>
127+
/// 获得/设置 删除按钮图标
128+
/// </summary>
129+
[Parameter]
130+
public string? DeleteIcon { get; set; }
131+
132+
/// <summary>
133+
/// 获得/设置 Excel 类型文件图标
134+
/// </summary>
135+
[Parameter]
136+
public string? FileIconExcel { get; set; }
137+
138+
/// <summary>
139+
/// 获得/设置 Excel 类型文件图标
140+
/// </summary>
141+
[Parameter]
142+
public string? FileIconDocx { get; set; }
143+
144+
/// <summary>
145+
/// 获得/设置 Excel 类型文件图标
146+
/// </summary>
147+
[Parameter]
148+
public string? FileIconPPT { get; set; }
149+
150+
/// <summary>
151+
/// 获得/设置 Excel 类型文件图标
152+
/// </summary>
153+
[Parameter]
154+
public string? FileIconAudio { get; set; }
155+
156+
/// <summary>
157+
/// 获得/设置 Excel 类型文件图标
158+
/// </summary>
159+
[Parameter]
160+
public string? FileIconVideo { get; set; }
161+
162+
/// <summary>
163+
/// 获得/设置 Excel 类型文件图标
164+
/// </summary>
165+
[Parameter]
166+
public string? FileIconCode { get; set; }
167+
168+
/// <summary>
169+
/// 获得/设置 Excel 类型文件图标
170+
/// </summary>
171+
[Parameter]
172+
public string? FileIconPdf { get; set; }
173+
174+
/// <summary>
175+
/// 获得/设置 Excel 类型文件图标
176+
/// </summary>
177+
[Parameter]
178+
public string? FileIconZip { get; set; }
179+
180+
/// <summary>
181+
/// 获得/设置 Excel 类型文件图标
182+
/// </summary>
183+
[Parameter]
184+
public string? FileIconArchive { get; set; }
185+
186+
/// <summary>
187+
/// 获得/设置 Excel 类型文件图标
188+
/// </summary>
189+
[Parameter]
190+
public string? FileIconImage { get; set; }
191+
192+
/// <summary>
193+
/// 获得/设置 Excel 类型文件图标
194+
/// </summary>
195+
[Parameter]
196+
public string? FileIconFile { get; set; }
197+
66198
[Inject]
67199
[NotNull]
68200
private IIconTheme? IconTheme { get; set; }

0 commit comments

Comments
 (0)