Skip to content

Commit 6710442

Browse files
authored
fix: build error without full pages (#193)
* fix: build error without full pages * fix using
1 parent 808be9a commit 6710442

File tree

13 files changed

+98
-73
lines changed

13 files changed

+98
-73
lines changed

.template.config/templates/server/AntDesign.Pro.Template.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<PackageReference Include="AntDesign.Charts" Version="0.4.0" />
1111
<PackageReference Include="AntDesign.Extensions.Localization" Version="0.20.2.1" />
1212
<PackageReference Include="AntDesign.ProLayout" Version="0.20.2.1" />
13+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
1314
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
1415
</ItemGroup>
1516

.template.config/templates/server/_Imports.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@using Microsoft.AspNetCore.Components.Web
99
@using Microsoft.JSInterop
1010
@using AntDesign.Pro.Template
11+
@using AntDesign.Pro.Template.Layouts
1112
@using AntDesign.Extensions.Localization
1213
@using System.Globalization
1314
//#if (full)

.template.config/templates/wasm/AntDesign.Pro.Template.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
55
<RazorLangVersion>3.0</RazorLangVersion>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
68
</PropertyGroup>
79

810
<ItemGroup>
@@ -11,6 +13,7 @@
1113
<PackageReference Include="AntDesign.ProLayout" Version="0.20.2.1" />
1214
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
1315
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
16+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
1417
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
1518
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
1619
</ItemGroup>

.template.config/templates/wasm/_Imports.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@using Microsoft.AspNetCore.Components.WebAssembly.Http
1010
@using Microsoft.JSInterop
1111
@using AntDesign.Pro.Template
12+
@using AntDesign.Pro.Template.Layouts
1213
@using AntDesign.Extensions.Localization
1314
@using System.Globalization
1415
//#if (full)

.template.config/templates/webapp/src/AntDesign.Pro.Template.Client/AntDesign.Pro.Template.Client.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<PackageReference Include="AntDesign.ProLayout" Version="0.20.2.1" />
1515
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
1616
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
17+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
1718
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
1819
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
1920
</ItemGroup>

src/AntDesign.Pro/AntDesign.Pro.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
77
<AssemblyName>AntDesign.Pro.Template</AssemblyName>
88
<RootNamespace>AntDesign.Pro.Template</RootNamespace>
9-
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
10-
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
9+
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
10+
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
1111
</PropertyGroup>
1212

1313
<ItemGroup>
@@ -16,6 +16,7 @@
1616
<PackageReference Include="AntDesign.ProLayout" Version="0.20.2.1" />
1717
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
1818
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
19+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
1920
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
2021
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
2122
</ItemGroup>

src/AntDesign.Pro/GlobalUsings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
#else
66
global using AntDesign.Pro.Resources;
77
#endif
8+
9+
global using AntDesign;
Lines changed: 23 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
@namespace AntDesign.Pro.Template
1+
@namespace AntDesign.Pro.Template.Layouts
22
@inherits LayoutComponentBase
3-
@* //#if (full)*@
4-
@implements IDisposable
5-
@*#//#endif*@
63

74
<AntDesign.ProLayout.BasicLayout
85
Logo="@("https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg")"
@@ -31,80 +28,40 @@
3128
<FooterView Copyright="2021 Ant Design Blazor" Links="Links"></FooterView>
3229
</FooterRender>
3330
</AntDesign.ProLayout.BasicLayout>
31+
3432
<SettingDrawer />
3533

36-
@code
37-
{
34+
@code{
3835
bool collapsed;
39-
private MenuDataItem[] _menuData = { };
40-
41-
[Inject] private ReuseTabsService TabService { get; set; }
42-
//#if (full)
43-
44-
[Inject] private HttpClient HttpClient { get; set; }
45-
46-
[Inject] private ILocalizationService LocalizationService { get; set; }
47-
48-
private EventHandler<CultureInfo> _localizationChanged;
49-
50-
public void Dispose()
51-
{
52-
LocalizationService.LanguageChanged -= _localizationChanged;
53-
}
5436

55-
//#endif
56-
57-
protected override async Task OnInitializedAsync()
37+
public LinkItem[] Links =
5838
{
59-
#if IsNotFull
60-
_menuData = new[]{
61-
new MenuDataItem
39+
new LinkItem
40+
{
41+
Key = "Ant Design Blazor",
42+
Title = "Ant Design Blazor",
43+
Href = "https://antblazor.com",
44+
BlankTarget = true,
45+
},
46+
new LinkItem
6247
{
63-
Path = "/",
64-
Name = "welcome",
65-
Key = "welcome",
66-
Icon = "smile",
48+
Key = "github",
49+
Title = (RenderFragment)(@<Icon Type="github" />),
50+
Href = "https://github.com/ant-design-blazor/ant-design-pro-blazor",
51+
BlankTarget = true,
52+
},
53+
new LinkItem
54+
{
55+
Key = "Blazor",
56+
Title = "Blazor",
57+
Href = "https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor?WT.mc_id=DT-MVP-5003987",
58+
BlankTarget = true,
6759
}
68-
};
69-
#else
70-
_localizationChanged = (sender, args) => InvokeAsync(StateHasChanged);
71-
LocalizationService.LanguageChanged += _localizationChanged;
72-
_menuData = await HttpClient.GetFromJsonAsync<MenuDataItem[]>("data/menu.json");
73-
#endif
74-
}
75-
76-
public LinkItem[] Links { get; set; } =
77-
{
78-
new LinkItem
79-
{
80-
Key = "Ant Design Blazor",
81-
Title = "Ant Design Blazor",
82-
Href = "https://antblazor.com",
83-
BlankTarget = true,
84-
},
85-
new LinkItem
86-
{
87-
Key = "github",
88-
Title = (RenderFragment)(@<Icon Type="github" />),
89-
Href = "https://github.com/ant-design-blazor/ant-design-pro-blazor",
90-
BlankTarget = true,
91-
},
92-
new LinkItem
93-
{
94-
Key = "Blazor",
95-
Title = "Blazor",
96-
Href = "https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor?WT.mc_id=DT-MVP-5003987",
97-
BlankTarget = true,
98-
}
9960
};
10061

10162
void Toggle()
10263
{
10364
collapsed = !collapsed;
10465
}
10566

106-
void Reload()
107-
{
108-
TabService.ReloadPage();
109-
}
11067
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using AntDesign.Extensions.Localization;
2+
using AntDesign.ProLayout;
3+
using Microsoft.AspNetCore.Components;
4+
using System.Globalization;
5+
using System.Net.Http.Json;
6+
7+
namespace AntDesign.Pro.Template.Layouts
8+
{
9+
public partial class BasicLayout : LayoutComponentBase, IDisposable
10+
{
11+
private MenuDataItem[] _menuData;
12+
13+
[Inject] private ReuseTabsService TabService { get; set; }
14+
//#if (full)
15+
16+
[Inject] private HttpClient HttpClient { get; set; }
17+
18+
[Inject] private ILocalizationService LocalizationService { get; set; }
19+
20+
private EventHandler<CultureInfo> _localizationChanged;
21+
22+
//#endif
23+
24+
protected override async Task OnInitializedAsync()
25+
{
26+
#if IsNotFull
27+
_menuData = new[] {
28+
new MenuDataItem
29+
{
30+
Path = "/",
31+
Name = "welcome",
32+
Key = "welcome",
33+
Icon = "smile",
34+
}
35+
};
36+
#else
37+
_localizationChanged = (sender, args) => InvokeAsync(StateHasChanged);
38+
LocalizationService.LanguageChanged += _localizationChanged;
39+
_menuData = await HttpClient.GetFromJsonAsync<MenuDataItem[]>("data/menu.json");
40+
#endif
41+
}
42+
43+
void Reload()
44+
{
45+
TabService.ReloadPage();
46+
}
47+
48+
public void Dispose()
49+
{
50+
#if IsNotFull
51+
52+
#else
53+
LocalizationService.LanguageChanged -= _localizationChanged;
54+
#endif
55+
}
56+
57+
}
58+
}

src/AntDesign.Pro/Layouts/UserLayout.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@namespace AntDesign.Pro.Template
1+
@namespace AntDesign.Pro.Template.Layouts
22
@using OneOf
33
@inherits LayoutComponentBase
44

0 commit comments

Comments
 (0)