Skip to content

Commit 139753d

Browse files
committed
1. 表格单元格<util-td> 添加 tooltip 相关属性.
2. 新增Spa管道中间件,由于微软已放弃维护, 故从 Microsoft.AspNetCore.SpaServices 复制源码进行修改. 3. IAppBuilder 扩展方法 AddNgZorro ,新增 EnableWatchRazor 选项, 用于启用Razor监视服务 ,并默认开启. 4. WebApplication 扩展方法 UseNgZorro , 新增 isAutoStartAngularServer 参数,用于自动启动Angular服务器, 并默认开启. 5. 修复描述列表项 <util-descriptions-item> 显示数值类型不正确的bug. 6. 修复具有嵌套列的情况下表格设置加载列不正确的bug.
1 parent 66926b2 commit 139753d

File tree

66 files changed

+2144
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2144
-173
lines changed

build/version.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<VersionMajor>8</VersionMajor>
44
<VersionMinor>0</VersionMinor>
5-
<VersionPatch>8</VersionPatch>
5+
<VersionPatch>9</VersionPatch>
66
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
77
<VersionSuffix></VersionSuffix>
88
</PropertyGroup>

readme.md

+2-26
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,6 @@ Util 配套代码生成器, 简单易用, 可解决大部分机械工作.
422422

423423
## Util Angular UI 特点
424424

425-
- ### 使用 Visual Studio 开发工具
426-
427-
前端开发一般使用 Visual Studio Code , 不过 Util Angular UI主要使用 Razor 页面,使用 Visual Studio 更方便.
428-
429425
- ### 组件扩展支持
430426

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

581577
## Util Angular UI 已知缺陷
582578

583-
Util Angular UI 在提供大量支持的同时,也存在一些缺陷.
584-
585-
- ### 开发阶段运行比较缓慢
586-
587-
与 Visual Studio Code 相比,使用 Visual Studio 开发 Angular 项目要慢一些,如果使用了 Resharper 插件,则会更慢.
588-
589-
除开发工具影响外, Util Angular UI 在开发阶段需要启用 Angular JIT( 即时编译 ), 运行会变慢.
590-
591-
另外, Util Angular UI 在开发阶段需要访问 Razor 页面,每当项目启动,Angular 主模块加载的所有组件都会发出 Razor 页面请求.
592-
593-
不过运行缓慢仅存在于开发阶段,一旦发布,则与纯前端开发方式的运行速度相同.
594-
595-
- ### 无法使用 Angular 常规延迟加载方式
596-
597-
你不能使用 loadChildren 延迟加载模块,这是因为开发阶段组件的 templateUrl 指向 Razor 页面地址, 必须使用 Angular JIT 模式,等待运行时再获取组件模板.
598-
599-
这个问题从 Angular 13 开始出现, Angular 13弃用了传统的视图引擎, 使用 loadChildren 加载指向 Razor 页面地址的组件会报异常.
600-
601-
解决它的方法是使用微前端方案延迟加载模块, 当然你也可以回退到 Angular 13之前的版本.
602-
603-
在同一个 Util Angular UI 项目中,你必须把所有的子模块加载到主模块中,并配置微前端将子模块发布为可独立加载包.
579+
Util Angular UI 所有已知缺陷均已解决.
604580

605581
## Util Angular UI 适合你吗?
606582

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

609585
## 参考应用框架
610586

src/Util.AspNetCore/Helpers/Web.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ public static async Task DownloadAsync( byte[] bytes, string fileName, Encoding
368368
fileName = fileName.Replace( " ", "" );
369369
fileName = UrlEncode( fileName, encoding );
370370
Response.ContentType = "application/octet-stream";
371-
Response.Headers.Add( "Content-Disposition", $"attachment; filename={fileName}" );
372-
Response.Headers.Add( "Content-Length", bytes.Length.ToString() );
371+
Response.Headers.Append( "Content-Disposition", $"attachment; filename={fileName}" );
372+
Response.Headers.Append( "Content-Length", bytes.Length.ToString() );
373373
await Response.Body.WriteAsync( bytes, 0, bytes.Length );
374374
}
375375

