Skip to content

Commit 9ffc3d4

Browse files
ArgoZhangj4587698
andauthored
chore(Localizer): update localizer check unit test (#7544)
* doc: 更新参数表格 * Please provide the file changes to generate a commit message. * Revert "Please provide the file changes to generate a commit message." This reverts commit aa97c6b. * Reapply "Please provide the file changes to generate a commit message." This reverts commit 50376ff. * refactor: 更新多语言 * doc: 更新资源文件 * test: 更新单元测试 * test: 增加文件尾部新行 * feat: 增加支持是否为组件参数 * doc: 使用新方法自动生成参数说明 * doc: 更新注释 * doc: 删除冗余多语言配置 * doc: 调整列宽 * refactor: 重构资源文件检查单元测试 * refactor: 更新获得类名逻辑 --------- Co-authored-by: j4587698 <jx@jvxiang.com>
1 parent 55ac5b9 commit 9ffc3d4

144 files changed

Lines changed: 11746 additions & 23361 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/BootstrapBlazor.Server/Components/Components/AttributeTable.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
}
88
</p>
99

10-
<Table TItem="AttributeItem" Items="Items" IsBordered="true" IsStriped="true" ShowFooter="@ShowFooter">
10+
<Table TItem="AttributeItem" Items="_items" IsBordered="true" IsStriped="true" ShowFooter="@ShowFooter">
1111
<TableColumns>
1212
<TableColumn @bind-Field="@context.Name" />
1313
<TableColumn @bind-Field="@context.Description" TextWrap="true" />
14-
<TableColumn @bind-Field="@context.Type" />
14+
<TableColumn @bind-Field="@context.Type" TextWrap="true" Width="180"></TableColumn>
1515
<TableColumn @bind-Field="@context.Version" />
1616
</TableColumns>
1717
<TableFooter>
18-
<TableFooterCell Text="合计:" colspan="3" Align="Alignment.Left" />
18+
<TableFooterCell Text="@Localizer["Total"]" colspan="3" Align="Alignment.Left" />
1919
<TableFooterCell Aggregate="AggregateType.Count" Field="@nameof(AttributeItem.Name)" />
2020
</TableFooter>
2121
</Table>

src/BootstrapBlazor.Server/Components/Components/AttributeTable.razor.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ public sealed partial class AttributeTable
2121
[NotNull]
2222
public string? Title { get; set; }
2323

24-
/// <summary>
25-
/// 获得/设置 表格数据
26-
/// </summary>
27-
[Parameter]
28-
public IEnumerable<AttributeItem> Items { get; set; } = [];
29-
3024
/// <summary>
3125
/// 获得/设置 表格关联组件类型
3226
/// </summary>
@@ -39,18 +33,33 @@ public sealed partial class AttributeTable
3933
[Parameter]
4034
public bool ShowFooter { get; set; }
4135

36+
private List<AttributeItem> _items = [];
37+
4238
/// <summary>
4339
/// <inheritdoc/>
4440
/// </summary>
45-
protected override void OnInitialized()
41+
protected override void OnParametersSet()
4642
{
47-
base.OnInitialized();
48-
49-
Title ??= Localizer[nameof(Title)];
43+
base.OnParametersSet();
5044

5145
if (Type != null)
5246
{
53-
Items = ComponentAttributeCacheService.GetAttributes(Type);
47+
_items = ComponentAttributeCacheService.GetAttributes(Type);
48+
49+
Title ??= FormatTypeName(Type);
5450
}
5551
}
52+
53+
private static string FormatTypeName(Type type)
54+
{
55+
if (!type.IsGenericType)
56+
{
57+
return type.Name;
58+
}
59+
60+
var index = type.Name.IndexOf('`');
61+
var typeName = type.Name.Substring(0, index);
62+
var genericArgs = string.Join(", ", type.GetGenericArguments().Select(i => i.Name));
63+
return $"{typeName}<{genericArgs}>";
64+
}
5665
}

