Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
  • Loading branch information
cao-gift committed Jul 20, 2024
1 parent c5e757c commit 4603439
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 0 deletions.
16 changes: 16 additions & 0 deletions static/assets/GmeekBSZ.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function createBSZ() {
var postBody = document.getElementById('postBody');
if (postBody){
postBody.insertAdjacentHTML('afterend','<div id="busuanzi_container_page_pv" style="display:none;float:left;margin-top:8px;font-size:small;">本文浏览量<span id="busuanzi_value_page_pv"></span>次</div>');
}
var runday = document.getElementById('runday');
runday.insertAdjacentHTML('afterend', '<div id="busuanzi_container_site_pv" style="display:none;">总浏览量<span id="busuanzi_value_site_pv"></span>次 • </div>');
}

document.addEventListener("DOMContentLoaded", function() {
createBSZ();
var element = document.createElement('script');
element.src = '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js';
document.head.appendChild(element);
console.log("\n %c GmeekBSZ Plugins https://github.com/Meekdai/Gmeek \n","padding:5px 0;background:#bc4c00;color:#fff");
});
58 changes: 58 additions & 0 deletions static/assets/GmeekTOC.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function loadResource(type, attributes, callback) {
var element;
if (type === 'script') {
element = document.createElement('script');
element.src = attributes.src;
element.onload = callback;
} else if (type === 'link') {
element = document.createElement('link');
element.rel = attributes.rel;
element.href = attributes.href;
} else if (type === 'style') {
element = document.createElement('style');
element.rel = 'stylesheet';
element.appendChild(document.createTextNode(attributes.css));
}
document.head.appendChild(element);
}

function createTOC() {
var tocElement = document.createElement('div');
tocElement.className = 'toc';
var contentContainer = document.getElementById('content');
if (contentContainer.firstChild) {
contentContainer.insertBefore(tocElement, contentContainer.firstChild);
} else {
contentContainer.appendChild(tocElement);
}
}

document.addEventListener("DOMContentLoaded", function() {
createTOC();
var css = '.toc {position:fixed;top:130px;left:50%;transform: translateX(50%) translateX(300px);width:200px;padding-left:30px;}@media (max-width: 1249px) {.toc{position:static;top:auto;left:auto;transform:none;padding:10px;margin-bottom:20px;background-color:#eee;}}';
loadResource('style', {css: css});

loadResource('script', { src: 'https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/tocbot/4.27.4/tocbot.min.js' }, function() {
tocbot.init({
tocSelector: '.toc',
contentSelector: '.markdown-body',
headingSelector: 'h1, h2, h3, h4, h5, h6',
scrollSmooth: true,
scrollSmoothOffset: -10,
headingsOffset: 10,
});
});

loadResource('link', { rel: 'stylesheet', href: 'https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/tocbot/4.27.4/tocbot.css' });

const headings = document.querySelectorAll('.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6');
headings.forEach((heading) => {
if (!heading.id) {
heading.id = heading.textContent.trim().replace(/\s+/g, '-');
}
});

var footerPlaceholder = document.createElement('div');
footerPlaceholder.style.height = window.innerHeight + 'px';
document.body.appendChild(footerPlaceholder);
});
119 changes: 119 additions & 0 deletions static/assets/LoadingBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
(function () {
function loadjQuery(callback) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://blog.liyifan.xyz/lib/jquery.min.js';
script.onload = callback;
document.head.appendChild(script);
}

function createLoader() {
// 创建CSS样式
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `
.loaderbg {
background-color: #fff;
width: 100%;
height: 100%;
overflow: hidden;
position: fixed;
left: 0;
top: 0;
z-index: 99999999;
visibility: visible;
}
.spinner {
position: absolute;
top: 50%;
left: 50%;
margin-left: -25px;
margin-top: -30px;
width: 50px;
height: 60px;
text-align: center;
font-size: 10px;
}
.spinner > .double {
background: #49a9ee;
height: 100%;
width: 6px;
display: inline-block;
animation: stretchDelay 1.2s infinite ease-in-out;
}
.spinner .rect2 { animation-delay: -1.1s; }
.spinner .rect3 { animation-delay: -1.0s; }
.spinner .rect4 { animation-delay: -0.9s; }
.spinner .rect5 { animation-delay: -0.8s; }
@keyframes stretchDelay {
0%, 40%, 100% { transform: scaleY(0.4); }
20% { transform: scaleY(1); }
}
`;
document.head.appendChild(style);

// 创建加载条HTML
var loader = document.createElement('div');
loader.className = 'loaderbg';
loader.innerHTML = `
<div class="spinner">
<div class="double rect1"></div>
<div class="double rect2"></div>
<div class="double rect3"></div>
<div class="double rect4"></div>
<div class="double rect5"></div>
</div>
`;
document.body.appendChild(loader);

return loader;
}

function hideLoader(loader) {
loader.style.visibility = 'hidden';
}

function showLoader(loader) {
loader.style.visibility = 'visible';
}

function loadingSpinner(options) {
var settings = {
duration: 3000,
onComplete: function () {}
};

// 合并用户配置
if (options) {
for (var key in options) {
if (options.hasOwnProperty(key)) {
settings[key] = options[key];
}
}
}

var loader = createLoader();

// 页面加载完成后隐藏加载条
window.addEventListener('load', function () {
hideLoader(loader);
settings.onComplete();
});

return {
show: function () { showLoader(loader); },
hide: function () { hideLoader(loader); }
};
}


// 加载jQuery并初始化插件
loadjQuery(function () {
loadingSpinner({
duration: 3000,
onComplete: function () {
console.log("页面加载完成啦!");
}
});
});
})();
87 changes: 87 additions & 0 deletions static/assets/rain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

