From e3de0e96e9ab0448c18a14a21ca88b1c237d68a5 Mon Sep 17 00:00:00 2001 From: cipchk Date: Sat, 25 Nov 2023 00:42:50 +0800 Subject: [PATCH 01/11] perf(*): use control flow --- docs/new-component.en-US.md | 4 +- docs/new-component.zh-CN.md | 4 +- .../auto-focus/auto-focus.directive.spec.ts | 8 ++-- packages/abc/auto-focus/demo/simple.md | 8 ++-- .../avatar-list/avatar-list.component.html | 36 ++++++++------- packages/abc/cell/demo/simple.md | 4 +- .../abc/count-down/count-down.component.ts | 4 +- packages/abc/count-down/count-down.spec.ts | 16 ++++--- .../layout-default/layout-nav.component.html | 45 ++++++++++++------- ...__name@dasherize__.component.html.template | 32 +++++++------ ...__name@dasherize__.component.html.template | 34 ++++++++------ ...__name@dasherize__.component.html.template | 34 ++++++++------ 12 files changed, 140 insertions(+), 89 deletions(-) diff --git a/docs/new-component.en-US.md b/docs/new-component.en-US.md index 9ef4eff16..061e81e03 100644 --- a/docs/new-component.en-US.md +++ b/docs/new-component.en-US.md @@ -47,7 +47,9 @@ import { Component, Input } from '@angular/core'; template: `
-
{{ desc }}
+ @if (desc) { +
{{ desc }}
+ }
`, styleUrls: [ './index.less' ] diff --git a/docs/new-component.zh-CN.md b/docs/new-component.zh-CN.md index ca2b899a2..5c77b94da 100644 --- a/docs/new-component.zh-CN.md +++ b/docs/new-component.zh-CN.md @@ -47,7 +47,9 @@ import { Component, Input } from '@angular/core'; template: `
-
{{ desc }}
+ @if (desc) { +
{{ desc }}
+ }
`, styleUrls: [ './index.less' ] diff --git a/packages/abc/auto-focus/auto-focus.directive.spec.ts b/packages/abc/auto-focus/auto-focus.directive.spec.ts index 9c898ed0e..814282c85 100644 --- a/packages/abc/auto-focus/auto-focus.directive.spec.ts +++ b/packages/abc/auto-focus/auto-focus.directive.spec.ts @@ -42,9 +42,11 @@ describe('abc: auto-focus', () => { @Component({ template: ` -
- -
+ @if (showInput) { +
+ +
+ } ` }) class TestComponent { diff --git a/packages/abc/auto-focus/demo/simple.md b/packages/abc/auto-focus/demo/simple.md index 422015c49..97ef3a8ba 100644 --- a/packages/abc/auto-focus/demo/simple.md +++ b/packages/abc/auto-focus/demo/simple.md @@ -20,9 +20,11 @@ import { Component } from '@angular/core'; selector: 'app-demo', template: ` -
- -
+ @if (showInput) { +
+ +
+ } `, }) export class DemoComponent { diff --git a/packages/abc/avatar-list/avatar-list.component.html b/packages/abc/avatar-list/avatar-list.component.html index 0e724cbbe..f39eacc01 100644 --- a/packages/abc/avatar-list/avatar-list.component.html +++ b/packages/abc/avatar-list/avatar-list.component.html @@ -1,17 +1,23 @@ diff --git a/packages/abc/cell/demo/simple.md b/packages/abc/cell/demo/simple.md index c634c4dde..0c30d5497 100644 --- a/packages/abc/cell/demo/simple.md +++ b/packages/abc/cell/demo/simple.md @@ -128,7 +128,9 @@ import { CellBadge, CellFuValue, CellOptions, CellRenderType } from '@delon/abc/
Async => - Again + @if (!asyncLoading) { + Again + }
Unit =>
Text Unit =>
diff --git a/packages/abc/count-down/count-down.component.ts b/packages/abc/count-down/count-down.component.ts index 233ac2bc9..fcac7c55a 100644 --- a/packages/abc/count-down/count-down.component.ts +++ b/packages/abc/count-down/count-down.component.ts @@ -14,7 +14,9 @@ import { CountdownComponent, CountdownConfig, CountdownEvent } from 'ngx-countdo @Component({ selector: 'count-down', exportAs: 'countDown', - template: ``, + template: `@if (config) { + + }`, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None diff --git a/packages/abc/count-down/count-down.spec.ts b/packages/abc/count-down/count-down.spec.ts index d746d318e..491e1d508 100644 --- a/packages/abc/count-down/count-down.spec.ts +++ b/packages/abc/count-down/count-down.spec.ts @@ -50,12 +50,16 @@ describe('abc: count-down', () => { @Component({ template: ` -
- -
-
- -
+ @if (config) { +
+ +
+ } + @if (target) { +
+ +
+ } ` }) class TestComponent { diff --git a/packages/theme/layout-default/layout-nav.component.html b/packages/theme/layout-default/layout-nav.component.html index 76342cac6..e7c20a78a 100644 --- a/packages/theme/layout-default/layout-nav.component.html +++ b/packages/theme/layout-default/layout-nav.component.html @@ -1,21 +1,32 @@ - - - - - - - + @if (i) { + @switch (i.type) { + @case ('icon') { + + } + @case ('iconfont') { + + } + @case ('img') { + + } + @case ('svg') { + + } + @default { + + } + } + } diff --git a/schematics/edit/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template b/schematics/edit/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template index d84e80b76..bc2c78eaf 100644 --- a/schematics/edit/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +++ b/schematics/edit/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template @@ -1,19 +1,25 @@ <% if(modal) { %> - - - -<% } else { %> - - - - - +@if (i) { + + +} @else { + +}<% } else { %> + + @if (i) { + + + + + + + } @else { + + } <% } %> diff --git a/schematics/plugin/files/sts/swagger-edit/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template b/schematics/plugin/files/sts/swagger-edit/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template index 3f6f40d89..bc2c78eaf 100644 --- a/schematics/plugin/files/sts/swagger-edit/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +++ b/schematics/plugin/files/sts/swagger-edit/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template @@ -1,19 +1,25 @@ <% if(modal) { %> - - - -<% } else { %> - - - - - +@if (i) { + + -<% } %> \ No newline at end of file +} @else { + +}<% } else { %> + + @if (i) { + + + + + + + } @else { + + } +<% } %> diff --git a/schematics/view/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template b/schematics/view/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template index b63a00ed1..9400530f2 100644 --- a/schematics/view/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +++ b/schematics/view/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template @@ -1,24 +1,30 @@ <% if(modal) { %> - -
- {{ i.owner }} - 32943898021309809423 - 3321944288191034921 - 18112345678 - 曲丽丽 18100000000 浙江省杭州市西湖区黄姑山路工专路交叉路口 -
-<% } else { %> - - -
+@if (i) { +
{{ i.owner }} 32943898021309809423 3321944288191034921 18112345678 曲丽丽 18100000000 浙江省杭州市西湖区黄姑山路工专路交叉路口
+} @else { + +} +<% } else { %> + + @if (i) { +
+ {{ i.owner }} + 32943898021309809423 + 3321944288191034921 + 18112345678 + 曲丽丽 18100000000 浙江省杭州市西湖区黄姑山路工专路交叉路口 +
+ } @else { + + }
<% } %> From a4c050b5b906385c04d032e3e058a2946dd311a9 Mon Sep 17 00:00:00 2001 From: cipchk Date: Sat, 25 Nov 2023 00:57:57 +0800 Subject: [PATCH 02/11] chore: update --- .../abc/exception/exception.component.html | 8 +- .../footer-toolbar.component.html | 4 +- .../global-footer.component.html | 18 ++- packages/abc/let/demo/async.md | 4 +- packages/abc/loading/loading.component.html | 26 ++-- packages/abc/lodop/demo/design.md | 66 +++++----- packages/abc/lodop/demo/print.md | 115 +++++++++--------- .../notice-icon-tab.component.html | 46 ++++--- .../notice-icon/notice-icon.component.html | 46 +++---- .../abc/onboarding/onboarding.component.html | 114 ++++++++--------- .../page-header/page-header.component.html | 59 +++++---- packages/abc/pdf/demo/design.md | 80 +++++++----- packages/abc/pdf/pdf.component.ts | 4 +- packages/abc/qr/qr.component.ts | 4 +- 14 files changed, 330 insertions(+), 264 deletions(-) diff --git a/packages/abc/exception/exception.component.html b/packages/abc/exception/exception.component.html index 711fe8a2e..989689497 100644 --- a/packages/abc/exception/exception.component.html +++ b/packages/abc/exception/exception.component.html @@ -8,8 +8,10 @@

- + @if (!hasCon) { + + }
diff --git a/packages/abc/footer-toolbar/footer-toolbar.component.html b/packages/abc/footer-toolbar/footer-toolbar.component.html index 8ebe9798f..a3c8accd8 100644 --- a/packages/abc/footer-toolbar/footer-toolbar.component.html +++ b/packages/abc/footer-toolbar/footer-toolbar.component.html @@ -2,6 +2,8 @@ {{ extra }} diff --git a/packages/abc/global-footer/global-footer.component.html b/packages/abc/global-footer/global-footer.component.html index b7cd71f70..2e7e0fbb8 100644 --- a/packages/abc/global-footer/global-footer.component.html +++ b/packages/abc/global-footer/global-footer.component.html @@ -1,9 +1,15 @@ - +@if (links.length > 0 || items.length > 0) { + +} diff --git a/packages/abc/let/demo/async.md b/packages/abc/let/demo/async.md index a8d7f57fb..21ddb9bc2 100644 --- a/packages/abc/let/demo/async.md +++ b/packages/abc/let/demo/async.md @@ -23,13 +23,13 @@ import { NzSafeAny } from 'ng-zorro-antd/core/types'; @Component({ selector: 'app-demo', template: ` - + @if (timer$ !== null) {

Timer value: {{ time }}

Timer value: {{ time }}

Timer value: {{ time }}

-
+ } `, changeDetection: ChangeDetectionStrategy.OnPush }) diff --git a/packages/abc/loading/loading.component.html b/packages/abc/loading/loading.component.html index 10a7170a1..2ac6e2a72 100644 --- a/packages/abc/loading/loading.component.html +++ b/packages/abc/loading/loading.component.html @@ -1,8 +1,18 @@ -
- - - -
-
-
-
{{ options.text }}
+@if (options.type! !== 'text') { +
+ @switch (options.type) { + @case ('spin') { + + } + @case ('icon') { + + } + @default { +
+ } + } +
+} +@if (options.text) { +
{{ options.text }}
+} diff --git a/packages/abc/lodop/demo/design.md b/packages/abc/lodop/demo/design.md index 4137ac9e7..5c146ab46 100644 --- a/packages/abc/lodop/demo/design.md +++ b/packages/abc/lodop/demo/design.md @@ -21,37 +21,41 @@ import { NzMessageService } from 'ng-zorro-antd/message'; @Component({ selector: 'app-demo', template: ` - - 请先下载Lodop插件 - -
- - 标题 - - - - - - 费用 - - - - - - 打印内容 - - - - - - - - - - - - -
+ @if (error) { + + 请先下载Lodop插件 + + } + @if (lodop && !error) { +
+ + 标题 + + + + + + 费用 + + + + + + 打印内容 + + + + + + + + + + + + +
+ } `, }) export class DemoComponent { diff --git a/packages/abc/lodop/demo/print.md b/packages/abc/lodop/demo/print.md index 195a4c0f1..ba3f309ad 100644 --- a/packages/abc/lodop/demo/print.md +++ b/packages/abc/lodop/demo/print.md @@ -21,62 +21,65 @@ import { NzMessageService } from 'ng-zorro-antd/message'; @Component({ selector: 'app-demo', template: ` - - - 请先下载Lodop插件, 安装后点击重试。 - - -
- - 打印服务器 - - -
- -
-
- -
-
-
-
- - 打印机 - - - - - - - - 纸张类型 - - - - - - - - 打印内容 - - - - - - - - - - -
+ @if (error) { + + + 请先下载Lodop插件, 安装后点击重试。 + + + } @else { +
+ + 打印服务器 + + +
+ +
+
+ +
+
+
+
+ + 打印机 + + + + + + + + 纸张类型 + + + + + + + + 打印内容 + + + + + + + + + + +
+ } `, }) export class DemoComponent { diff --git a/packages/abc/notice-icon/notice-icon-tab.component.html b/packages/abc/notice-icon/notice-icon-tab.component.html index d81f604bd..c748288e1 100644 --- a/packages/abc/notice-icon/notice-icon-tab.component.html +++ b/packages/abc/notice-icon/notice-icon-tab.component.html @@ -1,11 +1,17 @@ -
- not found -

- - {{ data.emptyText || locale.emptyText }} - -

-
+@if (data.list?.length === 0) { +
+ @if (data.emptyImage) { + not found + } +

+ + {{ data.emptyText || locale.emptyText }} + +

+
+} @else { + +} @@ -15,17 +21,23 @@ {{ item.title }} -
- {{ item.extra }} -
+ @if (item.extra) { +
+ {{ item.extra }} +
+ }
-
- - {{ item.description }} - -
-
{{ item.datetime }}
+ @if (item.description) { +
+ + {{ item.description }} + +
+ } + @if (item.datetime) { +
{{ item.datetime }}
+ }
diff --git a/packages/abc/notice-icon/notice-icon.component.html b/packages/abc/notice-icon/notice-icon.component.html index 9a4fa89c0..573022d1e 100644 --- a/packages/abc/notice-icon/notice-icon.component.html +++ b/packages/abc/notice-icon/notice-icon.component.html @@ -3,27 +3,27 @@
-
+@if (data!.length <= 0) { -
-
- -
- - - - - - - - - +} @else { +
+ +
+ + + + + + + + + +} diff --git a/packages/abc/onboarding/onboarding.component.html b/packages/abc/onboarding/onboarding.component.html index 96717c30d..be3aab5b2 100644 --- a/packages/abc/onboarding/onboarding.component.html +++ b/packages/abc/onboarding/onboarding.component.html @@ -1,62 +1,54 @@ -
-
- - -
-
-