src/BootstrapBlazor.Server/Components/Samples/Alerts.razor.cs

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -116,76 +116,4 @@ private static EventItem[] GetEvents() =>
116116
Type = "EventCallback<MouseEventArgs>"
117117
}
118118
];
119-
120-
/// <summary>
121-
/// 获得属性方法
122-
/// </summary>
123-
/// <returns></returns>
124-
private static AttributeItem[] GetAttributes() =>
125-
[
126-
new()
127-
{
128-
Name = "ChildContent",
129-
Description = "Content",
130-
Type = "RenderFragment",
131-
ValueList = " — ",
132-
DefaultValue = " — "
133-
},
134-
new()
135-
{
136-
Name = "Class",
137-
Description = "Style",
138-
Type = "string",
139-
ValueList = " — ",
140-
DefaultValue = " — "
141-
},
142-
new()
143-
{
144-
Name = "Color",
145-
Description = "Color",
146-
Type = "Color",
147-
ValueList = "Primary / Secondary / Success / Danger / Warning / Info / Dark",
148-
DefaultValue = "Primary"
149-
},
150-
new()
151-
{
152-
Name = "Icon",
153-
Description = "Icon",
154-
Type = "string",
155-
ValueList = " — ",
156-
DefaultValue = " — "
157-
},
158-
new()
159-
{
160-
Name = "ShowDismiss",
161-
Description = "Close Button",
162-
Type = "bool",
163-
ValueList = " — ",
164-
DefaultValue = "false"
165-
},
166-
new()
167-
{
168-
Name = "ShowBar",
169-
Description = "Show the left Bar",
170-
Type = "bool",
171-
ValueList = "true|false",
172-
DefaultValue = "false"
173-
},
174-
new()
175-
{
176-
Name = "ShowBorder",
177-
Description = "Show border",
178-
Type = "bool",
179-
ValueList = "true|false",
180-
DefaultValue = "false"
181-
},
182-
new()
183-
{
184-
Name = "ShowShadow",
185-
Description = "Show Shadow",
186-
Type = "bool",
187-
ValueList = "true|false",
188-
DefaultValue = "false"
189-
}
190-
];
191119
}

src/BootstrapBlazor.Server/Components/Samples/AnchorLinks.razor.cs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,4 @@ public partial class AnchorLinks
1313
[Inject]
1414
[NotNull]
1515
private IStringLocalizer<AnchorLinks>? Localizer { get; set; }
16-
17-
private AttributeItem[] GetAttributes() =>
18-
[
19-
new()
20-
{
21-
Name = nameof(AnchorLink.Id),
22-
Description = Localizer[$"Attr{nameof(AnchorLink.Id)}"],
23-
Type = "string",
24-
ValueList = " — ",
25-
DefaultValue = " — "
26-
},
27-
new()
28-
{
29-
Name = nameof(AnchorLink.Icon),
30-
Description = Localizer[$"Attr{nameof(AnchorLink.Icon)}"],
31-
Type = "string",
32-
ValueList = " — ",
33-
DefaultValue = "fa-solid fa-link"
34-
},
35-
new()
36-
{
37-
Name = nameof(AnchorLink.Text),
38-
Description = Localizer[$"Attr{nameof(AnchorLink.Text)}"],
39-
Type = "string",
40-
ValueList = " — ",
41-
DefaultValue = " — "
42-
},
43-
new()
44-
{
45-
Name = nameof(AnchorLink.TooltipText),
46-
Description = Localizer[$"Attr{nameof(AnchorLink.TooltipText)}"],
47-
Type = "string",
48-
ValueList = " — ",
49-
DefaultValue = " — "
50-
}
51-
];
5216
}

src/BootstrapBlazor.Server/Components/Samples/Anchors.razor.cs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,4 @@ public partial class Anchors
1313
[Inject]
1414
[NotNull]
1515
private IStringLocalizer<Anchors>? Localizer { get; set; }
16-
17-
/// <summary>
18-
/// 获得属性方法
19-
/// </summary>
20-
/// <returns></returns>
21-
private AttributeItem[] GetAttributes() =>
22-
[
23-
new()
24-
{
25-
Name = "Target",
26-
Description = Localizer["DescTarget"],
27-
Type = "string",
28-
ValueList = " — ",
29-
DefaultValue = " — "
30-
},
31-
new()
32-
{
33-
Name = "Container",
34-
Description = Localizer["DescContainer"],
35-
Type = "string",
36-
ValueList = " — ",
37-
DefaultValue = " — "
38-
},
39-
new()
40-
{
41-
Name = "IsAnimation",
42-
Description = Localizer["DescIsAnimation"],
43-
Type = "boolean",
44-
ValueList = "true|false",
45-
DefaultValue = "true"
46-
},
47-
new()
48-
{
49-
Name = "Offset",
50-
Description = Localizer["DescOffset"],
51-
Type = "int",
52-
ValueList = " — ",
53-
DefaultValue = "0"
54-
},
55-
new()
56-
{
57-
Name = "ChildContent",
58-
Description = Localizer["DescChildContent"],
59-
Type = "RenderFragment",
60-
ValueList = " — ",
61-
DefaultValue = " — "
62-
}
63-
];
6416
}

