Skip to content

Commit

Permalink
1. 表格单元格<util-td> 添加 tooltip 相关属性.
Browse files Browse the repository at this point in the history
2. 新增Spa管道中间件,由于微软已放弃维护, 故从 Microsoft.AspNetCore.SpaServices 复制源码进行修改.
3. IAppBuilder 扩展方法 AddNgZorro ,新增 EnableWatchRazor 选项, 用于启用Razor监视服务 ,并默认开启.
4. WebApplication 扩展方法 UseNgZorro , 新增 isAutoStartAngularServer 参数,用于自动启动Angular服务器, 并默认开启.
5. 修复描述列表项 <util-descriptions-item> 显示数值类型不正确的bug.
6. 修复具有嵌套列的情况下表格设置加载列不正确的bug.
  • Loading branch information
UtilCore committed Mar 28, 2024
1 parent 66926b2 commit 139753d
Show file tree
Hide file tree
Showing 66 changed files with 2,144 additions and 173 deletions.
2 changes: 1 addition & 1 deletion build/version.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<VersionMajor>8</VersionMajor>
<VersionMinor>0</VersionMinor>
<VersionPatch>8</VersionPatch>
<VersionPatch>9</VersionPatch>
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
Expand Down
28 changes: 2 additions & 26 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,6 @@ Util 配套代码生成器, 简单易用, 可解决大部分机械工作.

## Util Angular UI 特点

- ### 使用 Visual Studio 开发工具

前端开发一般使用 Visual Studio Code , 不过 Util Angular UI主要使用 Razor 页面,使用 Visual Studio 更方便.

- ### 组件扩展支持

除了支持 Ng Zorro 原生功能外,Util UI还对常用组件进行了扩展.
Expand Down Expand Up @@ -580,31 +576,11 @@ Util Angular UI 主要由 util-angular 和 Util.Ui.NgZorro 两个库提供支持

## Util Angular UI 已知缺陷

Util Angular UI 在提供大量支持的同时,也存在一些缺陷.

- ### 开发阶段运行比较缓慢

与 Visual Studio Code 相比,使用 Visual Studio 开发 Angular 项目要慢一些,如果使用了 Resharper 插件,则会更慢.

除开发工具影响外, Util Angular UI 在开发阶段需要启用 Angular JIT( 即时编译 ), 运行会变慢.

另外, Util Angular UI 在开发阶段需要访问 Razor 页面,每当项目启动,Angular 主模块加载的所有组件都会发出 Razor 页面请求.

不过运行缓慢仅存在于开发阶段,一旦发布,则与纯前端开发方式的运行速度相同.

- ### 无法使用 Angular 常规延迟加载方式

你不能使用 loadChildren 延迟加载模块,这是因为开发阶段组件的 templateUrl 指向 Razor 页面地址, 必须使用 Angular JIT 模式,等待运行时再获取组件模板.

这个问题从 Angular 13 开始出现, Angular 13弃用了传统的视图引擎, 使用 loadChildren 加载指向 Razor 页面地址的组件会报异常.

解决它的方法是使用微前端方案延迟加载模块, 当然你也可以回退到 Angular 13之前的版本.

在同一个 Util Angular UI 项目中,你必须把所有的子模块加载到主模块中,并配置微前端将子模块发布为可独立加载包.
Util Angular UI 所有已知缺陷均已解决.

## Util Angular UI 适合你吗?

Util Angular UI 是为 .Net 全栈工程师准备的,如果你更喜欢使用 Visual Studio 开发,喜欢代码提示,喜欢更简洁的语法,希望开发的成本更低,它就适合你.
Util Angular UI 是为 .Net 全栈工程师准备的,如果你喜欢更简洁的语法,希望开发的成本更低,它就适合你.

## 参考应用框架

