Skip to content

Commit

Permalink
解决csrf_token缺失报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jqhph committed Apr 1, 2021
1 parent 346fd57 commit cb2df23
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 252 deletions.
172 changes: 90 additions & 82 deletions resources/assets/dcat/js/bootstrappers/Menu.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,90 @@

export default class Menu {
constructor(Dcat) {
this.init();
this.initHorizontal();
}

// 菜单点击选中效果
init() {
if (! $('.main-sidebar .sidebar').length) {
return;
}

// 滚动条优化
new PerfectScrollbar('.main-sidebar .sidebar');

let $content = $('.main-menu-content'),
$items = $content.find('li'),
$hasSubItems = $content.find('li.has-treeview');

$items.find('a').click(function () {
let href = $(this).attr('href');
if (! href || href === '#') {
return;
}

$items.find('.nav-link').removeClass('active');
// $hasSubItems.removeClass('menu-open');

$(this).addClass('active')
});
}

initHorizontal() {
let selectors = {
item: '.horizontal-menu .main-menu-content li.nav-item',
link: '.horizontal-menu .main-menu-content li.nav-item .nav-link',
};

$(selectors.item).on('mouseover', function () {
$(this).addClass('open')
}).on('mouseout', function () {
$(this).removeClass('open')
});

$(selectors.link).on('click', function () {
let $this = $(this);

$(selectors.link).removeClass('active');

$this.addClass('active');

$this.parents('.dropdown').find('.nav-link').eq(0).addClass('active');
$this.parents('.dropdown-submenu').find('.nav-link').eq(0).addClass('active')
});

// 自动计算高度
let $horizontalMenu = $('.horizontal-menu .main-horizontal-sidebar'),
defaultHorizontalMenuHeight = $horizontalMenu.height(),
horizontalMenuTop = $horizontalMenu.offset().top + 15;

// 重新计算高度
let resize = function () {
if (! $('.horizontal-menu').length) {
return;
}

let height = $horizontalMenu.height(),
diff = height - defaultHorizontalMenuHeight,
$wrapper = $('.horizontal-menu.navbar-fixed-top .content-wrapper');

if (height <= defaultHorizontalMenuHeight) {
return $wrapper.css({'padding-top': horizontalMenuTop + 'px'});
}

$wrapper.css({'padding-top': (horizontalMenuTop + diff) + 'px'});
};
window.onresize = resize;

resize();
}
}

export default class Menu {
constructor(Dcat) {
this.init();
this.initHorizontal();
}

// 菜单点击选中效果
init() {
if (! $('.main-sidebar .sidebar').length) {
return;
}

// 滚动条优化
new PerfectScrollbar('.main-sidebar .sidebar');

let $content = $('.main-menu-content'),
$items = $content.find('li'),
$hasSubItems = $content.find('li.has-treeview');

$items.find('a').click(function () {
let href = $(this).attr('href');
if (! href || href === '#') {
return;
}

$items.find('.nav-link').removeClass('active');
// $hasSubItems.removeClass('menu-open');

$(this).addClass('active')
});
}

initHorizontal() {
let selectors = {
item: '.horizontal-menu .main-menu-content li.nav-item',
link: '.horizontal-menu .main-menu-content li.nav-item .nav-link',
};

$(selectors.item).on('mouseover', function () {
$(this).addClass('open')
}).on('mouseout', function () {
$(this).removeClass('open')
});

$(selectors.link).on('click', function () {
let $this = $(this);

$(selectors.link).removeClass('active');

$this.addClass('active');

$this.parents('.dropdown').find('.nav-link').eq(0).addClass('active');
$this.parents('.dropdown-submenu').find('.nav-link').eq(0).addClass('active')
});

// 自动计算高度
let $horizontalMenu = $('.horizontal-menu .main-horizontal-sidebar'),
defaultHorizontalMenuHeight = 0,
horizontalMenuTop = 0;

// 重新计算高度
let resize = function () {
if (! $('.horizontal-menu').length) {
return;
}

if (! defaultHorizontalMenuHeight) {
defaultHorizontalMenuHeight = $horizontalMenu.height()
}

if (! horizontalMenuTop) {
horizontalMenuTop = $horizontalMenu.offset().top + 15;
}

let height = $horizontalMenu.height(),
diff = height - defaultHorizontalMenuHeight,
$wrapper = $('.horizontal-menu.navbar-fixed-top .content-wrapper');

if (height <= defaultHorizontalMenuHeight) {
return $wrapper.css({'padding-top': horizontalMenuTop + 'px'});
}

$wrapper.css({'padding-top': (horizontalMenuTop + diff) + 'px'});
};
window.onresize = resize;

resize();
}
}
Loading

0 comments on commit cb2df23

Please sign in to comment.