src/BootstrapBlazor.Server/Components/Samples/AutoCompletes.razor.cs

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -48,132 +48,4 @@ private Task GroupOnSelectedItemChanged(string val)
4848
GroupLogger.Log($"Value: {val}");
4949
return Task.CompletedTask;
5050
}
51-
52-
/// <summary>
53-
/// 获得属性方法
54-
/// </summary>
55-
/// <returns></returns>
56-
private AttributeItem[] GetAttributes() =>
57-
[
58-
new()
59-
{
60-
Name = "ShowLabel",
61-
Description = Localizer["Att1"],
62-
Type = "bool",
63-
ValueList = "true|false",
64-
DefaultValue = "true"
65-
},
66-
new()
67-
{
68-
Name = "ChildContent",
69-
Description = Localizer["Att2"],
70-
Type = "RenderFragment",
71-
ValueList = " — ",
72-
DefaultValue = " — "
73-
},
74-
new()
75-
{
76-
Name = "ItemTemplate",
77-
Description = Localizer["AttItemTemplate"],
78-
Type = "RenderFragment<string>",
79-
ValueList = " — ",
80-
DefaultValue = " — "
81-
},
82-
new()
83-
{
84-
Name = "Items",
85-
Description = Localizer["Att3"],
86-
Type = "IEnumerable<string>",
87-
ValueList = " — ",
88-
DefaultValue = " — "
89-
},
90-
new()
91-
{
92-
Name = "NoDataTip",
93-
Description = Localizer["Att4"],
94-
Type = "string",
95-
ValueList = " — ",
96-
DefaultValue = Localizer["Att4DefaultValue"]!
97-
},
98-
new()
99-
{
100-
Name = "DisplayCount",
101-
Description = Localizer["Att5"],
102-
Type = "int?",
103-
ValueList = " — ",
104-
DefaultValue = " — "
105-
},
106-
new()
107-
{
108-
Name = "ValueChanged",
109-
Description = Localizer["Att6"],
110-
Type = "Action<string>",
111-
ValueList = " — ",
112-
DefaultValue = " — "
113-
},
114-
new()
115-
{
116-
Name = "IsLikeMatch",
117-
Description = Localizer["Att7"],
118-
Type = "bool",
119-
ValueList = "true|false",
120-
DefaultValue = "false"
121-
},
122-
new()
123-
{
124-
Name = "IgnoreCase",
125-
Description = Localizer["Att8"],
126-
Type = "bool",
127-
ValueList = "true|false",
128-
DefaultValue = "true"
129-
},
130-
new()
131-
{
132-
Name = "OnCustomFilter",
133-
Description = Localizer["Att9"],
134-
Type = "Func<string, Task<IEnumerable<string>>>",
135-
ValueList = " — ",
136-
DefaultValue = " — "
137-
},
138-
new()
139-
{
140-
Name = "Debounce",
141-
Description = Localizer["Debounce"],
142-
Type = "int",
143-
ValueList = " — ",
144-
DefaultValue = "0"
145-
},
146-
new()
147-
{
148-
Name = nameof(AutoComplete.SkipEnter),
149-
Description = Localizer[nameof(AutoComplete.SkipEnter)],
150-
Type = "bool",
151-
ValueList = "true/false",
152-
DefaultValue = "false"
153-
},
154-
new()
155-
{
156-
Name = nameof(AutoComplete.SkipEsc),
157-
Description = Localizer[nameof(AutoComplete.SkipEsc)],
158-
Type = "bool",
159-
ValueList = "true/false",
160-
DefaultValue = "false"
161-
},
162-
new()
163-
{
164-
Name = nameof(AutoComplete.OnValueChanged),
165-
Description = Localizer[nameof(AutoComplete.OnValueChanged)],
166-
Type = "Func<string, Task>",
167-
ValueList = " — ",
168-
DefaultValue = " — "
169-
},
170-
new()
171-
{
172-
Name = nameof(AutoComplete.OnSelectedItemChanged),
173-
Description = Localizer[nameof(AutoComplete.OnSelectedItemChanged)],
174-
Type = "Func<string, Task>",
175-
ValueList = " — ",
176-
DefaultValue = " — "
177-
}
178-
];
17951
}

0 commit comments

Comments
 (0)