Skip to content

Commit 43436d4

Browse files
committed
refactor: 代码内容优化
1 parent 72e1f93 commit 43436d4

15 files changed

+49
-100
lines changed

src/app/app.module.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import {AppComponent} from "./app.component";
99

1010
import {CollectionComponent} from './collection/collection.component';
1111
import {ListComponent, ItemComponent} from './list';
12-
import {DetailComponent, AnotationComponent} from './detail';
12+
import {DetailComponent} from './detail';
1313
import {EditComponent} from './edit/edit.component';
1414

1515
import {ContactService} from "./shared/contact.service";
1616
import {FooterComponent} from './shared/footer.component';
17-
import {DateReformPipe} from './shared/date-reform.pipe';
17+
import {PhonePipe} from './shared/phone.pipe';
1818
import {BtnClickDirective} from './shared/btn-click.directive';
1919
import {UtilService} from './shared/util.service';
2020

@@ -24,12 +24,11 @@ import {UtilService} from './shared/util.service';
2424
AppComponent,
2525
ListComponent,
2626
DetailComponent,
27-
AnotationComponent,
2827
CollectionComponent,
2928
EditComponent,
3029
FooterComponent,
3130
ItemComponent,
32-
DateReformPipe,
31+
PhonePipe,
3332
BtnClickDirective
3433
],
3534
imports : [BrowserModule, FormsModule, HttpModule, RouterModule.forRoot(rootRouterConfig)],

src/app/app.routes.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ export const rootRouterConfig: Routes = [
1818
},
1919
{
2020
path: "list/:id",
21-
component: DetailComponent,
22-
children: [
23-
{
24-
path: "",
25-
component: AnotationComponent
26-
}
27-
]
21+
component: DetailComponent
2822
},
2923
{
3024
path: "edit",

src/app/collection/collection.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ <h3 *ngIf="coll_length == 0" class="no-collection">没有收藏</h3>
33
<ul class="my-collection">
44
<li *ngFor="let collection of collections">
55
<a [routerLink]="['/list', collection.id]">
6-
<label>{{ collection.name }}</label><span>{{ collection.telNum }}</span>
6+
<label>{{ collection.name }}</label><span>{{ collection.telNum | phone }}</span>
77
</a>
88
</li>
99
</ul>

src/app/detail/anotation.component.css

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/app/detail/anotation.component.html

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/app/detail/anotation.component.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/app/detail/detail.component.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,11 @@
8080
line-height: 20px;
8181
padding-top: 5px;
8282
}
83+
84+
.intro{
85+
padding: 20px 15px 0;
86+
}
87+
.intro h3{
88+
font-size: 18px;
89+
padding-bottom: 10px;
90+
}

src/app/detail/detail.component.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@
1616
<ul class="detail-info">
1717
<li>
1818
<p>手机号码:</p>
19-
<p>{{ detail.telNum }}</p>
19+
<p>{{ detail.telNum | phone }}</p>
2020
</li>
2121
<li>
2222
<p>邮箱:</p>
2323
<p>{{ detail.email }}</p>
2424
</li>
2525
<li>
2626
<p>生日:</p>
27-
<p>{{ detail.birthday | dateReform:'yyyy-MM-dd'}}</p>
27+
<p>{{ detail.birthday | date:'yyyy-MM-dd'}}</p>
2828
</li>
2929
<li>
3030
<p>住址:</p>
3131
<p>{{ detail.address }}</p>
3232
</li>
3333
</ul>
34-
<router-outlet></router-outlet>
34+
<article class="intro">
35+
<h3>简介:</h3>
36+
生活态度好,热爱运动
37+
</article>
3538
</div>

src/app/detail/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export * from './detail.component';
2-
export * from './anotation.component';

src/app/edit/edit.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ export class EditComponent implements OnInit {
123123
}
124124
onBlurPhone() {
125125
this.phoneTip = true;
126-
this.isPhoneNum = util.checkPhoneNum(this.contact.telNum);
126+
this.isPhoneNum = this.util.checkPhoneNum(this.contact.telNum);
127127
}
128128
onBlurAddr() {
129129
this.addrTip = true;
130130
this.isAddr = this.contact.address ? true : false;
131131
}
132132
onBlurEmail() {
133133
this.emailTie = true;
134-
this.isEmail = util.checkEmail(this.contact.email);
134+
this.isEmail = this.util.checkEmail(this.contact.email);
135135
}
136136
onBlurBir() {
137137
this.birTip = true;

0 commit comments

Comments
 (0)