Skip to content

Commit

Permalink
💩 优化部分模块功能
Browse files Browse the repository at this point in the history
  • Loading branch information
esofar committed Oct 1, 2020
1 parent dccbde6 commit 4814300
Show file tree
Hide file tree
Showing 29 changed files with 94 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
[![](https://data.jsdelivr.com/v1/package/gh/esofar/cnblogs-theme-silence/badge)](https://www.jsdelivr.com/package/gh/esofar/cnblogs-theme-silence)
[![Gitter](https://img.shields.io/gitter/room/esofar/cnblogs-theme-silence?style=flat-square)](https://gitter.im/cnblogs-theme-silence/community)

❤️ 一款专注阅读的博客园主题,其追求大道至简的终极真理,界面追求简洁、运行追求高效、部署追求简单。
一款专注于阅读的博客园主题,其追求大道至简的终极真理,界面追求简洁、运行追求高效、部署追求简单。

## 快速安装
## 部署指南

📖 [https://github.com/esofar/cnblogs-theme-silence](https://github.com/esofar/cnblogs-theme-silence)
[https://github.com/esofar/cnblogs-theme-silence](https://github.com/esofar/cnblogs-theme-silence)


## 贡献代码
Expand Down
2 changes: 1 addition & 1 deletion dist/silence.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/silence.min.js

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions src/modules/customHeader/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import "./index.less";
import options from '@/consts/options';

function buildCustomHeader() {
const navs = options.navbars;
const $navList = $('#navList');

if (navs && navs.length) {
navs.reverse().forEach((nav) => {
nav.target = nav.target || '_self';
if (nav.chilren && nav.chilren.length) {
var subnavs = nav.chilren.map(function (subnav) {
subnav.target = subnav.target || '_self';
return `<li><a class="menu" target="${subnav.target}" href="${subnav.url}">${subnav.title}</a></li>`;
});
$navList.find('li').eq(1).after(`
<li class="esa-has-subnavs">
<a class="menu" href="javascript:void(0);">${nav.title}
<svg class="arrow" width="9px" height="9px" viewBox="0 0 13 7" xml:space="preserve" fill="none" stroke="var(--text-color)"><path d="M1,1l6.2,6L13,1"></path></svg>
</a>
<div class="esa-sub-navs"><div class="caret"></div><ul>${subnavs.join('')}</ul></div>
</li>`);
} else {
$navList.find('li').eq(1).after(`<li><a class="menu" target="${nav.target}" href="${nav.url}">${nav.title}</a></li>`);
}
});

$('li.esa-has-subnavs').hover(function () {
$(this).find('svg').addClass('open');
$(this).find('.esa-sub-navs').fadeIn('fast');
}, function () {
$(this).find('svg').removeClass('open');
$(this).find('.esa-sub-navs').hide();
});
}

$.each($navList.children('li'), (index, nav) => {
if($(nav).children('a').length){
$(nav).append('<i></i>');
}else{
$(nav).remove();
}
});

$('#header').prepend(`<div class="esa-mobile-menu"><i class="fa fa-bars"></i></div>`);
$('.esa-mobile-menu').on('click', () => {
$('#navigator').fadeToggle();
});

if (!options.showNavAdmin) {
$('#blog_nav_admin').parent().remove();
}
}

export default buildCustomHeader;
15 changes: 15 additions & 0 deletions src/modules/customHeader/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.esa-mobile-menu {
display: none;
position: fixed;
top: 17px;
right: 20px;
height: 25px;
width: 25px;
text-align: center;
line-height: 25px;
z-index: 941113;
font-size: 1.5em;
cursor: pointer;
color: var(--text-color);
border-radius: 4px;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions src/modules/profile/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import "./index.less";
import options from '@/consts/options';

function buildProfile() {
const avatar = options.avatar;
const favicon = options.favicon;
if (avatar) {
$('#sideBarMain').prepend(`<img class="esa-profile-avatar" src="${avatar}" />`);
};
if (favicon) {
$('#favicon').attr('href', favicon);
}
}

export default buildProfile;
4 changes: 4 additions & 0 deletions src/modules/profile/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.esa-profile-avatar {
border-radius: 4px;
width: 100%;
}
File renamed without changes.
File renamed without changes.

0 comments on commit 4814300

Please sign in to comment.