From d28a8adcff2d0c9601b718450afb2ed0f251e5fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E8=89=B2?= Date: Thu, 14 Nov 2024 02:13:02 +0800 Subject: [PATCH] perf: optimizing `@let` (#1849) --- packages/abc/cell/cell.component.ts | 7 ++-- packages/abc/hotkey/hotkey.directive.ts | 4 +-- packages/abc/hotkey/index.en-US.md | 2 +- packages/abc/hotkey/index.zh-CN.md | 2 +- packages/abc/st/st-td.component.html | 47 ++++++++++++------------- packages/abc/st/st.component.html | 9 ++--- packages/abc/st/st.module.ts | 2 -- packages/form/src/sf.component.html | 20 ++++++----- 8 files changed, 47 insertions(+), 46 deletions(-) diff --git a/packages/abc/cell/cell.component.ts b/packages/abc/cell/cell.component.ts index 4e8e96bbf4..724b8fea47 100644 --- a/packages/abc/cell/cell.component.ts +++ b/packages/abc/cell/cell.component.ts @@ -68,13 +68,14 @@ import type { CellDefaultText, CellOptions, CellTextResult, CellValue } from './ } @case ('img') { @for (i of $any(_text); track $index) { + @let img = safeOpt.img; } } diff --git a/packages/abc/hotkey/hotkey.directive.ts b/packages/abc/hotkey/hotkey.directive.ts index 487a0c686c..0d256c9222 100644 --- a/packages/abc/hotkey/hotkey.directive.ts +++ b/packages/abc/hotkey/hotkey.directive.ts @@ -10,9 +10,9 @@ export class HotkeyDirective implements OnDestroy { private readonly platform = inject(Platform); /** - * Specify [hotkey format](https://github.com/github/hotkey#hotkey-string-format) + * Specify [hotkey format](https://github.com/github/hotkey#hotkey-string-format), you can get the code through [Hotkey Code](https://github.github.com/hotkey/hotkey_mapper.html) * - * 指定[热键格式](https://github.com/github/hotkey#hotkey-string-format) + * 指定[热键格式](https://github.com/github/hotkey#hotkey-string-format),可以通过 [Hotkey Code](https://github.github.com/hotkey/hotkey_mapper.html) 来获取代码。 */ @Input('hotkey') set hotkey(key: string) { diff --git a/packages/abc/hotkey/index.en-US.md b/packages/abc/hotkey/index.en-US.md index 49891134d0..6cb52abbdc 100644 --- a/packages/abc/hotkey/index.en-US.md +++ b/packages/abc/hotkey/index.en-US.md @@ -9,7 +9,7 @@ module: import { HotkeyModule } from '@delon/abc/hotkey'; Based on the [@github/hotke](https://github.com/github/hotkey) hotkey library. -> If you don't know the hotkey value, you can get it through [Hotkey Code](https://github.github.io/hotkey/hotkey_mapper.html). +> If you don't know the hotkey value, you can get it through [Hotkey Code](https://github.github.com/hotkey/hotkey_mapper.html). ## API diff --git a/packages/abc/hotkey/index.zh-CN.md b/packages/abc/hotkey/index.zh-CN.md index b015854e54..2fc532b53c 100644 --- a/packages/abc/hotkey/index.zh-CN.md +++ b/packages/abc/hotkey/index.zh-CN.md @@ -9,7 +9,7 @@ module: import { HotkeyModule } from '@delon/abc/hotkey'; 基于 [@github/hotke](https://github.com/github/hotkey) 热键库。 -> 如果不清楚热键值,可通过[热键代码](https://github.github.io/hotkey/hotkey_mapper.html)来获取。 +> 如果不清楚热键值,可通过[热键代码](https://github.github.com/hotkey/hotkey_mapper.html)来获取。 ## API diff --git a/packages/abc/st/st-td.component.html b/packages/abc/st/st-td.component.html index 0d9f60fb7b..7589610d4a 100644 --- a/packages/abc/st/st-td.component.html +++ b/packages/abc/st/st-td.component.html @@ -9,14 +9,15 @@ @if (i.pop) { + @let pop = i.pop; @if (i._icon) { - @if (i._icon.iconfont) { - + @let icon = i._icon; + @if (icon.iconfont) { + } @else { } } @@ -49,6 +51,7 @@ @if (c.__render) { } @else { + @let col = i._values[cIdx]; @switch (c.type) { @case ('checkbox') { @@ -57,35 +60,31 @@ } @case ('link') { - + } @case ('tag') { - - + + } @case ('badge') { - + } @case ('cell') { - + } @case ('widget') { } @default { @if (c.safeType === 'text') { - + } @else { - + } } } - @for (btn of i._values[cIdx].buttons; track $index) { + @for (btn of col.buttons; track $index) { @if (btn.children!.length > 0) { diff --git a/packages/abc/st/st.component.html b/packages/abc/st/st.component.html index 1f0b3f7fa5..e943156b70 100644 --- a/packages/abc/st/st.component.html +++ b/packages/abc/st/st.component.html @@ -61,8 +61,8 @@ } @for (h of row; track h; let index = $index; let last = $last) { + @let _c = h.column; } @for (c of _columns; track cIdx; let cIdx = $index) { - @if (i._values[cIdx].props?.colSpan > 0 && i._values[cIdx].props?.rowSpan > 0) { + @let props = i._values[cIdx].props; + @if (props?.colSpan > 0 && props?.rowSpan > 0) { @if (responsive) { diff --git a/packages/abc/st/st.module.ts b/packages/abc/st/st.module.ts index f74d37cc4f..d7cc671683 100644 --- a/packages/abc/st/st.module.ts +++ b/packages/abc/st/st.module.ts @@ -3,7 +3,6 @@ import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { CellModule } from '@delon/abc/cell'; -import { LetModule } from '@delon/abc/let'; import { DelonACLModule } from '@delon/acl'; import { NzBadgeModule } from 'ng-zorro-antd/badge'; import { NzCheckboxModule } from 'ng-zorro-antd/checkbox'; @@ -33,7 +32,6 @@ const COMPONENTS = [STComponent, STRowDirective, STWidgetHostDirective]; CommonModule, FormsModule, DelonACLModule, - LetModule, CellModule, NzPopconfirmModule, NzTableModule, diff --git a/packages/form/src/sf.component.html b/packages/form/src/sf.component.html index b69d1457ce..876618ae3d 100644 --- a/packages/form/src/sf.component.html +++ b/packages/form/src/sf.component.html @@ -3,8 +3,9 @@ @if (button !== 'none') { - @if (_btn && _btn.render) { - + @let btnRender = _btn.render; + @if (btnRender) { +
@@ -46,17 +47,18 @@ nz-button data-type="reset" [nzType]="_btn.reset_type!" - [nzSize]="_btn.render!.size!" + [nzSize]="btnRender.size!" [disabled]="loading" (click)="reset(true)" > - @if (_btn.reset_icon) { + @let resetIcon = _btn.reset_icon; + @if (resetIcon) { } {{ _btn.reset }}