Skip to content

Commit 0be6178

Browse files
authored
feat(module:qrcode): qrcode supports scanned state (#8447)
1 parent e83578e commit 0be6178

File tree

7 files changed

+19
-10
lines changed

7 files changed

+19
-10
lines changed

components/i18n/languages/en_US.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ export default {
189189
},
190190
QRCode: {
191191
expired: 'QR code expired',
192-
refresh: 'Refresh'
192+
refresh: 'Refresh',
193+
scanned: 'Scanned'
193194
}
194195
};

components/i18n/languages/zh_CN.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export default {
185185
},
186186
QRCode: {
187187
expired: '二维码过期',
188-
refresh: '点击刷新'
188+
refresh: '点击刷新',
189+
scanned: '已扫描'
189190
}
190191
};

components/i18n/nz-i18n.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export type NzCronExpressionI18nInterface = NzCronExpressionCronErrorI18n & NzCr
149149
export interface NzQRCodeI18nInterface {
150150
expired: string;
151151
refresh: string;
152+
scanned: string;
152153
}
153154

154155
export interface NzI18nInterface {

components/qr-code/demo/status.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ title:
77

88
## zh-CN
99

10-
通过 `nzStatus` 的值控制二维码的状态。
10+
通过 `nzStatus` 的值控制二维码的状态,提供了 `active``expired``loading``scanned` 四个值
1111

1212
## en-US
1313

14-
The status can be controlled by the value `nzStatus`.
14+
The status can be controlled by the value `nzStatus`, four values of `active`, `expired`, `loading`, `scanned` are provided.

components/qr-code/demo/status.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Component } from '@angular/core';
55
template: `
66
<nz-qrcode nzValue="https://ng.ant.design/" nzStatus="loading"></nz-qrcode>
77
<nz-qrcode nzValue="https://ng.ant.design/" nzStatus="expired" (nzRefresh)="refresh($event)"></nz-qrcode>
8+
<nz-qrcode nzValue="https://ng.ant.design/" nzStatus="scanned"></nz-qrcode>
89
`,
910
styles: [
1011
`

components/qr-code/qrcode.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class NzTestQrCodeBasicComponent {
2020
value: string = 'https://ng.ant.design/';
2121
size: number = 160;
2222
bordered: boolean = true;
23-
status: 'active' | 'expired' | 'loading' = 'active';
23+
status: 'active' | 'expired' | 'loading' | 'scanned' = 'active';
2424
}
2525

2626
describe('nz-qrcode', () => {
@@ -54,16 +54,16 @@ describe('nz-qrcode', () => {
5454
});
5555

5656
it('qr code status', () => {
57-
const statusList: Array<'active' | 'expired' | 'loading'> = ['expired', 'loading'];
57+
const statusList: Array<'active' | 'expired' | 'loading' | 'scanned'> = ['expired', 'loading', 'scanned'];
5858

5959
for (let i = 0; i < statusList.length; i++) {
6060
testComponent.status = statusList[i];
6161
fixture.detectChanges();
6262
const statusView = resultEl.nativeElement.querySelector('.ant-qrcode-mask');
63-
if (i === 0) {
64-
expect(statusView.firstElementChild.tagName).toBe('DIV');
65-
} else {
63+
if (i === 1) {
6664
expect(statusView.firstElementChild.tagName).toBe('NZ-SPIN');
65+
} else {
66+
expect(statusView.firstElementChild.tagName).toBe('DIV');
6767
}
6868
}
6969
});

components/qr-code/qrcode.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ import { drawCanvas, ERROR_LEVEL_MAP, plotQRCodeData } from './qrcode';
5151
</button>
5252
</div>
5353
}
54+
@case ('scanned') {
55+
<div>
56+
<p class="ant-qrcode-expired">{{ locale.scanned }}</p>
57+
</div>
58+
}
5459
}
5560
</div>
5661
}
@@ -76,7 +81,7 @@ export class NzQRCodeComponent implements OnInit, AfterViewInit, OnChanges, OnDe
7681
@Input() nzIcon: string = '';
7782
@Input() nzIconSize: number = 40;
7883
@Input() nzBordered: boolean = true;
79-
@Input() nzStatus: 'active' | 'expired' | 'loading' = 'active';
84+
@Input() nzStatus: 'active' | 'expired' | 'loading' | 'scanned' = 'active';
8085
@Input() nzLevel: keyof typeof ERROR_LEVEL_MAP = 'M';
8186

8287
@Output() readonly nzRefresh = new EventEmitter<string>();

0 commit comments

Comments
 (0)