import { switchMap } from 'rxjs/operators'; import { Component, OnInit } from '@angular/core'; import { MessagerService } from '@farris/ui-messager'; import { EMPTY } from 'rxjs'; @Component({ selector: 'messager-demo', templateUrl: './messager-demo.component.html' }) export class MessagerDemoComponent implements OnInit { fitContentString = ''; constructor(private msgSer: MessagerService) { this.fitContentString = '这是非常长的消息,足以产生滚动条!!' + '君不见黄河之水天上来,奔流到海不复回。' + '君不见高堂明镜悲白发,朝如青丝暮成雪。' + '人生得意须尽欢⑷,莫使金樽空对月。' + '天生我材必有用,千金散尽还复来。' + '烹羊宰牛且为乐,会须一饮三百杯。' + '岑夫子,丹丘生⑹,将进酒,杯莫停。' + '与君歌一曲⑻,请君为我倾耳听。' + '钟鼓馔玉不足贵⑽,但愿长醉不复醒。' + '古来圣贤皆寂寞,惟有饮者留其名。' + '陈王昔时宴平乐,斗酒十千恣欢谑。' + '主人何为言少钱⒀,径须沽取对君酌。' + '五花马、千金裘,呼儿将出换美酒,与尔同销万古愁'; } ngOnInit(): void { } showPrompt(showlong = false, fitContent = true) { let message = showlong ? this.fitContentString + this.fitContentString + this.fitContentString + this.fitContentString : '请留下过路费:'; this.msgSer.prompt('请留下过路费', message, fitContent).subscribe((v) => { console.log(v); }); } showConfirm(showlong = false, fitContent = true) { let message = showlong ? this.fitContentString + this.fitContentString + this.fitContentString + this.fitContentString : ''; this.msgSer.confirm('确认要执行删除操作吗?', message, fitContent).pipe( switchMap((r) => { return r ? this.msgSer.prompt('请留下过路费:') : EMPTY; }) ).subscribe((v) => { console.log(v); }); } primary(showlong = false, fitContent = true) { let message = showlong ? this.fitContentString + this.fitContentString + this.fitContentString + this.fitContentString : ''; this.msgSer.info('这是一条提示消息', () => { }, message, fitContent); } success(showlong = false, fitContent = true) { let message = showlong ? this.fitContentString + this.fitContentString + this.fitContentString + this.fitContentString : ''; this.msgSer.success('这是一条成功消息', message, fitContent); } danger(showlong = false, fitContent = true) { let message = showlong ? this.fitContentString + this.fitContentString + this.fitContentString + this.fitContentString : ''; this.msgSer.error('这是一条错误消息', message, fitContent); } warning(showlong = false, fitContent = true) { let message = showlong ? this.fitContentString : '这是一条警告消息'; this.msgSer.warning('这是一条警告消息', message, fitContent); } comfirm(showlong = false, fitContent = true) { let message = showlong ? this.fitContentString : ''; this.msgSer.confirm('确认删除?', message, fitContent).subscribe(() => { this.msgSer.confirm('在问你一次,真的要执行删除操作吗?'); }); } }