提交 a3c0b364 编写于 作者: tony001's avatar tony001

Update navdata-service.ts

上级 d1347f34
......@@ -319,7 +319,20 @@ export default class NavDataService {
* @memberof NavDataService
*/
public addNavDataByOnly(curNavData:NavDataElement){
this.navDataStack.push(curNavData);
if(this.navDataStack.length >0){
let tempIndex:number = this.navDataStack.findIndex((element:NavDataElement) =>{
return Object.is(element.tag,curNavData.tag);
})
if(tempIndex === -1){
this.navDataStack.push(curNavData);
}else{
this.navDataStack[tempIndex] = curNavData;
}
}else{
this.navDataStack.push(curNavData);
}
this.sessionStore.setItem('srfnavdata',JSON.stringify(this.navDataStack));
return curNavData;
}
/**
......@@ -339,4 +352,32 @@ export default class NavDataService {
return null;
}
}
/**
* 从导航数据栈中获取指定元素前一个元素
*
* @memberof NavDataService
*/
public getPreNavDataByTag(viewtag:string){
if(this.navDataStack.length >0){
let tempIndex:number = this.navDataStack.findIndex((element:NavDataElement) =>{
return Object.is(element.tag,viewtag);
})
return this.navDataStack[tempIndex - 1]?this.navDataStack[tempIndex - 1]:null;
}else{
return null;
}
}
/**
* 从导航数据栈中删除所有数据
*
* @memberof NavDataService
*/
public removeAllNavData(){
if(this.navDataStack.length >0){
this.navDataStack = [];
this.sessionStore.setItem('srfnavdata',JSON.stringify(this.navDataStack));
}
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册