mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-02 03:59:14 +08:00
!1174 chore(#I3CBS1): use props file set TargetFramework
* chore: 统一设置框架 * chore: net5.0 框架消除 8620 警告 * refactor: 重构参数集合可为空消除警告
This commit is contained in:
parent
217cc078ca
commit
29bbffe68e
@ -65,9 +65,6 @@ EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest", "test\UnitTest\UnitTest.csproj", "{190F25CF-C6F9-4964-97E9-F6A912D527AE}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "extensions", "extensions", "{22328011-53B3-447A-B781-AC3C196B2847}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
src\Extensions\Directory.Build.props = src\Extensions\Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wasm", "wasm", "{C8E79F4C-8C55-4E13-96B5-3D2BD6A07B74}"
|
||||
EndProject
|
||||
|
@ -1,7 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<IsWebProject>true</IsWebProject>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<IsPackable>true</IsPackable>
|
||||
<Version>5.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
@ -17,13 +17,9 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
/// </summary>
|
||||
public sealed partial class Consoles : IDisposable
|
||||
{
|
||||
private readonly BlockingCollection<ConsoleMessageItem> _messages = new BlockingCollection<ConsoleMessageItem>(new ConcurrentQueue<ConsoleMessageItem>());
|
||||
private readonly BlockingCollection<ConsoleMessageItem> _messages2 = new BlockingCollection<ConsoleMessageItem>(new ConcurrentQueue<ConsoleMessageItem>());
|
||||
|
||||
private readonly CancellationTokenSource _cancelTokenSource = new CancellationTokenSource();
|
||||
|
||||
private IEnumerable<ConsoleMessageItem> Messages => _messages;
|
||||
private IEnumerable<ConsoleMessageItem> ColorMessages => _messages2;
|
||||
private ConcurrentQueue<ConsoleMessageItem> Messages { get; set; } = new();
|
||||
private ConcurrentQueue<ConsoleMessageItem> ColorMessages { get; set; } = new();
|
||||
private readonly CancellationTokenSource _cancelTokenSource = new();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -38,23 +34,20 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
do
|
||||
{
|
||||
_locker.WaitOne();
|
||||
if (!_messages.IsAddingCompleted)
|
||||
Messages.Enqueue(new ConsoleMessageItem { Message = $"{DateTimeOffset.Now}: Dispatch Message" });
|
||||
|
||||
ColorMessages.Enqueue(new ConsoleMessageItem { Message = $"{DateTimeOffset.Now}: Dispatch Message", Color = GetColor() });
|
||||
|
||||
if (Messages.Count > 8)
|
||||
{
|
||||
_messages.Add(new ConsoleMessageItem { Message = $"{DateTimeOffset.Now}: Dispatch Message" });
|
||||
|
||||
_messages2.Add(new ConsoleMessageItem { Message = $"{DateTimeOffset.Now}: Dispatch Message", Color = GetColor() });
|
||||
|
||||
if (_messages.Count > 8)
|
||||
{
|
||||
_messages.TryTake(out var _);
|
||||
}
|
||||
|
||||
if (_messages2.Count > 12)
|
||||
{
|
||||
_messages2.TryTake(out var _);
|
||||
}
|
||||
await InvokeAsync(StateHasChanged);
|
||||
Messages.TryDequeue(out var _);
|
||||
}
|
||||
|
||||
if (ColorMessages.Count > 12)
|
||||
{
|
||||
ColorMessages.TryDequeue(out var _);
|
||||
}
|
||||
await InvokeAsync(StateHasChanged);
|
||||
_locker.Set();
|
||||
await Task.Delay(2000, _cancelTokenSource.Token);
|
||||
}
|
||||
@ -62,7 +55,7 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
});
|
||||
}
|
||||
|
||||
private Color GetColor()
|
||||
private static Color GetColor()
|
||||
{
|
||||
var second = DateTime.Now.Second;
|
||||
return (second % 3) switch
|
||||
@ -73,22 +66,19 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
};
|
||||
}
|
||||
|
||||
private readonly AutoResetEvent _locker = new AutoResetEvent(true);
|
||||
private readonly AutoResetEvent _locker = new(true);
|
||||
|
||||
private void OnClear()
|
||||
{
|
||||
_locker.WaitOne();
|
||||
if (!_messages.IsAddingCompleted)
|
||||
while (!Messages.IsEmpty)
|
||||
{
|
||||
while (_messages.Count > 0)
|
||||
{
|
||||
_messages.TryTake(out var _);
|
||||
}
|
||||
Messages.TryDequeue(out var _);
|
||||
}
|
||||
_locker.Set();
|
||||
}
|
||||
|
||||
private IEnumerable<AttributeItem> GetItemAttributes()
|
||||
private static IEnumerable<AttributeItem> GetItemAttributes()
|
||||
{
|
||||
return new AttributeItem[]
|
||||
{
|
||||
@ -113,7 +103,7 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IEnumerable<AttributeItem> GetAttributes()
|
||||
private static IEnumerable<AttributeItem> GetAttributes()
|
||||
{
|
||||
return new AttributeItem[]
|
||||
{
|
||||
@ -187,7 +177,6 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_messages.CompleteAdding();
|
||||
_cancelTokenSource.Cancel();
|
||||
_cancelTokenSource.Dispose();
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
/// <returns></returns>
|
||||
public async Task UpdateAsync()
|
||||
{
|
||||
await RootPage.SetParametersAsync(ParameterView.FromDictionary(new Dictionary<string, object>()
|
||||
await RootPage.SetParametersAsync(ParameterView.FromDictionary(new Dictionary<string, object?>()
|
||||
{
|
||||
[nameof(RootPage.IsFullSide)] = IsFullSide,
|
||||
[nameof(RootPage.IsFixedFooter)] = IsFixedFooter && ShowFooter,
|
||||
|
@ -20,7 +20,7 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
{
|
||||
var ret = new List<NavLink>();
|
||||
var link = new NavLink();
|
||||
link.SetParametersAsync(ParameterView.FromDictionary(new Dictionary<string, object>()
|
||||
link.SetParametersAsync(ParameterView.FromDictionary(new Dictionary<string, object?>()
|
||||
{
|
||||
["href"] = WebsiteOption.Value.AdminUrl,
|
||||
["class"] = "nav-link nav-item",
|
||||
@ -38,7 +38,7 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
/// 获得属性方法
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
|
||||
private static IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
|
||||
{
|
||||
// TODO: 移动到数据库中
|
||||
new AttributeItem() {
|
||||
|
@ -47,7 +47,7 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
private static Task AddTab(Tab tabset)
|
||||
{
|
||||
var text = $"Tab {tabset.Items.Count() + 1}";
|
||||
tabset.AddTab(new Dictionary<string, object>
|
||||
tabset.AddTab(new Dictionary<string, object?>
|
||||
{
|
||||
[nameof(TabItem.Text)] = text,
|
||||
[nameof(TabItem.IsActive)] = true,
|
||||
@ -105,7 +105,7 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void AddTabItem(string text) => TabSetMenu.AddTab(new Dictionary<string, object>
|
||||
private void AddTabItem(string text) => TabSetMenu.AddTab(new Dictionary<string, object?>
|
||||
{
|
||||
[nameof(TabItem.Text)] = text,
|
||||
[nameof(TabItem.IsActive)] = true,
|
||||
|
@ -18,7 +18,7 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
/// </summary>
|
||||
public sealed partial class Timelines
|
||||
{
|
||||
private readonly BlockingCollection<ConsoleMessageItem> _messages = new(new ConcurrentQueue<ConsoleMessageItem>());
|
||||
private readonly ConcurrentQueue<ConsoleMessageItem> _messages = new();
|
||||
|
||||
private readonly CancellationTokenSource _cancelTokenSource = new();
|
||||
|
||||
@ -52,16 +52,13 @@ namespace BootstrapBlazor.Shared.Pages
|
||||
do
|
||||
{
|
||||
_locker.WaitOne();
|
||||
if (!_messages.IsAddingCompleted)
|
||||
{
|
||||
_messages.Add(new ConsoleMessageItem { Message = $"{DateTimeOffset.Now}: Dispatch Message", Color = GetColor() });
|
||||
_messages.Enqueue(new ConsoleMessageItem { Message = $"{DateTimeOffset.Now}: Dispatch Message", Color = GetColor() });
|
||||
|
||||
if (_messages.Count > 8)
|
||||
{
|
||||
_messages.TryTake(out var _);
|
||||
}
|
||||
await InvokeAsync(StateHasChanged);
|
||||
if (_messages.Count > 8)
|
||||
{
|
||||
_messages.TryDequeue(out var _);
|
||||
}
|
||||
await InvokeAsync(StateHasChanged);
|
||||
_locker.Set();
|
||||
await Task.Delay(2000, _cancelTokenSource.Token);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<IsPackable>true</IsPackable>
|
||||
<PackageIcon>logo.png</PackageIcon>
|
||||
<Version>5.0.22-beta02</Version>
|
||||
|
@ -1,69 +0,0 @@
|
||||
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
// Website: https://www.blazor.zone or https://argozhang.github.io/
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BootstrapBlazor.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// 动态组件类
|
||||
/// </summary>
|
||||
[Obsolete("由于 NET6.0 新增加了一个 DynamicComponent 类,组件原 DynamicComponent 类更改为 BootstrapDynamicComponent", true)]
|
||||
public class DynamicComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// 获得/设置 组件参数集合
|
||||
/// </summary>
|
||||
private IEnumerable<KeyValuePair<string, object>> Parameters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 组件类型
|
||||
/// </summary>
|
||||
public Type ComponentType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="componentType"></param>
|
||||
/// <param name="parameters">TCom 组件所需要的参数集合</param>
|
||||
public DynamicComponent(Type componentType, IEnumerable<KeyValuePair<string, object>> parameters)
|
||||
{
|
||||
ComponentType = componentType;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建自定义组件方法
|
||||
/// </summary>
|
||||
/// <typeparam name="TCom"></typeparam>
|
||||
/// <param name="parameters">TCom 组件所需要的参数集合</param>
|
||||
/// <returns></returns>
|
||||
public static DynamicComponent CreateComponent<TCom>(IEnumerable<KeyValuePair<string, object>> parameters) where TCom : IComponent => new(typeof(TCom), parameters);
|
||||
|
||||
/// <summary>
|
||||
/// 创建自定义组件方法
|
||||
/// </summary>
|
||||
/// <typeparam name="TCom"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static DynamicComponent CreateComponent<TCom>() where TCom : IComponent => CreateComponent<TCom>(Enumerable.Empty<KeyValuePair<string, object>>());
|
||||
|
||||
/// <summary>
|
||||
/// 创建组件实例并渲染
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public RenderFragment Render() => builder =>
|
||||
{
|
||||
var index = 0;
|
||||
builder.OpenComponent(index++, ComponentType);
|
||||
if (Parameters.Any())
|
||||
{
|
||||
builder.AddMultipleAttributes(index++, Parameters);
|
||||
}
|
||||
builder.CloseComponent();
|
||||
};
|
||||
}
|
||||
}
|
@ -440,7 +440,7 @@ namespace BootstrapBlazor.Components
|
||||
closable ??= Options.Closable ?? option.Closable ?? true;
|
||||
Options.Reset();
|
||||
|
||||
AddTabItem(new Dictionary<string, object>
|
||||
AddTabItem(new Dictionary<string, object?>
|
||||
{
|
||||
[nameof(TabItem.Text)] = GetTabText(text, context.Segments),
|
||||
[nameof(TabItem.Url)] = url,
|
||||
@ -475,13 +475,13 @@ namespace BootstrapBlazor.Components
|
||||
/// 添加 TabItem 方法
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
public void AddTab(Dictionary<string, object> parameters)
|
||||
public void AddTab(Dictionary<string, object?> parameters)
|
||||
{
|
||||
AddTabItem(parameters);
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void AddTabItem(Dictionary<string, object> parameters)
|
||||
private void AddTabItem(Dictionary<string, object?> parameters)
|
||||
{
|
||||
var item = TabItem.Create(parameters);
|
||||
if (item.IsActive)
|
||||
|
@ -81,12 +81,12 @@ namespace BootstrapBlazor.Components
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
public static TabItem Create(Dictionary<string, object> parameters)
|
||||
public static TabItem Create(Dictionary<string, object?> parameters)
|
||||
{
|
||||
var item = new TabItem();
|
||||
if (parameters.TryGetValue(nameof(Url), out var url))
|
||||
{
|
||||
parameters[nameof(Url)] = ((string)url).TrimStart('/');
|
||||
parameters[nameof(Url)] = url?.ToString()?.TrimStart('/');
|
||||
}
|
||||
var _ = item.SetParametersAsync(ParameterView.FromDictionary(parameters));
|
||||
return item;
|
||||
|
@ -1,8 +1,9 @@
|
||||
<Project>
|
||||
<Project>
|
||||
|
||||
<Import Project="..\Directory.Build.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RepositoryUrl>https://github.com/dotnetcore/BootstrapBlazor.git</RepositoryUrl>
|
||||
<PackageProjectUrl>https://argozhang.github.io</PackageProjectUrl>
|
||||
<PackageTags>Bootstrap Blazor WebAssembly wasm UI Components</PackageTags>
|
||||
@ -13,6 +14,10 @@
|
||||
<DocumentationFile>$(MSBuildProjectName).xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0'">
|
||||
<NoWarn>1701;1702;8620</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||
|
@ -3,7 +3,6 @@
|
||||
<Import Project="..\Directory.Build.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<IsPackable>true</IsPackable>
|
||||
<PackageIcon>logo.png</PackageIcon>
|
||||
<Version>5.0.11</Version>
|
||||
|
@ -1,7 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
|
||||
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
|
||||
</PropertyGroup>
|
||||
|
@ -1,16 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<IsWebProject>true</IsWebProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.4" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<IsWebProject>true</IsWebProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BootstrapBlazor.WebAssembly.ClientHost\BootstrapBlazor.WebAssembly.ClientHost.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BootstrapBlazor.WebAssembly.ClientHost\BootstrapBlazor.WebAssembly.ClientHost.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user