Skip to content

Commit d28a8ad

Browse files
authored
perf: optimizing @let (#1849)
1 parent 7a40351 commit d28a8ad

File tree

8 files changed

+47
-46
lines changed

8 files changed

+47
-46
lines changed

packages/abc/cell/cell.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ import type { CellDefaultText, CellOptions, CellTextResult, CellValue } from './
6868
}
6969
@case ('img') {
7070
@for (i of $any(_text); track $index) {
71+
@let img = safeOpt.img;
7172
<img
7273
[attr.src]="i"
73-
[attr.height]="safeOpt.img?.size"
74-
[attr.width]="safeOpt.img?.size"
74+
[attr.height]="img?.size"
75+
[attr.width]="img?.size"
7576
(click)="_showImg(i)"
7677
class="img"
77-
[class.point]="safeOpt.img?.big"
78+
[class.point]="img?.big"
7879
/>
7980
}
8081
}

packages/abc/hotkey/hotkey.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export class HotkeyDirective implements OnDestroy {
1010
private readonly platform = inject(Platform);
1111

1212
/**
13-
* Specify [hotkey format](https://github.com/github/hotkey#hotkey-string-format)
13+
* 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)
1414
*
15-
* 指定[热键格式](https://github.com/github/hotkey#hotkey-string-format)
15+
* 指定[热键格式](https://github.com/github/hotkey#hotkey-string-format),可以通过 [Hotkey Code](https://github.github.com/hotkey/hotkey_mapper.html) 来获取代码。
1616
*/
1717
@Input('hotkey')
1818
set hotkey(key: string) {

packages/abc/hotkey/index.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module: import { HotkeyModule } from '@delon/abc/hotkey';
99

1010
Based on the [@github/hotke](https://github.com/github/hotkey) hotkey library.
1111

12-
> If you don't know the hotkey value, you can get it through [Hotkey Code](https://github.github.io/hotkey/hotkey_mapper.html).
12+
> If you don't know the hotkey value, you can get it through [Hotkey Code](https://github.github.com/hotkey/hotkey_mapper.html).
1313
1414
## API
1515

packages/abc/hotkey/index.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module: import { HotkeyModule } from '@delon/abc/hotkey';
99

1010
基于 [@github/hotke](https://github.com/github/hotkey) 热键库。
1111

12-
> 如果不清楚热键值,可通过[热键代码](https://github.github.io/hotkey/hotkey_mapper.html)来获取。
12+
> 如果不清楚热键值,可通过[热键代码](https://github.github.com/hotkey/hotkey_mapper.html)来获取。
1313
1414
## API
1515

packages/abc/st/st-td.component.html

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
</ng-template>
1010
<ng-template #btnItemTpl let-i>
1111
@if (i.pop) {
12+
@let pop = i.pop;
1213
<a
1314
nz-popconfirm
14-
[nzPopconfirmTitle]="i.pop.title"
15-
[nzIcon]="i.pop.icon"
16-
[nzCondition]="i.pop.condition(i)"
17-
[nzCancelText]="i.pop.cancelText"
18-
[nzOkText]="i.pop.okText"
19-
[nzOkType]="i.pop.okType"
15+
[nzPopconfirmTitle]="pop.title"
16+
[nzIcon]="pop.icon"
17+
[nzCondition]="pop.condition(i)"
18+
[nzCancelText]="pop.cancelText"
19+
[nzOkText]="pop.okText"
20+
[nzOkType]="pop.okType"
2021
(nzOnConfirm)="_btn(i)"
2122
class="st__btn-text"
2223
[ngClass]="i._className"
@@ -32,15 +33,16 @@
3233
</ng-template>
3334
<ng-template #btnTextTpl let-i>
3435
@if (i._icon) {
35-
@if (i._icon.iconfont) {
36-
<i nz-icon [nzIconfont]="i._icon.iconfont"></i>
36+
@let icon = i._icon;
37+
@if (icon.iconfont) {
38+
<i nz-icon [nzIconfont]="icon.iconfont"></i>
3739
} @else {
3840
<i
3941
nz-icon
40-
[nzType]="i._icon.type"
41-
[nzTheme]="i._icon.theme"
42-
[nzSpin]="i._icon.spin"
43-
[nzTwotoneColor]="i._icon.twoToneColor"
42+
[nzType]="icon.type"
43+
[nzTheme]="icon.theme"
44+
[nzSpin]="icon.spin"
45+
[nzTwotoneColor]="icon.twoToneColor"
4446
></i>
4547
}
4648
}
@@ -49,6 +51,7 @@
4951
@if (c.__render) {
5052
<ng-template [ngTemplateOutlet]="c.__render!" [ngTemplateOutletContext]="{ $implicit: i, index: index, column: c }" />
5153
} @else {
54+
@let col = i._values[cIdx];
5255
@switch (c.type) {
5356
@case ('checkbox') {
5457
<label nz-checkbox [nzDisabled]="i.disabled" [ngModel]="i.checked" (ngModelChange)="_checkbox($event)"></label>
@@ -57,35 +60,31 @@
5760
<label nz-radio [nzDisabled]="i.disabled" [ngModel]="i.checked" (ngModelChange)="_radio()"></label>
5861
}
5962
@case ('link') {
60-
<a (click)="_link($event)" [innerHTML]="i._values[cIdx]._text" [attr.title]="i._values[cIdx].text"></a>
63+
<a (click)="_link($event)" [innerHTML]="col._text" [attr.title]="col.text"></a>
6164
}
6265
@case ('tag') {
63-
<nz-tag [nzColor]="i._values[cIdx].color" [nz-tooltip]="i._values[cIdx].tooltip">
64-
<span [innerHTML]="i._values[cIdx]._text"></span>
66+
<nz-tag [nzColor]="col.color" [nz-tooltip]="col.tooltip">
67+
<span [innerHTML]="col._text"></span>
6568
</nz-tag>
6669
}
6770
@case ('badge') {
68-
<nz-badge
69-
[nzStatus]="i._values[cIdx].color"
70-
[nzText]="i._values[cIdx].text"
71-
[nz-tooltip]="i._values[cIdx].tooltip"
72-
/>
71+
<nz-badge [nzStatus]="col.color" [nzText]="col.text" [nz-tooltip]="col.tooltip" />
7372
}
7473
@case ('cell') {
75-
<cell [value]="i._values[cIdx].text" [options]="i._values[cIdx].cell ?? c.cell" />
74+
<cell [value]="col.text" [options]="col.cell ?? c.cell" />
7675
}
7776
@case ('widget') {
7877
<ng-template st-widget-host [record]="i" [column]="c" />
7978
}
8079
@default {
8180
@if (c.safeType === 'text') {
82-
<span [innerText]="i._values[cIdx]._text" [attr.title]="c._isTruncate ? i._values[cIdx].text : null"></span>
81+
<span [innerText]="col._text" [attr.title]="c._isTruncate ? col.text : null"></span>
8382
} @else {
84-
<span [innerHTML]="i._values[cIdx]._text" [attr.title]="c._isTruncate ? i._values[cIdx].text : null"></span>
83+
<span [innerHTML]="col._text" [attr.title]="c._isTruncate ? col.text : null"></span>
8584
}
8685
}
8786
}
88-
@for (btn of i._values[cIdx].buttons; track $index) {
87+
@for (btn of col.buttons; track $index) {
8988
@if (btn.children!.length > 0) {
9089
<a nz-dropdown [nzDropdownMenu]="btnMenu" nzOverlayClassName="st__btn-sub">
9190
<span [innerHTML]="btn._text"></span>

packages/abc/st/st.component.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
<th nzWidth="50px" [rowSpan]="_headers.length"></th>
6262
}
6363
@for (h of row; track h; let index = $index; let last = $last) {
64+
@let _c = h.column;
6465
<th
65-
*let="h.column as _c"
6666
[colSpan]="h.colSpan"
6767
[rowSpan]="h.rowSpan"
6868
[nzWidth]="$any(_c).width"
@@ -172,14 +172,15 @@
172172
</ng-template>
173173
}
174174
@for (c of _columns; track cIdx; let cIdx = $index) {
175-
@if (i._values[cIdx].props?.colSpan > 0 && i._values[cIdx].props?.rowSpan > 0) {
175+
@let props = i._values[cIdx].props;
176+
@if (props?.colSpan > 0 && props?.rowSpan > 0) {
176177
<td
177178
[nzLeft]="!!c._left"
178179
[nzRight]="!!c._right"
179180
[attr.data-col-index]="cIdx"
180181
[ngClass]="c._className"
181-
[attr.colspan]="i._values[cIdx].props?.colSpan === 1 ? null : i._values[cIdx].props?.colSpan"
182-
[attr.rowspan]="i._values[cIdx].props?.rowSpan === 1 ? null : i._values[cIdx].props?.rowSpan"
182+
[attr.colspan]="props?.colSpan === 1 ? null : props?.colSpan"
183+
[attr.rowspan]="props?.rowSpan === 1 ? null : props?.rowSpan"
183184
>
184185
@if (responsive) {
185186
<span class="ant-table-rep__title">

packages/abc/st/st.module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { NgModule } from '@angular/core';
33
import { FormsModule } from '@angular/forms';
44

55
import { CellModule } from '@delon/abc/cell';
6-
import { LetModule } from '@delon/abc/let';
76
import { DelonACLModule } from '@delon/acl';
87
import { NzBadgeModule } from 'ng-zorro-antd/badge';
98
import { NzCheckboxModule } from 'ng-zorro-antd/checkbox';
@@ -33,7 +32,6 @@ const COMPONENTS = [STComponent, STRowDirective, STWidgetHostDirective];
3332
CommonModule,
3433
FormsModule,
3534
DelonACLModule,
36-
LetModule,
3735
CellModule,
3836
NzPopconfirmModule,
3937
NzTableModule,

packages/form/src/sf.component.html

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
</ng-template>
44
<ng-template #btnTpl>
55
@if (button !== 'none') {
6-
@if (_btn && _btn.render) {
7-
<nz-form-item [ngClass]="_btn.render!.class!" class="sf-btns" [fixed-label]="_btn.render!.spanLabelFixed!">
6+
@let btnRender = _btn.render;
7+
@if (btnRender) {
8+
<nz-form-item [ngClass]="btnRender.class!" class="sf-btns" [fixed-label]="btnRender.spanLabelFixed!">
89
<div
910
nz-col
1011
class="ant-form-item-control"
@@ -25,7 +26,7 @@
2526
nz-button
2627
data-type="submit"
2728
[nzType]="_btn.submit_type!"
28-
[nzSize]="_btn.render!.size!"
29+
[nzSize]="btnRender.size!"
2930
[nzLoading]="loading"
3031
[disabled]="liveValidate && !valid"
3132
>
@@ -46,17 +47,18 @@
4647
nz-button
4748
data-type="reset"
4849
[nzType]="_btn.reset_type!"
49-
[nzSize]="_btn.render!.size!"
50+
[nzSize]="btnRender.size!"
5051
[disabled]="loading"
5152
(click)="reset(true)"
5253
>
53-
@if (_btn.reset_icon) {
54+
@let resetIcon = _btn.reset_icon;
55+
@if (resetIcon) {
5456
<i
5557
nz-icon
56-
[nzType]="_btn.reset_icon.type!"
57-
[nzTheme]="_btn.reset_icon.theme!"
58-
[nzTwotoneColor]="_btn.reset_icon.twoToneColor!"
59-
[nzIconfont]="_btn.reset_icon.iconfont!"
58+
[nzType]="resetIcon.type!"
59+
[nzTheme]="resetIcon.theme!"
60+
[nzTwotoneColor]="resetIcon.twoToneColor!"
61+
[nzIconfont]="resetIcon.iconfont!"
6062
></i>
6163
}
6264
{{ _btn.reset }}

0 commit comments

Comments
 (0)