Skip to content

Commit

Permalink
fix #114 刷新页面保存tab状态
Browse files Browse the repository at this point in the history
  • Loading branch information
newpanjing committed Jul 22, 2019
1 parent cdb94c3 commit 0b34252
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions simpleui/static/admin/simpleui-x/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@
}
});
}
/*,
tabs: function (newValue, oldValue) {

//改变tab时把状态储存到sessionStorage
console.log(newValue)
}*/
},
created: function () {

Expand Down Expand Up @@ -245,12 +251,22 @@
fontEvents.push(handler);
}
}
var temp_tabs = sessionStorage['tabs'];

if(location.hash!=''){
if (temp_tabs && temp_tabs != '') {
this.tabs = JSON.parse(temp_tabs);
console.log(this.tabs)
}
if (location.hash != '') {
openByHash();
}
},
methods: {
syncTabs: function () {
if (window.sessionStorage) {
sessionStorage['tabs'] = JSON.stringify(this.tabs);
}
},
reset: function () {
this.fontSlider = 14;
fontConfig.fontSize = 0;
Expand Down Expand Up @@ -350,6 +366,7 @@
if (targetName != 0) {
this.tabs = this.tabs.filter(tab => tab.id !== targetName);
}
this.syncTabs();
}
}
,
Expand Down Expand Up @@ -380,7 +397,7 @@
this.tabModel = data.id;
}
changeUrl(data)

this.syncTabs();
}
,
foldClick: function () {
Expand Down
2 changes: 1 addition & 1 deletion simpleui/templates/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
@tab-click="tabClick">

<el-tab-pane v-for="(item,index) in tabs" :closable="index!=0" :label="item.name" :name="item.id"
:key="item.id">
:key="item.id" lazy="true">

{% home_page %}

Expand Down

0 comments on commit 0b34252

Please sign in to comment.