7 changed files with 239 additions and 42 deletions
@ -1,20 +1,23 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
using System.Linq; |
using System.Linq; |
||||
using System.Text; |
using System.Text; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Microsoft.Extensions.DependencyInjection; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Volo.Abp.AspNetCore.Components.Web.Theming.Routing; |
using Volo.Abp.AspNetCore.Components.Web.Theming.Routing; |
||||
using Volo.Abp.Modularity; |
using Volo.Abp.Autofac.WebAssembly; |
||||
|
using Volo.Abp.Modularity; |
||||
namespace Lion.AbpPro.Blazor.Layout.AntDesignTheme |
|
||||
{ |
namespace Lion.AbpPro.Blazor.Layout.AntDesignTheme |
||||
public class AbpProBlazorLayoutAntDesignThemeModule: AbpModule |
{ |
||||
{ |
[DependsOn( |
||||
|
typeof(AbpAutofacWebAssemblyModule) |
||||
public override void ConfigureServices(ServiceConfigurationContext context) |
)] |
||||
{ |
public class AbpProBlazorLayoutAntDesignThemeModule : AbpModule |
||||
context.Services.AddAntDesign(); |
{ |
||||
} |
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
} |
{ |
||||
} |
context.Services.AddAntDesign(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|||||
@ -0,0 +1,45 @@ |
|||||
|
@namespace Lion.AbpPro.Blazor.Layout.AntDesignTheme.Components.GlobalHeader |
||||
|
@inherits AntDomComponentBase |
||||
|
<Space Class="@ClassMapper.Class" Size="@("24")"> |
||||
|
|
||||
|
<!--通知--> |
||||
|
<SpaceItem> |
||||
|
<NoticeIcon ClearText="Empty" |
||||
|
ViewMoreText="see more" |
||||
|
Count="0" |
||||
|
OnClear="HandleClear" |
||||
|
OnViewMore="HandleViewMore"> |
||||
|
<NoticeList TabKey="message" |
||||
|
Title="消息" |
||||
|
EmptyText="你已阅读所有站内消息" |
||||
|
ShowViewMore=true |
||||
|
Data="null" /> |
||||
|
<NoticeList TabKey="notification" |
||||
|
Title="通知" |
||||
|
EmptyText="你已阅读所有通知消息" |
||||
|
ShowViewMore=true |
||||
|
Data="null" /> |
||||
|
</NoticeIcon> |
||||
|
</SpaceItem> |
||||
|
|
||||
|
<!--语言--> |
||||
|
<SpaceItem> |
||||
|
<SelectLang OnItemSelected="HandleSelectLang" LanguageIcons="_languageIcons" LanguageLabels="_languageLabels" Locales="_locales" /> |
||||
|
</SpaceItem> |
||||
|
|
||||
|
<!--账户信息--> |
||||
|
<SpaceItem> |
||||
|
<AvatarDropdown Name="admin" |
||||
|
Avatar="https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png" |
||||
|
MenuItems="AvatarMenuItems" |
||||
|
OnItemSelected="HandleSelectUser" /> |
||||
|
</SpaceItem> |
||||
|
|
||||
|
<!--最大化--> |
||||
|
<SpaceItem> |
||||
|
<AntDesign.Tooltip Placement="@Placement.Bottom" Title="FullScreenTipMsg"> |
||||
|
<Button Icon="fullscreen" Type="@ButtonType.Text"></Button> |
||||
|
</AntDesign.Tooltip> |
||||
|
</SpaceItem> |
||||
|
|
||||
|
</Space> |
||||
@ -0,0 +1,140 @@ |
|||||
|
using AntDesign; |
||||
|
using AntDesign.ProLayout; |
||||
|
using Blazored.LocalStorage; |
||||
|
using Lion.AbpPro.Users; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Globalization; |
||||
|
using System.Linq; |
||||
|
using System.Net.Http; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Lion.AbpPro.Blazor.Layout.AntDesignTheme.Components.GlobalHeader |
||||
|
{ |
||||
|
public partial class RightContent : ITransientDependency |
||||
|
{ |
||||
|
private readonly HttpClient _httpClient; |
||||
|
private readonly ILocalStorageService _localStorage; |
||||
|
private readonly MessageService _messageService; |
||||
|
private readonly NavigationManager _navigationManager; |
||||
|
private IDictionary<string, string> _languageLabels = new Dictionary<string, string>(); |
||||
|
private string[] _locales; |
||||
|
private IDictionary<string, string> _languageIcons = new Dictionary<string, string>(); |
||||
|
public RightContent( |
||||
|
HttpClient httpClient, |
||||
|
ILocalStorageService localStorage, |
||||
|
MessageService messageService, |
||||
|
NavigationManager navigationManager |
||||
|
) |
||||
|
{ |
||||
|
_httpClient = httpClient; |
||||
|
_localStorage = localStorage; |
||||
|
_messageService = messageService; |
||||
|
_navigationManager = navigationManager; |
||||
|
} |
||||
|
|
||||
|
public string FullScreenTipMsg { get; set; } = "全屏"; |
||||
|
|
||||
|
public AvatarMenuItem[] AvatarMenuItems { get; } = new AvatarMenuItem[] |
||||
|
{ |
||||
|
new() { Key = "setting", IconType = "setting", Option = "个人设置"}, |
||||
|
new() { Key = "center", IconType = "user", Option = "锁定屏幕"}, |
||||
|
new() { IsDivider = true }, |
||||
|
new() { Key = "logout", IconType = "logout", Option = "注销"} |
||||
|
}; |
||||
|
protected override async Task OnInitializedAsync() |
||||
|
{ |
||||
|
await base.OnInitializedAsync(); |
||||
|
|
||||
|
ClearClassMap(); |
||||
|
|
||||
|
_languageLabels.Add("zh-Hans", "简体中文"); |
||||
|
_languageLabels.Add("en", "English"); |
||||
|
|
||||
|
_languageIcons.Add("zh-Hans", "\ud83c\udde8\ud83c\uddf3"); |
||||
|
_languageIcons.Add("en", "\ud83c\uddfa\ud83c\uddf8"); |
||||
|
|
||||
|
_locales = new string[] { "zh-Hans", "en" }; |
||||
|
} |
||||
|
|
||||
|
private void ClearClassMap() |
||||
|
{ |
||||
|
ClassMapper.Clear().Add("right"); |
||||
|
} |
||||
|
|
||||
|
public async Task HandleClear(string key) |
||||
|
{ |
||||
|
switch (key) |
||||
|
{ |
||||
|
case "notification": |
||||
|
// TODO
|
||||
|
break; |
||||
|
case "message": |
||||
|
// TODO
|
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
await _messageService.Success($"清空了{key}"); |
||||
|
} |
||||
|
|
||||
|
public async Task HandleViewMore(string key) |
||||
|
{ |
||||
|
await _messageService.Info("查看更多..."); |
||||
|
} |
||||
|
|
||||
|
public async Task HandleSelectUser(MenuItem item) |
||||
|
{ |
||||
|
switch (item.Key) |
||||
|
{ |
||||
|
case "center": |
||||
|
_navigationManager.NavigateTo("/account/center"); |
||||
|
break; |
||||
|
case "setting": |
||||
|
_navigationManager.NavigateTo("/account/settings"); |
||||
|
break; |
||||
|
case "logout": |
||||
|
|
||||
|
// 先调用服务端登出接口 TODO
|
||||
|
|
||||
|
// 再清楚本地应用token缓存
|
||||
|
await _localStorage.RemoveItemAsync("access_token"); |
||||
|
_httpClient.DefaultRequestHeaders.Authorization = null; |
||||
|
|
||||
|
_navigationManager.NavigateTo("/user/login", true); |
||||
|
break; |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
await Task.CompletedTask; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 多语言
|
||||
|
/// </summary>
|
||||
|
/// <param name="item"></param>
|
||||
|
public async Task HandleSelectLang(MenuItem item) |
||||
|
{ |
||||
|
var langText = item.Key switch |
||||
|
{ |
||||
|
"zh-Hans" => "简体中文", |
||||
|
_ => "English", |
||||
|
}; |
||||
|
string lang = item.Key; |
||||
|
await _localStorage.SetItemAsStringAsync("lang", lang); |
||||
|
|
||||
|
//await _accountAppService.ChangeLanguageAsync(lang); //TODO
|
||||
|
|
||||
|
CultureInfo culture = new(lang); |
||||
|
CultureInfo.DefaultThreadCurrentCulture = culture; |
||||
|
CultureInfo.DefaultThreadCurrentUICulture = culture; |
||||
|
|
||||
|
await _messageService.Success($"切换【{langText}】成功!"); |
||||
|
|
||||
|
var currentUrl = _navigationManager.Uri; |
||||
|
_navigationManager.NavigateTo(currentUrl, true); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,20 +1,26 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
||||
<Import Project="..\..\..\common.props" /> |
<Import Project="..\..\..\common.props" /> |
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>net6.0</TargetFramework> |
<TargetFramework>net6.0</TargetFramework> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<SupportedPlatform Include="browser" /> |
<SupportedPlatform Include="browser" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="AntDesign" Version="0.10.2" /> |
<PackageReference Include="AntDesign" Version="0.10.2" /> |
||||
|
<PackageReference Include="AntDesign.ProLayout" Version="0.1.9" /> |
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(MicrosoftVersion)" /> |
<PackageReference Include="Blazored.LocalStorage" Version="4.1.5" /> |
||||
<PackageReference Include="Volo.Abp.AspNetCore.Components.Web.Theming" Version="$(AbpPackageVersion)" /> |
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(MicrosoftVersion)" /> |
||||
<PackageReference Include="Volo.Abp.Core" Version="$(AbpPackageVersion)" /> |
<PackageReference Include="Volo.Abp.Autofac.WebAssembly" Version="$(AbpPackageVersion)" /> |
||||
</ItemGroup> |
<PackageReference Include="Volo.Abp.AspNetCore.Components.Web.Theming" Version="$(AbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.Core" Version="$(AbpPackageVersion)" /> |
||||
</Project> |
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Lion.AbpPro.HttpApi.Client\Lion.AbpPro.HttpApi.Client.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
|
|||||
@ -1,4 +1,5 @@ |
|||||
@using Microsoft.AspNetCore.Components.Web |
@using Microsoft.AspNetCore.Components.Web |
||||
@using System.Net.Http |
@using System.Net.Http |
||||
@using System.Net.Http.Json |
@using System.Net.Http.Json |
||||
@using AntDesign |
@using AntDesign |
||||
|
@using AntDesign.ProLayout |
||||
Loading…
Reference in new issue