8000 fix: default thyCopyText · atinc/ngx-tethys@adaf5db · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit adaf5db

Browse files
committed
fix: default thyCopyText
1 parent 81ff6db commit adaf5db

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

demo/src/app/components/+copy/copy-section.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export class DemoCopySectionComponent {
99
constructor(private notifyService: ThyNotifyService) {}
1010
copy(event: ThyCopyEvent) {
1111
if (event.isSuccess) {
12-
this.notifyService.success('编号已成功复制到粘贴板');
12+
console.log('复制成功啦');
1313
} else {
14-
this.notifyService.error('复制失败');
14+
console.log('复制失败啦');
1515
}
1616
}
1717
}

src/directive/thy-copy.directive.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class ThyCopyDirective implements OnInit, OnDestroy {
2929
// 默认为点击标签,可传复制目标标签
3030
@Output() thyCopy = new EventEmitter<ThyCopyEvent>();
3131

32-
@Input('thyCopyNotifyText') thyCopyNotifyText: string;
32+
@Input('thyCopyNotifyText') thyCopyNotifyText = '复制成功';
3333

3434
@Input('thyCopyContent') thyCopyContent: string | ElementRef | HTMLElement;
3535

@@ -63,14 +63,10 @@ export class ThyCopyDirective implements OnInit, OnDestroy {
6363
try {
6464
document.execCommand('copy', false, null);
6565
this.thyCopy.emit({ isSuccess: true, event });
66-
if (this.thyCopyNotifyText) {
67-
this.notifyService.success(this.thyCopyNotifyText);
68-
}
66+
this.notifyService.success(this.thyCopyNotifyText);
6967
} catch (err) {
7068
this.thyCopy.emit({ isSuccess: false, even 61A1 t });
71-
if (this.thyCopyNotifyText) {
72-
this.notifyService.error('复制失败');
73-
}
69+
this.notifyService.error('复制失败');
7470
} finally {
7571
input.remove();
7672
}

0 commit comments

Comments
 (0)
0