Expand Down
4 changes: 2 additions & 2 deletions src/Util.AspNetCore/Helpers/Web.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ public static async Task DownloadAsync( byte[] bytes, string fileName, Encoding
fileName = fileName.Replace( " ", "" );
fileName = UrlEncode( fileName, encoding );
Response.ContentType = "application/octet-stream";
Response.Headers.Add( "Content-Disposition", $"attachment; filename={fileName}" );
Response.Headers.Add( "Content-Length", bytes.Length.ToString() );
Response.Headers.Append( "Content-Disposition", $"attachment; filename={fileName}" );
Response.Headers.Append( "Content-Length", bytes.Length.ToString() );
await Response.Body.WriteAsync( bytes, 0, bytes.Length );
}

Expand Down
4 changes: 4 additions & 0 deletions src/Util.Core/Helpers/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public static class Environment {
/// 换行符
/// </summary>
public static string NewLine => System.Environment.NewLine;
/// <summary>
/// 是否测试环境
/// </summary>
public static bool IsTest { get; set; }

/// <summary>
/// 设置环境变量
Expand Down
10 changes: 9 additions & 1 deletion src/Util.Core/Helpers/Url.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public static string JoinPath( params string[] paths ) {
return string.Empty;
var firstPath = paths.First();
var lastPath = paths.Last();
string schema = string.Empty;
if ( firstPath.StartsWith( "http:", StringComparison.OrdinalIgnoreCase ) )
schema = "http://";
if ( firstPath.StartsWith( "https:", StringComparison.OrdinalIgnoreCase ) )
schema = "https://";
paths = paths.Select( t => t.Trim( '/' ) ).ToArray();
var result = Path.Combine( paths ).Replace( @"\", "/" );
if ( paths.Any( path => path.StartsWith( "." ) ) ) {
Expand All @@ -26,6 +31,9 @@ public static string JoinPath( params string[] paths ) {
result = $"/{result}";
if ( lastPath.EndsWith( '/' ) )
result = $"{result}/";
return result;
result = result.RemoveStart( "http:/" ).RemoveStart( "https:/" );
if (schema.IsEmpty())
return result;
return schema + result.RemoveStart( "/" );
}
}
8 changes: 5 additions & 3 deletions src/Util.Generators.Razor/RazorTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Util.Generators.Templates;
using Util.Templates;

namespace Util.Generators.Razor;
namespace Util.Generators.Razor;

/// <summary>
/// Razor模板
Expand Down Expand Up @@ -82,8 +82,10 @@ protected virtual async Task<string> RenderResult( EntityContext context ) {
/// </summary>
/// <param name="context">实体上下文</param>
/// <param name="result">渲染结果</param>
protected virtual async Task WriteFile( EntityContext context,string result ) {
if( context.Output.Path.IsEmpty() )
protected virtual async Task WriteFile( EntityContext context, string result ) {
if ( context.Output.Path.IsEmpty() )
return;
if ( result.IsEmpty() )
return;
await Util.Helpers.File.WriteAsync( context.Output.Path, result );
}
Expand Down
6 changes: 3 additions & 3 deletions src/Util.Logging.Serilog/02-Util.Logging.Serilog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.3" />
<PackageReference Include="Serilog.Sinks.Seq" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
31 changes: 24 additions & 7 deletions src/Util.Ui.Angular/Extensions/ConfigExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Util.Ui.Angular.Configs;
using Util.Ui.Configs;

namespace Util.Ui.Angular.Extensions;
namespace Util.Ui.Angular.Extensions;

/// <summary>
/// 配置扩展
Expand All @@ -13,13 +13,30 @@ public static class ConfigExtensions {
/// <param name="config">配置</param>
public static Config CopyRemoveAttributes( this Config config ) {
var result = config.Copy();
result.RemoveAttribute( UiConst.Id );
result.RemoveAttribute( AngularConst.RawId );
result.RemoveAttribute( UiConst.Name );
result.RemoveAttribute( AngularConst.BindName );
result.RemoveAttribute( UiConst.Style );
result.RemoveAttribute( UiConst.Class );
result.OutputAttributes.Clear();
result.AllAttributes.Clear();
LoadConfig( config, result, UiConst.Required );
LoadConfig( config, result, UiConst.RequiredMessage );
LoadConfig( config, result, UiConst.Suffix );
LoadConfig( config, result, AngularConst.BindSuffix );
LoadConfig( config, result, UiConst.Extra );
LoadConfig( config, result, AngularConst.BindExtra );
LoadConfig( config, result, UiConst.ErrorTip );
LoadConfig( config, result, AngularConst.BindErrorTip );
LoadConfig( config, result, UiConst.SuccessTip );
LoadConfig( config, result, AngularConst.BindSuccessTip );
LoadConfig( config, result, UiConst.ValidatingTip );
LoadConfig( config, result, AngularConst.BindValidatingTip );
LoadConfig( config, result, UiConst.WarningTip );
LoadConfig( config, result, AngularConst.BindWarningTip );
return result;
}

/// <summary>
/// 加载配置
/// </summary>
private static void LoadConfig( Config from, Config to, string name ) {
var value = from.GetValue( name );
to.SetAttribute( name, value );
}
}
6 changes: 6 additions & 0 deletions src/Util.Ui.NgZorro/AppBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public static IAppBuilder AddNgZorro( this IAppBuilder builder, Action<NgZorroOp
services.TryAddSingleton<IRazorWatchService, RazorWatchService>();
services.TryAddSingleton<IPartViewPathResolver, PartViewPathResolver>();
services.TryAddSingleton<IPartViewPathFinder, PartViewPathFinder>();
if ( options.EnableWatchRazor )
services.AddHostedService<WatchHostedService>();
ConfigSpaStaticFiles( services, options );
ConfigRazorOptions( services, options );
ConfigNgZorroOptions( services, setupAction );
Expand All @@ -56,7 +58,11 @@ void Action( RazorOptions t ) {
t.GenerateHtmlBasePath = options.GenerateHtmlBasePath;
t.GenerateHtmlFolder = options.GenerateHtmlFolder;
t.GenerateHtmlSuffix = options.GenerateHtmlSuffix;
t.EnableWatchRazor = options.EnableWatchRazor;
t.StartInitDelay = options.StartInitDelay;
t.HtmlRenderDelayOnRazorChange = options.HtmlRenderDelayOnRazorChange;
t.EnablePreheat = options.EnablePreheat;
t.EnableOverrideHtml = options.EnableOverrideHtml;
}
services.Configure( (Action<RazorOptions>)Action );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Razor.TagHelpers;
using Util.Ui.Angular.TagHelpers;
using Util.Ui.Configs;
using Util.Ui.NgZorro.Components.Buttons.Renders;
using Util.Ui.NgZorro.Enums;
using Util.Ui.Renders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ private void ConfigValue() {
LoadDate( value );
return;
}
if ( dataType == DataType.Number ) {
LoadNumber( value );
return;
}
SetContent( "{{" + GetValue(value) + "}}");
}

Expand All @@ -114,6 +118,13 @@ protected void LoadDate( string value ) {
SetContent( $"{{{{{value}|date:\"{format}\"}}}}" );
}

/// <summary>
/// 加载数值
/// </summary>
protected void LoadNumber( string value ) {
SetContent( "{{" + value + "}}" );
}

/// <summary>
/// 获取值
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Util.Ui.Configs;
using Util.Ui.Expressions;
using Util.Ui.Expressions;
using Util.Ui.NgZorro.Components.Forms.Configs;
using Util.Ui.NgZorro.Enums;
using Util.Ui.NgZorro.Expressions;
Expand Down Expand Up @@ -53,5 +52,9 @@ protected virtual void LoadValue( Config config, ModelExpressionInfo info ) {
config.SetAttribute( UiConst.Type, DataType.Date );
return;
}
if ( info.IsNumber ) {
config.SetAttribute( UiConst.Type, DataType.Number );
return;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Util.Ui.Angular.Configs;
using Util.Ui.Configs;
using Util.Ui.NgZorro.Enums;
using Util.Ui.NgZorro.Components.Inputs.Configs;
using Util.Ui.Angular.Builders;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Util.Ui.Angular.Configs;
using Util.Ui.Configs;
using Util.Ui.NgZorro.Components.Base;
using Util.Ui.NgZorro.Components.Inputs.Helpers;
using Util.Ui.NgZorro.Enums;
Expand Down
1 change: 0 additions & 1 deletion src/Util.Ui.NgZorro/Components/Popover/PopoverRender.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Util.Ui.Angular.Configs;
using Util.Ui.Builders;
using Util.Ui.Configs;
using Util.Ui.NgZorro.Enums;

namespace Util.Ui.NgZorro.Components.Popover;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Util.Ui.Angular.Builders;
using Util.Ui.Angular.Configs;
using Util.Ui.Angular.Extensions;
using Util.Ui.Builders;
using Util.Ui.NgZorro.Components.Tables.Builders.Contents;
using Util.Ui.NgZorro.Components.Tables.Configs;
using Util.Ui.NgZorro.Directives.Tooltips;

namespace Util.Ui.NgZorro.Components.Tables.Builders;

Expand Down Expand Up @@ -289,6 +291,7 @@ public TableColumnBuilder EnableCustomColumn() {
public TableColumnBuilder Events() {
AttributeIfNotEmpty( "(nzCheckedChange)", _config.GetValue( UiConst.OnCheckedChange ) );
AttributeIfNotEmpty( "(nzExpandChange)", _config.GetValue( UiConst.OnExpandChange ) );
this.OnClick( _config );
return this;
}

Expand All @@ -301,7 +304,7 @@ public override void Config() {
.ShowExpand().Expand()
.Left().Right().Align().BreakWord().Ellipsis()
.IndentSize().CellControl().EnableCustomColumn()
.Events();
.Tooltip( _config ).Events();
ConfigContent();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Util.Ui.Angular.Builders;
using Util.Ui.Angular.Extensions;
using Util.Ui.Configs;
using Util.Ui.NgZorro.Components.Tables.Configs;

namespace Util.Ui.NgZorro.Components.Tables.Builders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public TableShareConfig GetTableShareConfig() {
/// 设置表格尺寸
/// </summary>
public TableSettingsBuilder IsTreeTable() {
if (_tableShareConfig.IsTreeTable == false)
if ( _tableShareConfig.IsTreeTable == false )
return this;
Attribute( "[isTreeTable]","true" );
Attribute( "[isTreeTable]", "true" );
return this;
}

Expand Down Expand Up @@ -75,8 +75,8 @@ public TableSettingsBuilder Scroll() {
/// 配置是否启用固定列
/// </summary>
public TableSettingsBuilder EnableFixedColumn() {
if( _tableShareConfig.IsEnableFixedColumn )
Attribute( "[enableFixedColumn]","true" );
if ( _tableShareConfig.IsEnableFixedColumn )
Attribute( "[enableFixedColumn]", "true" );
return this;
}

Expand All @@ -98,9 +98,9 @@ private string GetColumnsJson() {
AddRadioColumn( result );
AddCheckboxColumn( result );
AddLineNumberColumn( result );
result.AddRange( _tableShareConfig.Columns.Select( column => column.ToCustomColumn() ) );
result.AddRange( _tableShareConfig.Columns.Where( column => column.IsInner == false ).Select( column => column.ToCustomColumn() ) );
var json = Util.Helpers.Json.ToJson( result, new JsonOptions { ToSingleQuotes = true, IgnoreNullValues = true } );
return json.Replace($"'{GetCheckboxWidth()}'", GetCheckboxWidth() )
return json.Replace( $"'{GetCheckboxWidth()}'", GetCheckboxWidth() )
.Replace( $"'{GetRadioWidth()}'", GetRadioWidth() )
.Replace( $"'{GetLineNumberWidth()}'", GetLineNumberWidth() );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Util.Ui.NgZorro.Components.Tables.Configs;

/// <summary>
/// 表格编辑列显示区域共享配置
/// </summary>
public class TableColumnDisplayShareConfig {
}
4 changes: 4 additions & 0 deletions src/Util.Ui.NgZorro/Components/Tables/Helpers/ColumnInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public class ColumnInfo {
/// 是否启用拖动调整列宽
/// </summary>
public bool IsEnableResizable { get; set; }
/// <summary>
/// 是否内部列
/// </summary>
public bool IsInner { get; set; }

/// <summary>
/// 转换为自定义列
Expand Down
Loading

0 comments on commit 139753d

Please sign in to comment.