Skip to content

Commit

Permalink
fix: build error without full pages (#193)
Browse files Browse the repository at this point in the history
* fix: build error without full pages

* fix using
  • Loading branch information
ElderJames authored Aug 23, 2024
1 parent 808be9a commit 6710442
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PackageReference Include="AntDesign.Charts" Version="0.4.0" />
<PackageReference Include="AntDesign.Extensions.Localization" Version="0.20.2.1" />
<PackageReference Include="AntDesign.ProLayout" Version="0.20.2.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions .template.config/templates/server/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@using AntDesign.Pro.Template
@using AntDesign.Pro.Template.Layouts
@using AntDesign.Extensions.Localization
@using System.Globalization
//#if (full)
Expand Down
3 changes: 3 additions & 0 deletions .template.config/templates/wasm/AntDesign.Pro.Template.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand All @@ -11,6 +13,7 @@
<PackageReference Include="AntDesign.ProLayout" Version="0.20.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions .template.config/templates/wasm/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using AntDesign.Pro.Template
@using AntDesign.Pro.Template.Layouts
@using AntDesign.Extensions.Localization
@using System.Globalization
//#if (full)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageReference Include="AntDesign.ProLayout" Version="0.20.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
</ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions src/AntDesign.Pro/AntDesign.Pro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<PropertyGroup>
<TargetFramework>net8</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>AntDesign.Pro.Template</AssemblyName>
<RootNamespace>AntDesign.Pro.Template</RootNamespace>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,6 +16,7 @@
<PackageReference Include="AntDesign.ProLayout" Version="0.20.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/AntDesign.Pro/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
#else
global using AntDesign.Pro.Resources;
#endif

global using AntDesign;
89 changes: 23 additions & 66 deletions src/AntDesign.Pro/Layouts/BasicLayout.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
@namespace AntDesign.Pro.Template
@namespace AntDesign.Pro.Template.Layouts
@inherits LayoutComponentBase
@* //#if (full)*@
@implements IDisposable
@*#//#endif*@

<AntDesign.ProLayout.BasicLayout
Logo="@("https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg")"
Expand Down Expand Up @@ -31,80 +28,40 @@
<FooterView Copyright="2021 Ant Design Blazor" Links="Links"></FooterView>
</FooterRender>
</AntDesign.ProLayout.BasicLayout>

<SettingDrawer />

@code
{
@code{
bool collapsed;
private MenuDataItem[] _menuData = { };

[Inject] private ReuseTabsService TabService { get; set; }
//#if (full)
[Inject] private HttpClient HttpClient { get; set; }

[Inject] private ILocalizationService LocalizationService { get; set; }

private EventHandler<CultureInfo> _localizationChanged;

public void Dispose()
{
LocalizationService.LanguageChanged -= _localizationChanged;
}

//#endif
protected override async Task OnInitializedAsync()
public LinkItem[] Links =
{
#if IsNotFull
_menuData = new[]{
new MenuDataItem
new LinkItem
{
Key = "Ant Design Blazor",
Title = "Ant Design Blazor",
Href = "https://antblazor.com",
BlankTarget = true,
},
new LinkItem
{
Path = "/",
Name = "welcome",
Key = "welcome",
Icon = "smile",
Key = "github",
Title = (RenderFragment)(@<Icon Type="github" />),
Href = "https://github.com/ant-design-blazor/ant-design-pro-blazor",
BlankTarget = true,
},
new LinkItem
{
Key = "Blazor",
Title = "Blazor",
Href = "https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor?WT.mc_id=DT-MVP-5003987",
BlankTarget = true,
}
};
#else
_localizationChanged = (sender, args) => InvokeAsync(StateHasChanged);
LocalizationService.LanguageChanged += _localizationChanged;
_menuData = await HttpClient.GetFromJsonAsync<MenuDataItem[]>("data/menu.json");
#endif
}

public LinkItem[] Links { get; set; } =
{
new LinkItem
{
Key = "Ant Design Blazor",
Title = "Ant Design Blazor",
Href = "https://antblazor.com",
BlankTarget = true,
},
new LinkItem
{
Key = "github",
Title = (RenderFragment)(@<Icon Type="github" />),
Href = "https://github.com/ant-design-blazor/ant-design-pro-blazor",
BlankTarget = true,
},
new LinkItem
{
Key = "Blazor",
Title = "Blazor",
Href = "https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor?WT.mc_id=DT-MVP-5003987",
BlankTarget = true,
}
};

void Toggle()
{
collapsed = !collapsed;
}

void Reload()
{
TabService.ReloadPage();
}
}
58 changes: 58 additions & 0 deletions src/AntDesign.Pro/Layouts/BasicLayout.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using AntDesign.Extensions.Localization;

Check warning on line 1 in src/AntDesign.Pro/Layouts/BasicLayout.razor.cs

View workflow job for this annotation

GitHub Actions / publish-and-deploy

Possible null reference assignment. [/home/runner/work/ant-design-pro-blazor/ant-design-pro-blazor/src/AntDesign.Pro/AntDesign.Pro.csproj]

Check warning on line 1 in src/AntDesign.Pro/Layouts/BasicLayout.razor.cs

View workflow job for this annotation

GitHub Actions / publish-and-deploy

Non-nullable field '_menuData' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. [/home/runner/work/ant-design-pro-blazor/ant-design-pro-blazor/src/AntDesign.Pro/AntDesign.Pro.csproj]
using AntDesign.ProLayout;
using Microsoft.AspNetCore.Components;
using System.Globalization;
using System.Net.Http.Json;

namespace AntDesign.Pro.Template.Layouts
{
public partial class BasicLayout : LayoutComponentBase, IDisposable
{
private MenuDataItem[] _menuData;

[Inject] private ReuseTabsService TabService { get; set; }
//#if (full)

[Inject] private HttpClient HttpClient { get; set; }

[Inject] private ILocalizationService LocalizationService { get; set; }

private EventHandler<CultureInfo> _localizationChanged;

//#endif

protected override async Task OnInitializedAsync()
{
#if IsNotFull
_menuData = new[] {
new MenuDataItem
{
Path = "/",
Name = "welcome",
Key = "welcome",
Icon = "smile",
}
};
#else
_localizationChanged = (sender, args) => InvokeAsync(StateHasChanged);
LocalizationService.LanguageChanged += _localizationChanged;
_menuData = await HttpClient.GetFromJsonAsync<MenuDataItem[]>("data/menu.json");
#endif
}

void Reload()
{
TabService.ReloadPage();
}

public void Dispose()
{
#if IsNotFull

#else
LocalizationService.LanguageChanged -= _localizationChanged;
#endif
}

}
}
2 changes: 1 addition & 1 deletion src/AntDesign.Pro/Layouts/UserLayout.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@namespace AntDesign.Pro.Template
@namespace AntDesign.Pro.Template.Layouts
@using OneOf
@inherits LayoutComponentBase

Expand Down
1 change: 0 additions & 1 deletion src/AntDesign.Pro/Pages/List/Search/SearchList.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@namespace AntDesign.Pro.Template.Pages.List
@inherits LayoutComponentBase
@layout AntDesign.Pro.Template.BasicLayout

<PageContainer Title="Search"
TabList="_tabList"
Expand Down
2 changes: 1 addition & 1 deletion src/AntDesign.Pro/Routes.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Router AppAssembly="typeof(Program).Assembly">
<Found Context="routeData">
<CascadingValue Value="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(AntDesign.Pro.Template.BasicLayout)" />
<RouteView RouteData="routeData" DefaultLayout="typeof(AntDesign.Pro.Template.Layouts.BasicLayout)" />
</CascadingValue>
<FocusOnNavigate RouteData="routeData" Selector="h1" />
</Found>
Expand Down
1 change: 1 addition & 0 deletions src/AntDesign.Pro/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@using AntDesign.Charts
@using AntDesign.ProLayout
@using AntDesign.Pro.Template
@using AntDesign.Pro.Template.Layouts
@using AntDesign.Pro.Template.Models
@using AntDesign.Pro.Template.Services
@using AntDesign.Extensions.Localization
Expand Down

0 comments on commit 6710442

Please sign in to comment.