const rainstyle = document.createElement('style');
rainstyle.type = 'text/css';
rainstyle.innerHTML = `
* {
padding: 0;
margin: 0;
}
.raincontent {
width: 100%;
height: 100%;
}
#rainBox {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
pointer-events: none;
}
.rain {
position: absolute;
width: 2px;
height: 50px;
background: linear-gradient(rgba(255,255,255,.3),rgba(255,255,255,.6));
}
`;
document.head.appendChild(rainstyle);

// 创建结构
const raincontent = document.createElement('div');
raincontent.classList.add('raincontent');
const rainBox = document.createElement('div');
rainBox.id = 'rainBox';
raincontent.appendChild(rainBox);
document.body.appendChild(raincontent);

// 获取rainBox元素
const box = document.getElementById('rainBox');

// 定义box的高度和宽度
let boxHeight = box.clientHeight;
let boxWidth = box.clientWidth;

// 窗口加载时更新box的高度和宽度
window.onload = function () {
boxHeight = box.clientHeight;
boxWidth = box.clientWidth;
};

// 窗口大小变化时更新box的高度和宽度
window.onresize = function () {
boxHeight = box.clientHeight;
boxWidth = box.clientWidth;
};

// 每隔50毫秒添加一个新的雨点
setInterval(() => {
// 创建一个新的div元素表示雨点
const rain = document.createElement('div');

// 添加类名'rain'到雨点元素
rain.classList.add('rain');

// 设置雨点的初始位置
rain.style.top = '0px';
rain.style.left = Math.random() * boxWidth + 'px';

// 设置雨点的随机透明度
rain.style.opacity = Math.random();

// 将雨点元素添加到rainBox中
box.appendChild(rain);

// 每隔20毫秒更新雨点的位置,使其下落
let race = 1;
const timer = setInterval(() => {
// 如果雨点到达底部,则清除定时器并移除雨点
if (parseInt(rain.style.top) > boxHeight) {
clearInterval(timer);
box.removeChild(rain);
}
// 增加雨点的下落速度
race++;
rain.style.top = parseInt(rain.style.top) + race + 'px';
}, 20);
}, 50);
69 changes: 69 additions & 0 deletions static/assets/yifantheme_index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const style = document.createElement("style");
style.innerHTML = `
.blogTitle {
display: unset;
}
#header {
height: 300px;
}
#header h1 {
position: absolute;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-direction: column;
align-items: center;
}
.avatar {
width: 200px;
height: 200px;
}
#header h1 a {
margin-top: 30px;
font-family: fantasy;
margin-left: unset;
}
html {
background: url('https://img.liyifan.xyz/file/a2262c314f6a8bd592eba.jpg') no-repeat center center fixed;
background-size: cover;
}
body {
margin: 30px auto;
padding: 20px;
font-size: 16px;
font-family: sans-serif;
line-height: 1.25;
background: rgba(255, 255, 255, 0.8); /* 白色背景,透明度80% */
border-radius: 10px; /* 圆角边框 */
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); /* 添加阴影 */
overflow: auto;
}
.SideNav {
background: rgba(255, 255, 255, 0.6); /* 白色背景,透明度60% */
border-radius: 10px; /* 圆角边框 */
min-width: unset;
}
.SideNav-item:hover {
background-color: #c3e4e3;
border-radius: 10px;
transform: scale(1.02);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}
.SideNav-item {
transition: 0.5s;
}
.pagination a:hover, .pagination a:focus, .pagination span:hover, .pagination span:focus, .pagination em:hover, .pagination em:focus {
border-color: rebeccapurple;
}
`;
document.head.appendChild(style);
Binary file added static/avatar.webp
Binary file not shown.
Binary file added static/background.webp
Binary file not shown.
5 changes: 5 additions & 0 deletions static/lib/jquery.min.js

Large diffs are not rendered by default.

0 comments on commit 4603439

Please sign in to comment.