src/Util.Core/Helpers/Environment.cs

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public static class Environment {
2020
/// 换行符
2121
/// </summary>
2222
public static string NewLine => System.Environment.NewLine;
23+
/// <summary>
24+
/// 是否测试环境
25+
/// </summary>
26+
public static bool IsTest { get; set; }
2327

2428
/// <summary>
2529
/// 设置环境变量

src/Util.Core/Helpers/Url.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public static string JoinPath( params string[] paths ) {
1616
return string.Empty;
1717
var firstPath = paths.First();
1818
var lastPath = paths.Last();
19+
string schema = string.Empty;
20+
if ( firstPath.StartsWith( "http:", StringComparison.OrdinalIgnoreCase ) )
21+
schema = "http://";
22+
if ( firstPath.StartsWith( "https:", StringComparison.OrdinalIgnoreCase ) )
23+
schema = "https://";
1924
paths = paths.Select( t => t.Trim( '/' ) ).ToArray();
2025
var result = Path.Combine( paths ).Replace( @"\", "/" );
2126
if ( paths.Any( path => path.StartsWith( "." ) ) ) {
@@ -26,6 +31,9 @@ public static string JoinPath( params string[] paths ) {
2631
result = $"/{result}";
2732
if ( lastPath.EndsWith( '/' ) )
2833
result = $"{result}/";
29-
return result;
34+
result = result.RemoveStart( "http:/" ).RemoveStart( "https:/" );
35+
if (schema.IsEmpty())
36+
return result;
37+
return schema + result.RemoveStart( "/" );
3038
}
3139
}

src/Util.Generators.Razor/RazorTemplate.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Util.Generators.Templates;
33
using Util.Templates;
44

5-
namespace Util.Generators.Razor;
5+
namespace Util.Generators.Razor;
66

77
/// <summary>
88
/// Razor模板
@@ -82,8 +82,10 @@ protected virtual async Task<string> RenderResult( EntityContext context ) {
8282
/// </summary>
8383
/// <param name="context">实体上下文</param>
8484
/// <param name="result">渲染结果</param>
85-
protected virtual async Task WriteFile( EntityContext context,string result ) {
86-
if( context.Output.Path.IsEmpty() )
85+
protected virtual async Task WriteFile( EntityContext context, string result ) {
86+
if ( context.Output.Path.IsEmpty() )
87+
return;
88+
if ( result.IsEmpty() )
8789
return;
8890
await Util.Helpers.File.WriteAsync( context.Output.Path, result );
8991
}

src/Util.Logging.Serilog/02-Util.Logging.Serilog.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
</ItemGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
31-
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
30+
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
31+
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
3232
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
33-
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.3" />
33+
<PackageReference Include="Serilog.Sinks.Seq" Version="7.0.0" />
3434
</ItemGroup>
3535

3636
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Util.Ui.Angular.Configs;
22
using Util.Ui.Configs;
33

4-
namespace Util.Ui.Angular.Extensions;
4+
namespace Util.Ui.Angular.Extensions;
55

66
/// <summary>
77
/// 配置扩展
@@ -13,13 +13,30 @@ public static class ConfigExtensions {
1313
/// <param name="config">配置</param>
1414
public static Config CopyRemoveAttributes( this Config config ) {
1515
var result = config.Copy();
16-
result.RemoveAttribute( UiConst.Id );
17-
result.RemoveAttribute( AngularConst.RawId );
18-
result.RemoveAttribute( UiConst.Name );
19-
result.RemoveAttribute( AngularConst.BindName );
20-
result.RemoveAttribute( UiConst.Style );
21-
result.RemoveAttribute( UiConst.Class );
2216
result.OutputAttributes.Clear();
17+
result.AllAttributes.Clear();
18+
LoadConfig( config, result, UiConst.Required );
19+
LoadConfig( config, result, UiConst.RequiredMessage );
20+
LoadConfig( config, result, UiConst.Suffix );
21+
LoadConfig( config, result, AngularConst.BindSuffix );
22+
LoadConfig( config, result, UiConst.Extra );
23+
LoadConfig( config, result, AngularConst.BindExtra );
24+
LoadConfig( config, result, UiConst.ErrorTip );
25+
LoadConfig( config, result, AngularConst.BindErrorTip );
26+
LoadConfig( config, result, UiConst.SuccessTip );
27+
LoadConfig( config, result, AngularConst.BindSuccessTip );
28+
LoadConfig( config, result, UiConst.ValidatingTip );
29+
LoadConfig( config, result, AngularConst.BindValidatingTip );
30+
LoadConfig( config, result, UiConst.WarningTip );
31+
LoadConfig( config, result, AngularConst.BindWarningTip );
2332
return result;
2433
}
34+
35+
/// <summary>
36+
/// 加载配置
37+
/// </summary>
38+
private static void LoadConfig( Config from, Config to, string name ) {
39+
var value = from.GetValue( name );
40+
to.SetAttribute( name, value );
41+
}
2542
}

src/Util.Ui.NgZorro/AppBuilderExtensions.cs

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public static IAppBuilder AddNgZorro( this IAppBuilder builder, Action<NgZorroOp
3131
services.TryAddSingleton<IRazorWatchService, RazorWatchService>();
3232
services.TryAddSingleton<IPartViewPathResolver, PartViewPathResolver>();
3333
services.TryAddSingleton<IPartViewPathFinder, PartViewPathFinder>();
34+
if ( options.EnableWatchRazor )
35+
services.AddHostedService<WatchHostedService>();
3436
ConfigSpaStaticFiles( services, options );
3537
ConfigRazorOptions( services, options );
3638
ConfigNgZorroOptions( services, setupAction );
@@ -56,7 +58,11 @@ void Action( RazorOptions t ) {
5658
t.GenerateHtmlBasePath = options.GenerateHtmlBasePath;
5759
t.GenerateHtmlFolder = options.GenerateHtmlFolder;
5860
t.GenerateHtmlSuffix = options.GenerateHtmlSuffix;
61+
t.EnableWatchRazor = options.EnableWatchRazor;
62+
t.StartInitDelay = options.StartInitDelay;
5963
t.HtmlRenderDelayOnRazorChange = options.HtmlRenderDelayOnRazorChange;
64+
t.EnablePreheat = options.EnablePreheat;
65+
t.EnableOverrideHtml = options.EnableOverrideHtml;
6066
}
6167
services.Configure( (Action<RazorOptions>)Action );
6268
}

src/Util.Ui.NgZorro/Components/Buttons/ButtonGroupTagHelper.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Microsoft.AspNetCore.Razor.TagHelpers;
22
using Util.Ui.Angular.TagHelpers;
3-
using Util.Ui.Configs;
43
using Util.Ui.NgZorro.Components.Buttons.Renders;
54
using Util.Ui.NgZorro.Enums;
65
using Util.Ui.Renders;

src/Util.Ui.NgZorro/Components/Descriptions/Builders/DescriptionItemBuilder.cs

+11
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ private void ConfigValue() {
9393
LoadDate( value );
9494
return;
9595
}
96+
if ( dataType == DataType.Number ) {
97+
LoadNumber( value );
98+
return;
99+
}
96100
SetContent( "{{" + GetValue(value) + "}}");
97101
}
98102

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

121+
/// <summary>
122+
/// 加载数值
123+
/// </summary>
124+
protected void LoadNumber( string value ) {
125+
SetContent( "{{" + value + "}}" );
126+
}
127+
117128
/// <summary>
118129
/// 获取值
119130
/// </summary>

src/Util.Ui.NgZorro/Components/Display/Helpers/DisplayExpressionLoader.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Util.Ui.Configs;
2-
using Util.Ui.Expressions;
1+
using Util.Ui.Expressions;
32
using Util.Ui.NgZorro.Components.Forms.Configs;
43
using Util.Ui.NgZorro.Enums;
54
using Util.Ui.NgZorro.Expressions;
@@ -53,5 +52,9 @@ protected virtual void LoadValue( Config config, ModelExpressionInfo info ) {
5352
config.SetAttribute( UiConst.Type, DataType.Date );
5453
return;
5554
}
55+
if ( info.IsNumber ) {
56+
config.SetAttribute( UiConst.Type, DataType.Number );
57+
return;
58+
}
5659
}
5760
}

src/Util.Ui.NgZorro/Components/Inputs/Builders/InputGroupBuilder.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Util.Ui.Angular.Configs;
2-
using Util.Ui.Configs;
32
using Util.Ui.NgZorro.Enums;
43
using Util.Ui.NgZorro.Components.Inputs.Configs;
54
using Util.Ui.Angular.Builders;

src/Util.Ui.NgZorro/Components/Inputs/Builders/TextareaBuilder.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Util.Ui.Angular.Configs;
2-
using Util.Ui.Configs;
32
using Util.Ui.NgZorro.Components.Base;
43
using Util.Ui.NgZorro.Components.Inputs.Helpers;
54
using Util.Ui.NgZorro.Enums;

src/Util.Ui.NgZorro/Components/Popover/PopoverRender.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Util.Ui.Angular.Configs;
22
using Util.Ui.Builders;
3-
using Util.Ui.Configs;
43
using Util.Ui.NgZorro.Enums;
54

65
namespace Util.Ui.NgZorro.Components.Popover;

src/Util.Ui.NgZorro/Components/Tables/Builders/TableColumnBuilder.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using Util.Ui.Angular.Builders;
22
using Util.Ui.Angular.Configs;
3+
using Util.Ui.Angular.Extensions;
34
using Util.Ui.Builders;
45
using Util.Ui.NgZorro.Components.Tables.Builders.Contents;
56
using Util.Ui.NgZorro.Components.Tables.Configs;
7+
using Util.Ui.NgZorro.Directives.Tooltips;
68

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

@@ -289,6 +291,7 @@ public TableColumnBuilder EnableCustomColumn() {
289291
public TableColumnBuilder Events() {
290292
AttributeIfNotEmpty( "(nzCheckedChange)", _config.GetValue( UiConst.OnCheckedChange ) );
291293
AttributeIfNotEmpty( "(nzExpandChange)", _config.GetValue( UiConst.OnExpandChange ) );
294+
this.OnClick( _config );
292295
return this;
293296
}
294297

@@ -301,7 +304,7 @@ public override void Config() {
301304
.ShowExpand().Expand()
302305
.Left().Right().Align().BreakWord().Ellipsis()
303306
.IndentSize().CellControl().EnableCustomColumn()
304-
.Events();
307+
.Tooltip( _config ).Events();
305308
ConfigContent();
306309
}
307310

src/Util.Ui.NgZorro/Components/Tables/Builders/TableColumnDisplayBuilder.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Util.Ui.Angular.Builders;
22
using Util.Ui.Angular.Extensions;
3-
using Util.Ui.Configs;
43
using Util.Ui.NgZorro.Components.Tables.Configs;
54

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

src/Util.Ui.NgZorro/Components/Tables/Builders/TableSettingsBuilder.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public TableShareConfig GetTableShareConfig() {
3939
/// 设置表格尺寸
4040
/// </summary>
4141
public TableSettingsBuilder IsTreeTable() {
42-
if (_tableShareConfig.IsTreeTable == false)
42+
if ( _tableShareConfig.IsTreeTable == false )
4343
return this;
44-
Attribute( "[isTreeTable]","true" );
44+
Attribute( "[isTreeTable]", "true" );
4545
return this;
4646
}
4747

@@ -75,8 +75,8 @@ public TableSettingsBuilder Scroll() {
7575
/// 配置是否启用固定列
7676
/// </summary>
7777
public TableSettingsBuilder EnableFixedColumn() {
78-
if( _tableShareConfig.IsEnableFixedColumn )
79-
Attribute( "[enableFixedColumn]","true" );
78+
if ( _tableShareConfig.IsEnableFixedColumn )
79+
Attribute( "[enableFixedColumn]", "true" );
8080
return this;
8181
}
8282

@@ -98,9 +98,9 @@ private string GetColumnsJson() {
9898
AddRadioColumn( result );
9999
AddCheckboxColumn( result );
100100
AddLineNumberColumn( result );
101-
result.AddRange( _tableShareConfig.Columns.Select( column => column.ToCustomColumn() ) );
101+
result.AddRange( _tableShareConfig.Columns.Where( column => column.IsInner == false ).Select( column => column.ToCustomColumn() ) );
102102
var json = Util.Helpers.Json.ToJson( result, new JsonOptions { ToSingleQuotes = true, IgnoreNullValues = true } );
103-
return json.Replace($"'{GetCheckboxWidth()}'", GetCheckboxWidth() )
103+
return json.Replace( $"'{GetCheckboxWidth()}'", GetCheckboxWidth() )
104104
.Replace( $"'{GetRadioWidth()}'", GetRadioWidth() )
105105
.Replace( $"'{GetLineNumberWidth()}'", GetLineNumberWidth() );
106106
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Util.Ui.NgZorro.Components.Tables.Configs;
2+
3+
/// <summary>
4+
/// 表格编辑列显示区域共享配置
5+
/// </summary>
6+
public class TableColumnDisplayShareConfig {
7+
}

src/Util.Ui.NgZorro/Components/Tables/Helpers/ColumnInfo.cs

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public class ColumnInfo {
6464
/// 是否启用拖动调整列宽
6565
/// </summary>
6666
public bool IsEnableResizable { get; set; }
67+
/// <summary>
68+
/// 是否内部列
69+
/// </summary>
70+
public bool IsInner { get; set; }
6771

6872
/// <summary>
6973
/// 转换为自定义列

0 commit comments

Comments
 (0)