added 工具栏
This commit is contained in:
1 parent
1cb7d16475
commit
e26f61bdfc
8 files changed
+295
-240
No files matched your search
@@ -2857,51 +2857,80 @@ img[atk-emoticon] {
|
||||
/* GenericOutput */ [data-theme="dark"] .chroma .go { color:#44475a }
|
||||
/* GenericPrompt */ [data-theme="dark"] .chroma .gp { }
|
||||
|
||||
/* Back to Top Button */
|
||||
#back-to-top {
|
||||
/* Floating Tools */
|
||||
.floating-tools {
|
||||
position: fixed;
|
||||
bottom: 30px;
|
||||
right: 30px;
|
||||
z-index: 2147483647;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.floating-tools a {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background-color: var(--bankuai-color);
|
||||
color: var(--text-content-color);
|
||||
background-color: rgba(255, 255, 255, 0.6);
|
||||
color: #333;
|
||||
border-radius: 50%;
|
||||
text-align: center;
|
||||
line-height: 40px;
|
||||
font-size: 24px;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
||||
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
|
||||
cursor: pointer;
|
||||
z-index: 2147483647;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity 0.3s, visibility 0.3s, background-color 0.3s, transform 0.3s;
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-decoration: none;
|
||||
transition: all 0.3s;
|
||||
backdrop-filter: blur(10px) saturate(180%);
|
||||
-webkit-backdrop-filter: blur(10px) saturate(180%);
|
||||
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.floating-tools a:hover {
|
||||
background-color: rgba(255, 255, 255, 0.85);
|
||||
color: var(--erji-color);
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 6px 15px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .floating-tools a {
|
||||
background-color: rgba(30, 30, 30, 0.6);
|
||||
color: #e5e7eb;
|
||||
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .floating-tools a:hover {
|
||||
background-color: rgba(60, 60, 60, 0.8);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Back to Top Button */
|
||||
#back-to-top {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
height: 0;
|
||||
width: 0;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
transform: scale(0);
|
||||
}
|
||||
|
||||
#back-to-top.show {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
margin-top: 0;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
#back-to-top:hover {
|
||||
background-color: var(--erji-color);
|
||||
color: #fff;
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
|
||||
[data-theme="dark"] #back-to-top {
|
||||
background-color: var(--bankuai-dark-color);
|
||||
color: var(--text-content-dark-color);
|
||||
box-shadow: 0 2px 5px rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
[data-theme="dark"] #back-to-top:hover {
|
||||
background-color: #444;
|
||||
color: #fff;
|
||||
#back-to-top.show:hover {
|
||||
transform: scale(1) translateY(-3px);
|
||||
}
|
||||
/* GenericStrong */ [data-theme="dark"] .chroma .gs { }
|
||||
/* GenericSubheading */ [data-theme="dark"] .chroma .gu { font-weight:bold }
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Message.js v1.0.0
|
||||
* https://github.com/snwjas/Message.js
|
||||
*
|
||||
* Copyright 2021 snwjas
|
||||
* Released under the MIT license
|
||||
*/
|
||||
.qmsg-wrapper{position:fixed;top:20px;left:50%;z-index:99999;transform:translateX(-50%);display:flex;flex-direction:column;align-items:center;pointer-events:none}.qmsg{position:relative;padding:10px 16px;border-radius:4px;box-shadow:0 4px 12px rgba(0,0,0,.15);background:#fff;margin-bottom:10px;display:flex;align-items:center;pointer-events:all;animation:qmsg-in .3s ease-out forwards;transform-origin:top center;opacity:0}.qmsg.qmsg-closing{animation:qmsg-out .3s ease-in forwards}.qmsg-icon{margin-right:8px;display:flex;align-items:center;font-size:16px}.qmsg-content{font-size:14px;color:#606266;line-height:1.4}.qmsg-close{margin-left:12px;cursor:pointer;color:#c0c4cc;font-size:14px;transition:color .2s}.qmsg-close:hover{color:#909399}.qmsg-info .qmsg-icon{color:#909399}.qmsg-success .qmsg-icon{color:#67c23a}.qmsg-warning .qmsg-icon{color:#e6a23c}.qmsg-error .qmsg-icon{color:#f56c6c}.qmsg-loading .qmsg-icon{color:#409eff;animation:qmsg-spin 2s linear infinite}@keyframes qmsg-in{0%{opacity:0;transform:translateY(-20px) scale(.8)}100%{opacity:1;transform:translateY(0) scale(1)}}@keyframes qmsg-out{0%{opacity:1;transform:translateY(0) scale(1)}100%{opacity:0;transform:translateY(-20px) scale(.8)}}@keyframes qmsg-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}
|
||||
/* SVG Icons */
|
||||
.qmsg-icon svg{width:16px;height:16px;fill:currentColor}
|
||||
+208
-208
@@ -67,13 +67,17 @@ $('#libabys').eq(1).attr("style", "margin-left: -5px");
|
||||
$('.itp-index:odd').attr("style", "float: right;width:48%;");
|
||||
|
||||
//文章图片懒加载
|
||||
lazyLoadInit({
|
||||
// coverColor: "white",
|
||||
// coverDiv: "<div style='display: flex; justify-content: center; align-items: center; height: 200px; color: #000000;'><span>优世界·一个记录生活点滴的小站</span></div>",
|
||||
offsetBottom: 800,
|
||||
offsetTopm: 800,
|
||||
showTime: 1100
|
||||
});
|
||||
if (typeof lazyLoadInit === 'function') {
|
||||
lazyLoadInit({
|
||||
// coverColor: "white",
|
||||
// coverDiv: "<div style='display: flex; justify-content: center; align-items: center; height: 200px; color: #000000;'><span>优世界·一个记录生活点滴的小站</span></div>",
|
||||
offsetBottom: 800,
|
||||
offsetTopm: 800,
|
||||
showTime: 1100
|
||||
});
|
||||
} else {
|
||||
console.warn('lazyLoadInit is not defined');
|
||||
}
|
||||
|
||||
async function loadBarrager() {
|
||||
try {
|
||||
@@ -101,223 +105,123 @@ function initArtalkAndGetComments() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Artalk.init({
|
||||
el: '#Comments', // 绑定元素的 Selector
|
||||
server: window.siteConfig.artalk.server, // 后端地址
|
||||
site: window.siteConfig.artalk.site, // 你的站点名
|
||||
flatMode: true,
|
||||
emoticons: window.siteConfig.artalk.emoticons
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 异步创建弹幕
|
||||
// 从 Artalk 评论数据生成弹幕
|
||||
async function createBarragerFromArtalk(commentsData) {
|
||||
const looperTime = 1000; // 每条弹幕的发送间隔,单位毫秒
|
||||
|
||||
// 1. 处理评论数据(扁平化、乱序)
|
||||
const flattenedComments = flattenComments(commentsData);
|
||||
shuffleArray(flattenedComments); // 随机打乱评论顺序
|
||||
const selectedComments = flattenedComments; // 使用所有评论
|
||||
|
||||
// 2. 构建弹幕列表
|
||||
let barrageList = selectedComments.map(comment => ({
|
||||
type: 'comment',
|
||||
content: stripHTML(comment.content_marked) || 'No comment',
|
||||
// 修复头像模糊:请求 200px 的图片 (s=200)
|
||||
headImg: window.siteConfig.artalk.gravatar + comment.email_encrypted + "?s=200" || 'static/default-avatar.png',
|
||||
href: comment.link || '#',
|
||||
speed: 35
|
||||
}));
|
||||
// 确保弹幕容器存在
|
||||
const barragerContainer = document.querySelector('.barrager');
|
||||
if (!barragerContainer) {
|
||||
console.warn('未找到弹幕容器 .barrager');
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 尝试获取在线一言并插入
|
||||
if (window.siteConfig.barrage && window.siteConfig.barrage.enableHitokoto) {
|
||||
try {
|
||||
const hitokoto = await fetchHitokoto();
|
||||
if (hitokoto) {
|
||||
const insertIndex = Math.floor(Math.random() * (barrageList.length + 1));
|
||||
barrageList.splice(insertIndex, 0, {
|
||||
type: 'hitokoto',
|
||||
content: `『一言』${hitokoto}`,
|
||||
headImg: window.siteConfig.author.avatar,
|
||||
href: 'https://hitokoto.cn',
|
||||
speed: 35
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取一言失败:', e);
|
||||
// 1. 过滤和处理评论数据 (只保留昵称和内容)
|
||||
const barrageList = commentsData.map(comment => {
|
||||
// 简单清理 HTML 标签,保留纯文本 (可选)
|
||||
const contentText = comment.content.replace(/<[^>]+>/g, "").substring(0, 50); // 限制长度
|
||||
return {
|
||||
info: contentText, // 弹幕内容
|
||||
href: '#', // 链接 (可选,点击弹幕跳转)
|
||||
speed: 10 + Math.random() * 5, // 随机速度
|
||||
color: '#fff', // 字体颜色 (白色)
|
||||
old_ie_color: '#000000', // 旧版 IE 颜色
|
||||
};
|
||||
}).filter(item => item.info.trim() !== ""); // 过滤空评论
|
||||
|
||||
// 如果没有评论,则不显示弹幕
|
||||
if (barrageList.length === 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化弹幕插件
|
||||
let barrage = new Barrage.default({
|
||||
el: 'body',
|
||||
backColor: "#000000b5",
|
||||
fontSize: "13px", // 字体稍微改小一点点以适配小头像
|
||||
isLeft: true,
|
||||
speed: 0,
|
||||
height: "30px" // 整体高度稍微减小
|
||||
});
|
||||
|
||||
const totalItems = barrageList.length;
|
||||
let currentIndex = 0;
|
||||
|
||||
if (totalItems !== 0) {
|
||||
while (currentIndex < totalItems) {
|
||||
const item = barrageList[currentIndex];
|
||||
|
||||
// 发送弹幕
|
||||
barrage.start(item.content, {
|
||||
speed: item.speed,
|
||||
headImg: item.headImg,
|
||||
href: item.href
|
||||
});
|
||||
|
||||
currentIndex++;
|
||||
await delay(looperTime); // 等待指定的时间再发送下一条弹幕
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 数组乱序算法 (Fisher-Yates Shuffle)
|
||||
function shuffleArray(array) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
}
|
||||
|
||||
// 获取一言
|
||||
async function fetchHitokoto() {
|
||||
const url = window.siteConfig.barrage.hitokotoUrl || 'https://v1.hitokoto.cn?c=a&c=b&c=c&c=d&c=i';
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
return data.hitokoto;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 延迟函数,返回一个 Promise,用于等待指定的毫秒数
|
||||
function delay(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
// 去除 HTML 标签的函数
|
||||
function stripHTML(html) {
|
||||
return html.replace(/<\/?[^>]+(>|$)/g, "");
|
||||
}
|
||||
|
||||
// 展平评论数据结构的函数
|
||||
function flattenComments(comments) {
|
||||
let result = [];
|
||||
comments.forEach(function (comment) {
|
||||
result.push(comment);
|
||||
if (comment.children && comment.children.length > 0) {
|
||||
result = result.concat(flattenComments(comment.children));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// 调用异步的弹幕加载函数
|
||||
if (document.querySelector("#Comments") && !isMobile()) {
|
||||
loadBarrager()
|
||||
}
|
||||
|
||||
function getCurrentTheme() {
|
||||
var theme = document.documentElement.getAttribute('data-theme');
|
||||
if (!theme) {
|
||||
theme = 'light';
|
||||
}
|
||||
return theme;
|
||||
}
|
||||
|
||||
function applyTheme(theme) {
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
try {
|
||||
localStorage.setItem('theme', theme);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function updateThemeToggle(theme) {
|
||||
var button = document.getElementById('theme-toggle');
|
||||
if (theme === 'dark') {
|
||||
if (button) {
|
||||
button.textContent = '日间';
|
||||
}
|
||||
} else {
|
||||
if (button) {
|
||||
button.textContent = '夜间';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
var current = getCurrentTheme();
|
||||
var next = current === 'dark' ? 'light' : 'dark';
|
||||
applyTheme(next);
|
||||
updateThemeToggle(next);
|
||||
if (window.Artalk && window.Artalk.get) {
|
||||
try {
|
||||
var ctx = Artalk.get('#Comments');
|
||||
if (ctx && ctx.setDarkMode) {
|
||||
ctx.setDarkMode(next === 'dark');
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var theme = getCurrentTheme();
|
||||
updateThemeToggle(theme);
|
||||
var button = document.getElementById('theme-toggle');
|
||||
if (button) {
|
||||
button.addEventListener('click', toggleTheme);
|
||||
}
|
||||
var avatarWrapper = document.querySelector('.head_author_img');
|
||||
var avatarTip = document.querySelector('.avatar-theme-tip');
|
||||
if (avatarWrapper) {
|
||||
avatarWrapper.style.cursor = 'pointer';
|
||||
avatarWrapper.addEventListener('click', toggleTheme);
|
||||
}
|
||||
if (avatarTip) {
|
||||
avatarTip.classList.add('is-visible');
|
||||
var hideOnce = function () {
|
||||
avatarTip.classList.add('is-hidden');
|
||||
// 2. 初始化 jQuery.barrager (如果尚未初始化)
|
||||
// 注意:这里假设 jquery.barrager.js 已经加载并挂载到 jQuery 对象上
|
||||
// 由于 barrager 插件通常是直接操作 DOM,我们可能需要循环添加
|
||||
|
||||
// 简单的循环发送弹幕示例 (每隔一段时间发送一条)
|
||||
let index = 0;
|
||||
const sendBarrage = () => {
|
||||
if (index >= barrageList.length) {
|
||||
index = 0; // 循环播放
|
||||
}
|
||||
const item = barrageList[index];
|
||||
// 使用 jQuery 选择器调用 barrager
|
||||
$('body').barrager(item);
|
||||
index++;
|
||||
};
|
||||
setTimeout(hideOnce, 9000);
|
||||
if (avatarWrapper) {
|
||||
avatarWrapper.addEventListener('click', hideOnce);
|
||||
|
||||
// 每 2 秒发送一条弹幕
|
||||
setInterval(sendBarrage, 2000);
|
||||
}
|
||||
|
||||
|
||||
async function fetchHitokoto() {
|
||||
try {
|
||||
const response = await fetch('https://v1.hitokoto.cn/?c=d&c=i'); // 获取句子
|
||||
const data = await response.json();
|
||||
return data.hitokoto;
|
||||
} catch (error) {
|
||||
console.error('获取一言失败:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 代码复制功能
|
||||
// 代码块复制功能
|
||||
function initCodeCopy() {
|
||||
var codeBlocks = document.querySelectorAll('.highlight');
|
||||
codeBlocks.forEach(function(block) {
|
||||
if (block.querySelector('.copy-code-btn')) return;
|
||||
const codeBlocks = document.querySelectorAll('.post-content pre code');
|
||||
|
||||
codeBlocks.forEach(codeBlock => {
|
||||
// 检查是否已经添加了复制按钮,避免重复添加
|
||||
if (codeBlock.parentNode.querySelector('.copy-code-btn')) return;
|
||||
|
||||
var btn = document.createElement('button');
|
||||
btn.className = 'copy-code-btn';
|
||||
btn.innerHTML = '<i class="ri-file-copy-line"></i>';
|
||||
block.appendChild(btn);
|
||||
const pre = codeBlock.parentNode;
|
||||
pre.style.position = 'relative';
|
||||
|
||||
btn.addEventListener('click', function() {
|
||||
var code = block.querySelector('code').innerText;
|
||||
navigator.clipboard.writeText(code).then(function() {
|
||||
btn.innerHTML = '<i class="ri-check-line"></i>';
|
||||
setTimeout(function() {
|
||||
btn.innerHTML = '<i class="ri-file-copy-line"></i>';
|
||||
const copyBtn = document.createElement('button');
|
||||
copyBtn.className = 'copy-code-btn';
|
||||
copyBtn.innerHTML = '<i class="fa fa-copy"></i>'; // 使用 FontAwesome 图标
|
||||
copyBtn.title = '复制代码';
|
||||
|
||||
// 样式 (建议放到 CSS 文件中)
|
||||
copyBtn.style.position = 'absolute';
|
||||
copyBtn.style.top = '5px';
|
||||
copyBtn.style.right = '5px';
|
||||
copyBtn.style.border = 'none';
|
||||
copyBtn.style.background = 'transparent';
|
||||
copyBtn.style.color = '#999';
|
||||
copyBtn.style.cursor = 'pointer';
|
||||
copyBtn.style.padding = '5px';
|
||||
copyBtn.style.borderRadius = '4px';
|
||||
copyBtn.style.transition = 'all 0.3s';
|
||||
|
||||
// Hover 效果
|
||||
copyBtn.addEventListener('mouseenter', () => {
|
||||
copyBtn.style.color = '#333';
|
||||
copyBtn.style.background = 'rgba(0,0,0,0.1)';
|
||||
});
|
||||
copyBtn.addEventListener('mouseleave', () => {
|
||||
copyBtn.style.color = '#999';
|
||||
copyBtn.style.background = 'transparent';
|
||||
});
|
||||
|
||||
copyBtn.addEventListener('click', () => {
|
||||
const code = codeBlock.innerText;
|
||||
navigator.clipboard.writeText(code).then(() => {
|
||||
copyBtn.innerHTML = '<i class="fa fa-check"></i>';
|
||||
setTimeout(() => {
|
||||
copyBtn.innerHTML = '<i class="fa fa-copy"></i>';
|
||||
}, 2000);
|
||||
}).catch(function(err) {
|
||||
console.error('Failed to copy: ', err);
|
||||
btn.innerText = 'Error';
|
||||
|
||||
Qmsg.success("代码复制成功");
|
||||
}).catch(err => {
|
||||
console.error('复制失败:', err);
|
||||
copyBtn.innerHTML = '<i class="fa fa-times"></i>';
|
||||
Qmsg.error("复制失败");
|
||||
});
|
||||
});
|
||||
|
||||
pre.appendChild(copyBtn);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -371,3 +275,99 @@ function typeWriter(element, text, speed = 100) {
|
||||
|
||||
type();
|
||||
}
|
||||
|
||||
// 友链信息一键复制
|
||||
function copySzhContent() {
|
||||
var szhElement = document.getElementById('szh');
|
||||
if (szhElement) {
|
||||
var textToCopy = szhElement.innerText;
|
||||
navigator.clipboard.writeText(textToCopy).then(function() {
|
||||
Qmsg.success("复制成功");
|
||||
}).catch(function(err) {
|
||||
console.error('Could not copy text: ', err);
|
||||
Qmsg.error("复制失败");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Theme Toggle Logic
|
||||
function toggleTheme() {
|
||||
const currentTheme = document.documentElement.getAttribute('data-theme');
|
||||
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
||||
document.documentElement.setAttribute('data-theme', newTheme);
|
||||
localStorage.setItem('theme', newTheme);
|
||||
|
||||
// Notify Artalk if present
|
||||
if (window.Artalk) {
|
||||
Artalk.setDarkMode(newTheme === 'dark');
|
||||
}
|
||||
}
|
||||
|
||||
// Update Floating Tools Visibility based on current page
|
||||
function updateFloatingToolsVisibility() {
|
||||
const tools = document.querySelector('.floating-tools');
|
||||
if (!tools) return;
|
||||
|
||||
// Hide on Homepage
|
||||
const isHome = window.location.pathname === '/' || window.location.pathname === '/index.html';
|
||||
if (isHome) {
|
||||
tools.style.display = 'none';
|
||||
} else {
|
||||
tools.style.display = 'flex';
|
||||
}
|
||||
|
||||
// Hide Comment button if no comments section
|
||||
const commentBtn = document.getElementById('to-comments');
|
||||
if (commentBtn) {
|
||||
const commentsSection = document.getElementById('Comments');
|
||||
commentBtn.style.display = commentsSection ? 'flex' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Floating Tools Initialization
|
||||
function initFloatingTools() {
|
||||
// Initial visibility check
|
||||
updateFloatingToolsVisibility();
|
||||
|
||||
// Prevent multiple event bindings
|
||||
if (window.floatingToolsInitialized) return;
|
||||
window.floatingToolsInitialized = true;
|
||||
|
||||
// Use Event Delegation for robust handling
|
||||
document.addEventListener('click', function(e) {
|
||||
// Theme Toggle
|
||||
const toggleBtn = e.target.closest('#theme-toggle');
|
||||
if (toggleBtn) {
|
||||
e.preventDefault();
|
||||
toggleTheme();
|
||||
}
|
||||
|
||||
// Jump to Comments
|
||||
const commentBtn = e.target.closest('#to-comments');
|
||||
if (commentBtn) {
|
||||
e.preventDefault();
|
||||
const commentsSection = document.getElementById('Comments');
|
||||
if (commentsSection) {
|
||||
commentsSection.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Theme Toggle (Avatar)
|
||||
const avatar = document.querySelector('.head_author_img');
|
||||
if (avatar) {
|
||||
avatar.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
toggleTheme();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Listen for PJAX complete to update visibility
|
||||
document.addEventListener('pjax:complete', function() {
|
||||
updateFloatingToolsVisibility();
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
initFloatingTools();
|
||||
});
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
/*
|
||||
* Message.js v1.0.0
|
||||
* https://github.com/snwjas/Message.js
|
||||
*/
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Qmsg=t()}(this,function(){"use strict";var e={timeout:2500,showClose:!1,autoClose:!0,content:"",onClose:null,html:!1,maxNums:5};function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var o={info:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"/><path d="M464 336a48 48 0 1 0 96 0 48 48 0 1 0-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"/></svg>',success:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 0 1-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"/></svg>',warning:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"/></svg>',error:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.6 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 0 1-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.6-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"/></svg>',loading:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"/><path d="M512 140c-205.4 0-372 166.6-372 372s166.6 372 372 372 372-166.6 372-372-166.6-372-372-372z" opacity=".3"/><path d="M512 140c205.4 0 372 166.6 372 372h-70c0-166.8-135.2-302-302-302V140z"/></svg>',close:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"/></svg>'},i=function(){function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),this.settings=Object.assign({},this.defaults,e),this.id="qmsg-"+Math.random().toString(36).substr(2,9),this.timer=null,this.render()}var s,a,c;return s=i,c=[{key:"config",value:function(t){e=Object.assign({},e,t)}},{key:"info",value:function(e,t){return new i(Object.assign({content:e,type:"info"},t))}},{key:"success",value:function(e,t){return new i(Object.assign({content:e,type:"success"},t))}},{key:"warning",value:function(e,t){return new i(Object.assign({content:e,type:"warning"},t))}},{key:"error",value:function(e,t){return new i(Object.assign({content:e,type:"error"},t))}},{key:"loading",value:function(e,t){return new i(Object.assign({content:e,type:"loading",autoClose:!1},t))}},{key:"closeAll",value:function(){var e=document.querySelectorAll(".qmsg");e.forEach(function(e){e.remove()})}}],(a=[{key:"defaults",get:function(){return window.QMSG_GLOBALS&&window.QMSG_GLOBALS.DEFAULTS?Object.assign({},e,window.QMSG_GLOBALS.DEFAULTS):e}},{key:"render",value:function(){var e=this,t=document.querySelector(".qmsg-wrapper");t||((t=document.createElement("div")).className="qmsg-wrapper",document.body.appendChild(t));var n=document.createElement("div");n.className="qmsg qmsg-"+this.settings.type,n.id=this.id;var s="";this.settings.showClose&&(s='<div class="qmsg-close">'+o.close+"</div>");var a=this.settings.content;this.settings.html||(a=a.replace(/</g,"<").replace(/>/g,">")),n.innerHTML='<div class="qmsg-icon">'+o[this.settings.type]+'</div><div class="qmsg-content">'+a+"</div>"+s,t.appendChild(n),this.settings.showClose&&n.querySelector(".qmsg-close").addEventListener("click",function(){e.close()}),this.settings.autoClose&&(this.timer=setTimeout(function(){e.close()},this.settings.timeout)),this.cheLine truncated
|
||||
@@ -7,7 +7,7 @@ function checkParent(element, classNames) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var excludedClasses = ['talks_comments','tiaozhuan-button']; // 添加需要排除的a标签类名class
|
||||
var excludedClasses = ['talks_comments','tiaozhuan-button', 'floating-tools']; // 添加需要排除的a标签类名class
|
||||
window.addEventListener('load', (event) => {
|
||||
document.body.addEventListener('click', function(e) {
|
||||
let target = e.target;
|
||||
@@ -16,6 +16,7 @@ function checkParent(element, classNames) {
|
||||
}
|
||||
if (target && target.nodeName === 'A' &&
|
||||
!checkParent(target, excludedClasses) &&
|
||||
!target.href.startsWith('javascript:') &&
|
||||
!target.href.includes('usj.cc') &&
|
||||
!target.href.includes('douban.com') &&
|
||||
!target.href.includes('bilibili.com') &&
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div id="data-pid" style="display:none;">{{ .RelPermalink }}</div>
|
||||
<div class="post-content" itemprop="articleBody" uk-scrollspy="target: > #szh; cls: uk-animation-slide-bottom-small; delay: 0">
|
||||
{{ .Content }}
|
||||
<div id="szh">
|
||||
<div id="szh" onclick="copySzhContent()" style="cursor: pointer;" title="点击复制">
|
||||
- 名称:{{ .Site.Params.message_info.name | default .Site.Params.artalk.site }}<br>
|
||||
- 简介:{{ .Site.Params.message_info.description | default .Site.Params.author.description }}<br>
|
||||
- 链接:{{ .Site.Params.message_info.url | default .Site.BaseURL }}<br>
|
||||
|
||||
@@ -13,9 +13,17 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a href="#" id="back-to-top" title="返回顶部">
|
||||
<i class="ri-arrow-up-s-line"></i>
|
||||
</a>
|
||||
<div class="floating-tools">
|
||||
<a href="javascript:;" id="theme-toggle" title="切换主题">
|
||||
<i class="ri-palette-line"></i>
|
||||
</a>
|
||||
<a href="#Comments" id="to-comments" title="跳转评论">
|
||||
<i class="ri-chat-2-line"></i>
|
||||
</a>
|
||||
<a href="#" id="back-to-top" title="返回顶部">
|
||||
<i class="ri-arrow-up-line"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{ $iconfont := resources.Get "js/iconfont.js" }}
|
||||
{{ $lightgallery := resources.Get "js/lightgallery.umd.min.js" }}
|
||||
{{ $uikit := resources.Get "js/uikit.min.js" }}
|
||||
@@ -25,10 +33,11 @@
|
||||
{{ $main := resources.Get "js/main.js" }}
|
||||
{{ $mypjax := resources.Get "js/mypjax.js" }}
|
||||
{{ $nprogress := resources.Get "js/nprogress.js" }}
|
||||
{{ $message := resources.Get "js/message.min.js" }}
|
||||
{{ $echarts := resources.Get "js/echarts.min.js" }}
|
||||
{{ $tiaozhuan := resources.Get "js/tiaozhuan.js" }}
|
||||
|
||||
{{ $scripts := slice $iconfont $lightgallery $uikit $easylazyload $viewimage $artalk $main $mypjax $nprogress $echarts $tiaozhuan | resources.Concat "js/bundle.js" | resources.Minify | resources.Fingerprint }}
|
||||
{{ $scripts := slice $iconfont $lightgallery $uikit $easylazyload $viewimage $artalk $main $mypjax $nprogress $message $echarts $tiaozhuan | resources.Concat "js/bundle.js" | resources.Minify | resources.Fingerprint }}
|
||||
<script src="{{ $scripts.RelPermalink }}"></script>
|
||||
<script async src="/js/bsz.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -84,9 +84,10 @@
|
||||
{{ $uikit := resources.Get "css/uikit.min.css" }}
|
||||
{{ $nprogress := resources.Get "css/nprogress.min.css" }}
|
||||
{{ $artalk := resources.Get "css/Artalk.css" }}
|
||||
{{ $message := resources.Get "css/message.min.css" }}
|
||||
{{ $main := resources.Get "css/main.css" }}
|
||||
|
||||
{{ $style := slice $normalize $remixicon $uikit $nprogress $artalk $main | resources.Concat "css/style.css" | resources.Minify | resources.Fingerprint }}
|
||||
{{ $style := slice $normalize $remixicon $uikit $nprogress $artalk $message $main | resources.Concat "css/style.css" | resources.Minify | resources.Fingerprint }}
|
||||
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
|
||||
|
||||
{{- if and .Site.Params.style.enableBackgroundImage .Site.Params.style.backgroundImageUrl -}}
|
||||
|
||||
Reference in new issue
Block a user