Skip to content

Commit 2b78e9e

Browse files
committed
Tabbug修复
1 parent 7d257cd commit 2b78e9e

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

src/app/base-data/person-manage.service.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { Injectable } from '@angular/core';
22
import { Http } from '@angular/http';
33

4-
import { ITablePersonItem } from './model/table-person-item';
4+
import { IPersonItem } from './model/table-person-item';
55
import 'rxjs/add/operator/toPromise';
66
@Injectable()
77
export class PersonManageService {
88

99
private personUrl = 'assets/mock-data/person.json';
1010
constructor(private http: Http) { }
1111

12-
getPersons(): Promise<ITablePersonItem[]> {
12+
getPersons(): Promise<IPersonItem[]> {
1313
return this.http
1414
.get(this.personUrl)
1515
.toPromise()
16-
.then(response => response.json() as ITablePersonItem[])
16+
.then(response => response.json() as IPersonItem[])
1717
.catch(this.handleError);
1818
}
1919

src/app/layout/header/tab/tabControl.service.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export class TabControlService {
9797
closeAll() {
9898
this.tabs.length = 1;
9999
this.tabsModel.activeTab = 0;
100-
101100
this.router.navigate(['/home']);
102101
}
103102

@@ -109,11 +108,10 @@ export class TabControlService {
109108
}
110109
const retainList = [],
111110
currentTabIndex = this.tabsModel.activeTab;
112-
retainList.push(this.tabs[0]);
113-
retainList.push(this.tabs[currentTabIndex]);
114-
this.tabs = retainList;
111+
this.tabsModel.tabs[1] = this.tabsModel.tabs[currentTabIndex];
112+
this.tabs.length = 2;
115113
this.tabsModel.activeTab = 1;
116-
this.router.navigate([this.tabs[1].link]);
114+
this.router.navigate([this.tabsModel.tabs[1].link]);
117115
}
118116

119117
// 关闭tab

src/app/layout/header/tab/tabs.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export class Md2Tabs implements OnInit, AfterContentInit {
131131
this._updateInkBar();
132132
if (this.tabs) {
133133
const tabs = this.tabs.toArray();
134-
if (!tabs[value].disabled) {
134+
if (tabs[value] && !tabs[value].disabled) {
135135
tabs.forEach(tab => tab.active = false);
136136
tabs[value].active = true;
137137
}
@@ -184,16 +184,19 @@ export class Md2Tabs implements OnInit, AfterContentInit {
184184
// 关闭所有页面
185185
closeAll() {
186186
this.tabControlService.closeAll();
187+
this.adjustOffset();
187188
}
188189

189190
// 关闭其它页面
190191
closeOther() {
191192
this.tabControlService.closeOther();
193+
this.adjustOffset();
192194
}
193195

194196
// 关闭当前页面
195197
closeNow() {
196198
this.tabControlService.closeTab();
199+
this.adjustOffset();
197200
}
198201

199202
/**
@@ -316,7 +319,7 @@ export class Md2Tabs implements OnInit, AfterContentInit {
316319
this.element.tabs.forEach((tab: any) => {
317320
canvasWidth -= tab.offsetWidth;
318321
});
319-
this.shouldPaginate = canvasWidth < 0;
322+
this.shouldPaginate = canvasWidth < -70;
320323

321324
const manageBtn = $('#tab_manage_btn'),
322325
canvas = $('.md2-tabs-canvas');

src/app/user/user.service.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ export class UserService implements CanActivate {
5959

6060
public logout(): void {
6161
this.tabControlService.closeAll();
62-
localStorage.removeItem('currentUser');
63-
this.userId = null;
64-
this.subject.next(Object.assign({}));
65-
this.router.navigate([{ outlets: { user: ['user-login'] } }]);
62+
setTimeout(() => {
63+
localStorage.removeItem('currentUser');
64+
this.userId = null;
65+
this.subject.next(Object.assign({}));
66+
this.router.navigate([{ outlets: { user: ['user-login'] } }]);
67+
}, 100);
68+
6669
}
6770

6871
public forgetPwd(email: string): Observable<any> {
@@ -93,8 +96,8 @@ export class UserService implements CanActivate {
9396
}
9497

9598
// 检测邮箱是否已注册
96-
public isEmailUsed(email: string){
97-
return Observable.create((observer)=>{
99+
public isEmailUsed(email: string) {
100+
return Observable.create((observer) => {
98101
observer.next(false);
99102
})
100103
}

src/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
<meta name="viewport" content="width=device-width, initial-scale=1">
1010
<link rel="icon" type="image/x-icon" href="favicon.ico">
11-
<!--<script src="//cdn.ckeditor.com/4.6.2/full/ckeditor.js"></script>-->
1211
<script src="./assets/global/plugins/ckeditor/ckeditor.js"></script>
1312
<script src="http://webapi.amap.com/maps?v=1.3&key=7abcc68bf0add08f839b8466d8bae876"></script>
1413
</head>

0 commit comments

Comments
 (0)