新增cookie保存当前打开的tab,刷新系统的时候保持原来的tab打开状态
This commit is contained in:
parent
7b60d5afdc
commit
3692eb18d9
@ -23,17 +23,17 @@
|
||||
|
||||
<div class="layui-layout-right">
|
||||
<span class="gg-head-item gg-head-refresh">
|
||||
<a href="javascript:;" class="refreshThis" gg-event="refresh" title="刷新">
|
||||
<a href="javascript:;" class="refreshThis" gg-event="refresh" title="刷新页面">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
</a>
|
||||
</span>
|
||||
<span class="gg-head-item gg-head-screen">
|
||||
<span class="gg-head-item gg-head-screen" title="切换全屏">
|
||||
<a href="javascript:;" gg-event="screen" data-screen="full">
|
||||
<i class="fullScreen layui-icon layui-icon-screen-full"></i>
|
||||
</a>
|
||||
</span>
|
||||
<span class="gg-head-item gg-head-set">
|
||||
<a href="javascript:;" id="theme">
|
||||
<a href="javascript:;" id="theme" title="切换主题">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
</a>
|
||||
</span>
|
||||
@ -151,6 +151,19 @@
|
||||
var msgStatus=0,isClose=0,msgNum = 0;
|
||||
const moduleInit = ['tool','admin'];
|
||||
function gouguInit() {
|
||||
let admin = layui.admin;
|
||||
let tabs = admin.getCookie('gougutab');
|
||||
if(tabs && tabs!=''){
|
||||
let tab_parse = JSON.parse(tabs);
|
||||
let tab_id = tab_parse.tab_id,tab_array = tab_parse.tab_array;
|
||||
if(tab_array.length>0){
|
||||
for(let a=0; a<tab_array.length;a++){
|
||||
admin.tabAdd(tab_array[a].id, tab_array[a].url,tab_array[a].title);
|
||||
}
|
||||
admin.tabChange(tab_id);
|
||||
}
|
||||
}
|
||||
|
||||
$('#GouguApp').on("click",'[gg-event="logout"]',function () {
|
||||
layer.confirm('确认注销登录吗?', { icon: 7, title: '警告' }, function (index) {
|
||||
//注销
|
||||
|
@ -74,7 +74,7 @@
|
||||
<script type="text/javascript">
|
||||
layui.use(['form'], function() {
|
||||
var form = layui.form,
|
||||
$ = layui.$;
|
||||
$ = layui.$,
|
||||
layer = layui.layer;
|
||||
// 登录过期的时候,跳出ifram框架
|
||||
if (top.location != self.location) top.location = self.location;
|
||||
@ -87,10 +87,13 @@
|
||||
success: function(res) {
|
||||
layer.tips(res.msg, '#login-submit');
|
||||
if (res.code === 0) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (-1 * 24 * 60 * 60 * 1000));
|
||||
var expires = "; expires=" + date.toGMTString();
|
||||
document.cookie = "gougutab=''" + expires + "; path=/";
|
||||
setTimeout(function() {
|
||||
// parent.document.location.reload();
|
||||
parent.document.location.href="/";
|
||||
}, 1500);
|
||||
}, 1200);
|
||||
} else {
|
||||
$('[alt="captcha"]').click();
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ layui.define(['element'], function (exports) {
|
||||
}
|
||||
element.tabAdd('gg-admin-tab', {
|
||||
id: id,
|
||||
url:url,
|
||||
title: '<span class="gg-tab-active"></span>' + title,
|
||||
content: '<iframe id="' + id + '" data-frameid="' + id + '" src="' + url + '" frameborder="0" align="left" width="100%" height="100%" scrolling="yes"></iframe>',
|
||||
});
|
||||
@ -92,6 +93,51 @@ layui.define(['element'], function (exports) {
|
||||
var src = parent.document.getElementById(id).contentWindow.location.href ? parent.document.getElementById(id).contentWindow.location.href : iframe.src;
|
||||
document.getElementById(id).src = src;
|
||||
}
|
||||
},
|
||||
tabCookie:function(){
|
||||
let thetabs = $('#pageTabUl').find('li');
|
||||
let tab_id = 0,tab_array=[];
|
||||
$('#pageTabUl li').each(function(index,item){
|
||||
let _id = $(item).attr('lay-id'),_url = $(item).attr('lay-url'),_title = $(item).text();
|
||||
if(_id>0){
|
||||
tab_array.push({'id':_id,'url':_url,'title':_title});
|
||||
}
|
||||
if($(item).hasClass('layui-this')){
|
||||
tab_id = _id;
|
||||
}
|
||||
})
|
||||
if(tab_array.length>0){
|
||||
let tabs_obj = {
|
||||
'tab_id':tab_id,
|
||||
'tab_array':tab_array
|
||||
}
|
||||
//console.log(tabs_obj);
|
||||
tab.setCookie('gougutab',JSON.stringify(tabs_obj));
|
||||
}
|
||||
else{
|
||||
tab.delCookie('gougutab');
|
||||
}
|
||||
},
|
||||
setCookie: function (name, value, days) {
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
var expires = "; expires=" + date.toGMTString();
|
||||
}
|
||||
else {
|
||||
var expires = "";
|
||||
}
|
||||
document.cookie = name + "=" + value + expires + "; path=/";
|
||||
},
|
||||
getCookie: function (name) {
|
||||
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
|
||||
if (arr != null) {
|
||||
return unescape(arr[ 2 ]);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
delCookie: function (name) {
|
||||
this.setCookie(name, "", -1);
|
||||
}
|
||||
};
|
||||
//切换tab
|
||||
@ -99,11 +145,13 @@ layui.define(['element'], function (exports) {
|
||||
$('#GouguAppBody').find('.gg-tab-page').removeClass('layui-show');
|
||||
$('#GouguAppBody').find('.gg-tab-page').eq(data.index).addClass('layui-show');
|
||||
tab.tabRoll("auto", data.index);
|
||||
tab.tabCookie();
|
||||
});
|
||||
//删除tab
|
||||
element.on('tabDelete(gg-admin-tab)', function (data) {
|
||||
$('#GouguAppBody').find('.gg-tab-page').eq(data.index).remove();
|
||||
tab.tabRoll("auto", data.index);
|
||||
tab.tabCookie();
|
||||
});
|
||||
|
||||
//右滚动tab
|
||||
|
Loading…
x
Reference in New Issue
Block a user