From 5454a747a729ea7cb310feed32b82698e07aed71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BE=E5=87=A0=E6=B5=B7?= Date: Fri, 7 Aug 2020 21:29:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=BD=91=E7=AB=99=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E9=A2=84=E8=A7=88=E5=92=8C=E5=8F=8B=E9=93=BE=E9=A1=B5?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E8=87=AA=E5=8A=A8=E8=A1=A5=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/view/link/link.component.html | 8 +++++++- src/app/view/link/link.component.ts | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/view/link/link.component.html b/src/app/view/link/link.component.html index b818b8f..f42631b 100644 --- a/src/app/view/link/link.component.html +++ b/src/app/view/link/link.component.html @@ -122,7 +122,13 @@ 网站图标 - + + + + + icon + diff --git a/src/app/view/link/link.component.ts b/src/app/view/link/link.component.ts index 007e0cc..822bdf9 100644 --- a/src/app/view/link/link.component.ts +++ b/src/app/view/link/link.component.ts @@ -30,6 +30,7 @@ export class LinkComponent implements OnInit { loading: boolean = false; applyFormGroup: FormGroup; colors: Color[]; + private lastUrl: string = ''; ngOnInit() { @@ -50,6 +51,13 @@ export class LinkComponent implements OnInit { name: [null, [Validators.required, Validators.maxLength(255)]], url: [null, [Validators.required, Validators.pattern(/^([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$/)]] }); + this.applyFormGroup.controls.url.valueChanges.subscribe({ + next: data => { + const linkUrlData: string = this.applyFormGroup.value.linkUrl || ''; + this.applyFormGroup.patchValue({linkUrl: linkUrlData.replace(this.lastUrl, data)}); + this.lastUrl = data; + }, + }) } apply() {