首页
关于
留言
统计
更多
友联
壁纸
图床
Search
1
下次见面又是什么时候呢
768 阅读
2
joe主题优化记录(更新中)
446 阅读
3
小程序npn构建
434 阅读
4
在线网页体重记录表
422 阅读
5
和他
387 阅读
Search
标签搜索
日常
joe
js
php
window
编程知识
小程序
html
Blank
累计撰写
22
篇文章
累计收到
9
条评论
首页
栏目
日常记录
微言微语
风景分享
生活知识
电脑知识
编程知识
办公技巧
node
最新文章
页面
关于
留言
统计
友联
壁纸
图床
搜索到
22
篇与
Blank
的结果
在线水印生成源码
前言演示网址:https://uurr.cn/myfile/page/watermark/支持文字水印和图片水印,支持自定义水印大小,颜色,旋转方向,间距,透明度效果代码<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>水印生成器</title> <style> body { font-family: Arial, sans-serif; background-color: #f9f9f9; color: #333; display: flex; padding: 50px; margin: 0; } .image-container { flex: 1; display: flex; justify-content: center; align-items: center; border: 1px solid #ccc; background-color: white; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); margin-right: 50px; } .settings-container { flex: 0 0 350px; /* 允许放大,基础宽度为310px */ display: flex; flex-direction: column; margin-right: 50px; } h1 { margin-bottom: 20px; font-size: 24px; text-align: center; } input[type="file"], input[type="text"], input[type="color"], input[type="range"], button { padding: 6px; margin: 6px 0; border: 1px solid #ccc; border-radius: 5px; width: 50%; font-size: 16px; } input[type="file"], input[type="text"], input[type="color"], input[type="range"], button { padding: 6px; margin: 6px 0; border: 1px solid #ccc; border-radius: 5px; width: 60%; font-size: 16px; } button { background-color: #007bff; color: white; border: none; cursor: pointer; transition: background-color 0.3s; width: 100%; } button:hover { background-color: #0056b3; } canvas { max-width: 90%; height: auto; } .slider-label { margin-top:10px ; display: flex; justify-content: space-between; align-items: center; } </style> </head> <body> <div class="image-container"> <canvas id="canvas"></canvas> </div> <div class="settings-container"> <h1>在线水印生成器</h1> <div class="slider-label"> <label>选择图片</label> <input type="file" id="imageUpload" accept="image/*" placeholder="上传主图"> </div> <div class="slider-label"> <label>图片水印</label> <input type="text" id="watermarkText" placeholder="输入水印文字" value="输入水印文字"> </div> <div class="slider-label"> <span>图片水印</span> <input type="file" id="watermarkImageUpload" accept="image/*" placeholder="上传水印图片"> </div> <div class="slider-label"> <label for="watermarkColor">文字颜色</label> <input type="color" id="watermarkColor" value="#ffffff"> </div> <div class="slider-label"> <label for="watermarkSize">文字大小</label> <input type="range" id="watermarkSize" min="1" max="100" value="20"> <span id="watermarkSizeValue">20</span> </div> <div class="slider-label"> <label for="spacing">文字间距</label> <input type="range" id="spacing" min="90" max="300" value="100"> <span id="spacingValue">100</span> </div> <div class="slider-label"> <label for="rotation">水印角度</label> <input type="range" id="rotation" min="0" max="360" value="310"> <span id="rotationValue">310</span> </div> <div class="slider-label"> <label for="opacity">水印透明</label> <input type="range" id="opacity" min="0" max="100" value="50"> <span id="opacityValue">50</span> </div> <button class="save" id="saveButton">保存图片</button> </div> <script> const imageUpload = document.getElementById('imageUpload'); const watermarkImageUpload = document.getElementById('watermarkImageUpload'); const watermarkText = document.getElementById('watermarkText'); const watermarkColor = document.getElementById('watermarkColor'); const watermarkSize = document.getElementById('watermarkSize'); const spacing = document.getElementById('spacing'); const rotation = document.getElementById('rotation'); const opacity = document.getElementById('opacity'); const saveButton = document.getElementById('saveButton'); const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); let mainImage, watermarkImage; // 初始化数值显示 const watermarkSizeValue = document.getElementById('watermarkSizeValue'); const spacingValue = document.getElementById('spacingValue'); const rotationValue = document.getElementById('rotationValue'); const opacityValue = document.getElementById('opacityValue'); imageUpload.addEventListener('change', handleImageUpload); watermarkImageUpload.addEventListener('change', handleWatermarkImageUpload); watermarkText.addEventListener('input', generateWatermarkedImage); watermarkColor.addEventListener('input', generateWatermarkedImage); watermarkSize.addEventListener('input', () => { watermarkSizeValue.textContent = watermarkSize.value; // 更新文字大小数值 generateWatermarkedImage(); }); spacing.addEventListener('input', () => { spacingValue.textContent = spacing.value; // 更新间距数值 generateWatermarkedImage(); }); rotation.addEventListener('input', () => { rotationValue.textContent = rotation.value; // 更新旋转角度数值 generateWatermarkedImage(); }); opacity.addEventListener('input', () => { opacityValue.textContent = opacity.value; // 更新透明度数值 generateWatermarkedImage(); }); saveButton.addEventListener('click', saveImage); function handleImageUpload(event) { const file = event.target.files[0]; if (file) { const reader = new FileReader(); reader.onload = function (e) { mainImage = new Image(); mainImage.src = e.target.result; mainImage.onload = () => { canvas.width = mainImage.width; canvas.height = mainImage.height; generateWatermarkedImage(); } } reader.readAsDataURL(file); } } function handleWatermarkImageUpload(event) { const file = event.target.files[0]; if (file) { const reader = new FileReader(); reader.onload = function (e) { watermarkImage = new Image(); watermarkImage.src = e.target.result; watermarkImage.onload = generateWatermarkedImage; // 当图片加载完成时生成水印 } reader.readAsDataURL(file); } } function generateWatermarkedImage() { if (!mainImage) return; ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.drawImage(mainImage, 0, 0); const size = parseInt(watermarkSize.value); const spacingValue = parseInt(spacing.value); const color = watermarkColor.value; const angle = parseInt(rotation.value) * (Math.PI / 180); // 角度转换为弧度 const alpha = parseInt(opacity.value) / 100; // 透明度转换为小数 const rows = Math.ceil(canvas.height / (size + spacingValue)); const cols = Math.ceil(canvas.width / (size + spacingValue)); for (let i = 0; i < rows; i++) { for (let j = 0; j < cols; j++) { const x = j * (size + spacingValue); const y = i * (size + spacingValue) + size; // +size 确保文字不会被遮挡 ctx.save(); // 保存当前状态 ctx.translate(x + size / 2, y - size / 2); // 移动到水印中心 ctx.rotate(angle); // 旋转 if (watermarkText.value) { ctx.font = `${size}px Arial`; ctx.fillStyle = color; ctx.globalAlpha = alpha; // 设置透明度 ctx.fillText(watermarkText.value, -ctx.measureText(watermarkText.value).width / 2, 0); // 绘制文字,中心对齐 } if (watermarkImage) { ctx.globalAlpha = alpha; // 设置透明度 ctx.drawImage(watermarkImage, -size / 2, -size / 2, size, size); // 假设图片水印也是方形 } ctx.restore(); // 恢复状态 } } ctx.globalAlpha = 1; // 重置透明度 } function saveImage() { const link = document.createElement('a'); link.download = 'watermarked-image.png'; link.href = canvas.toDataURL('image/png'); link.click(); } </script> </body> </html>代码详解HTML结构: 标签:为文件输入框提供描述。在用户点击标签时,可以直接触发文件选择窗口。 <input type="file"> :创建一个文件上传输入框,并设置accept属性,限制用户选择的文件类型为图片。 标签:用于显示用户当前选择的文件名,初始提示文本为“没有选择文件”。JavaScript函数:updateFileName()函数在用户选择文件时被调用。input.files是一个FileList对象,包含用户选择的文件。如果用户选择了文件,就会更新的文本内容为文件名;如果没有选择文件,则保持默认提示。
2024年10月19日
199 阅读
0 评论
0 点赞
分享一个css全屏加载特效
忘记在哪个网站扒来的了 ::(委屈)效果CSS #loading { position: fixed; width: 100%; height: 100vh; z-index: 9999; background-color: #eef1f5; top: 0; } .loading { display: flex; flex-direction: row; justify-content: center; align-items: center; height: 100vh; } .loading div { position: relative; min-width: 40px; height: 200px; background: linear-gradient(to bottom, rgba(0, 0, 0, 0.05), #eef1f5); margin: 20px; border-radius: 20px; border: 2px solid #eef1f5; box-shadow: 15px 15px 20px rgba(0, 0, 0, 0.1), -15px -15px 20px #fff, inset -5px -5px 5px rgba(255, 255, 255, 0.5), inset 5px 5px 5px rgba(0, 0, 0, 0.05); overflow: hidden; } .loading div::before { content: ""; position: absolute; top: 0; left: 0; width: 36px; height: 36px; border-radius: 50%; box-shadow: inset -5px -5px 5px rgba(0, 0, 0, 0.1), 0 420px 0 400px lightskyblue; animation: animate 2s ease-in-out infinite; animation-delay: calc(var(--x) * -0.3s); transform: translateY(160px); } @keyframes animate { 0% { transform: translateY(160px); filter: hue-rotate(0deg); } 50% { transform: translateY(0px); filter: hue-rotate(180deg); } 100% { transform: translateY(160px); filter: hue-rotate(360deg); } }HTML 放在body开头即可 <!-- 懒加载组件 --> <div id="loading"> <div class="loading"> <div style="--x:0"></div> <div style="--x:1"></div> <div style="--x:2"></div> <div style="--x:3"></div> <div style="--x:4"></div> <div style="--x:5"></div> </div> </div>JS最后加载完成使用js删除,放在body尾部即可 <script> // 停止懒加载,展示页面 window.addEventListener('load', function () { var loading = document.getElementById('loading'); loading.parentNode.removeChild(loading); }); </script>
2024年10月18日
125 阅读
0 评论
0 点赞
给网站加个LIVE2D
前言之前其实我有写过这个,但是发现好像有一点写漏了,今天重新写一个吧下载所需文件下载:https://wwkm.lanzouf.com/irqig0tl9wkh效果示例参考我网站的dome:https://uurr.cn/myfile/live2d/文件分为api和assetsapi是模型的接口,这个可以供别人使用也可以使用别人的,assets则是一些资源什么的你可以引用我网站的api资源 https://uurr.cn/myfile/live2d/api 接口下载好后在assets/waifu-tips.min.js文件中搜索 ;live2d_settings.modelAPI=" 将你的或者我的api接口填上去就像这样页面引用页面引用示例,要注意这里的目录别到时候引用错了<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Live2D 看板娘 v1.4 / Demo 1</title> <link rel="stylesheet" type="text/css" href="assets/waifu.min.css?v=1.4.2"/> </head> <body style="font-family: 'Microsoft YaHei';"> <!-- waifu-tips.js 依赖 JQuery 库 --> <script src="assets/jquery.min.js?v=3.3.1"></script> <!-- 实现拖动效果,需引入 JQuery UI --> <script src="assets/jquery-ui.min.js?v=1.12.1"></script> <div class="waifu"> <!--<div class="waifu-tips"></div>--> <canvas id="live2d" class="live2d"></canvas> <!--<div class="waifu-tool">--> <!-- <span class="fui-home"></span>--> <!-- <span class="fui-chat"></span>--> <!-- <span class="fui-eye"></span>--> <!-- <span class="fui-user"></span>--> <!-- <span class="fui-photo"></span>--> <!-- <span class="fui-info-circle"></span>--> <!-- <span class="fui-cross"></span>--> <!--</div>--> </div> <script src="assets/waifu-tips.min.js?v=1.4.2"></script> <script src="assets/live2d.min.js?v=1.0.5"></script> <script type="text/javascript"> /* 可直接修改部分参数 */ live2d_settings["modelId"] = 1; // 默认模型 ID live2d_settings["modelTexturesId"] = 87; // 默认材质 ID live2d_settings["modelStorage"] = false; // 不储存模型 ID live2d_settings["canCloseLive2d"] = false; // 隐藏 关闭看板娘 按钮 live2d_settings["canTurnToHomePage"] = false; // 隐藏 返回首页 按钮 live2d_settings["waifuSize"] = "160x160"; // 看板娘大小 live2d_settings["waifuTipsSize"] = "570x150"; // 提示框大小 live2d_settings["waifuFontSize"] = "30px"; // 提示框字体 live2d_settings["waifuToolFont"] = "36px"; // 工具栏字体 live2d_settings["waifuToolLine"] = "50px"; // 工具栏行高 live2d_settings["waifuToolTop"] = "-60px"; // 工具栏顶部边距 live2d_settings["waifuDraggable"] = "unlimited"; // 拖拽样式 live2d_settings["waifuDraggableRevert"] = false; /* 在 initModel 前添加 */ initModel("assets/waifu-tips.json?v=1.4.2") </script> </body> </html>joe主题后台引用示例如何你要在其它地方比如joe主题等使用的话就直接将body的内容放在你主题后台设 - 全局设置 - 自定义中即可 <!-- waifu-tips.js 依赖 JQuery 库 --> <script src="assets/jquery.min.js?v=3.3.1"></script> <!-- 实现拖动效果,需引入 JQuery UI --> <script src="assets/jquery-ui.min.js?v=1.12.1"></script> <div class="waifu"> <!--<div class="waifu-tips"></div>--> <canvas id="live2d" class="live2d"></canvas> <!--<div class="waifu-tool">--> <!-- <span class="fui-home"></span>--> <!-- <span class="fui-chat"></span>--> <!-- <span class="fui-eye"></span>--> <!-- <span class="fui-user"></span>--> <!-- <span class="fui-photo"></span>--> <!-- <span class="fui-info-circle"></span>--> <!-- <span class="fui-cross"></span>--> <!--</div>--> </div> <script src="assets/waifu-tips.min.js?v=1.4.2"></script> <script src="assets/live2d.min.js?v=1.0.5"></script> <script type="text/javascript"> /* 可直接修改部分参数 */ live2d_settings["modelId"] = 1; // 默认模型 ID live2d_settings["modelTexturesId"] = 87; // 默认材质 ID live2d_settings["modelStorage"] = false; // 不储存模型 ID live2d_settings["canCloseLive2d"] = false; // 隐藏 关闭看板娘 按钮 live2d_settings["canTurnToHomePage"] = false; // 隐藏 返回首页 按钮 live2d_settings["waifuSize"] = "160x160"; // 看板娘大小 live2d_settings["waifuTipsSize"] = "570x150"; // 提示框大小 live2d_settings["waifuFontSize"] = "30px"; // 提示框字体 live2d_settings["waifuToolFont"] = "36px"; // 工具栏字体 live2d_settings["waifuToolLine"] = "50px"; // 工具栏行高 live2d_settings["waifuToolTop"] = "-60px"; // 工具栏顶部边距 live2d_settings["waifuDraggable"] = "unlimited"; // 拖拽样式 live2d_settings["waifuDraggableRevert"] = false; /* 在 initModel 前添加 */ initModel("assets/waifu-tips.json?v=1.4.2") </script>
2024年10月11日
278 阅读
4 评论
0 点赞
阿西
::(玫瑰)
2024年04月26日
292 阅读
0 评论
5 点赞
在线网页体重记录表
前言代码在小程序端展示会异常需要的请移步网址 uurr.cn 获取 ::(灯泡)效果简介在本文中,我们将介绍一个简单的体重记录表的网页代码示例。该代码能够实现以下功能:用户可以输入体重数据和密码。输入正确密码后,将数据以时间戳的形式写入到文件中。读取已保存的体重数据,并生成体重变化折线图。显示体重数据的记录表,包括日期、体重和与上次体重的差值。代码功能详解体重数据提交和密码校验代码首先检查用户是否提交了体重数据,并验证密码是否正确。只有密码正确时才允许提交体重数据,否则会提示密码错误。体重数据处理如果存在本地文件 "weights.csv",代码会读取其中的体重数据,并生成折线图。同时,会计算体重数据间的差值,并标注在记录表中,用不同颜色表示增减情况。生成折线图 利用Plotly.js库绘制折线图,展示体重变化趋势。每个数据点上将显示具体的体重数值。记录表展示 在记录表中展示体重数据,包括第N天、日期、体重以及与上一次体重的差值。差值会根据正负情况以不同颜色标识,并保留两位小数。代码 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>体重记录表</title> <!-- 引入 Plotly.js 用于绘制折线图 --> <script src="https://www.w3school.com.cn/lib/graphics/plotly.js"></script> <style> body { font-family: Arial, sans-serif; margin: 20px; color: #333; } h2 { color: #333; text-align: center; } form { margin-bottom: 20px; } input[type="text"] { padding: 10px; width: calc(100% - 20px); margin-bottom: 10px; } input[type="submit"] { padding: 10px; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; width: 100%; } input[type="submit"]:hover { background-color: #45a049; } #chart { margin-bottom: 20px; width: 100%; } @media screen and (max-width: 759px) { /* 在屏幕宽度大于760像素时应用以下样式 */ #chart { height: 260px; } } table { border-collapse: collapse; width: 100%; } th, td { border: 1px solid #ddd; padding: 10px; text-align: center; } th { background-color: #f2f2f2; } </style> </head> <body> <?php // 检查是否有体重数据提交 if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["weight"])) { $weight = $_POST["weight"]; $paw = $_POST["paw"]; // 检查密码是否正确 if($paw != "gtt") { echo "密码错误,请重新输入。密码是你的名字拼音小写"; exit; // 停止执行后续代码 } // 生成当前时间戳 $timestamp = date("Y-m-d H:i:s"); // 将数据写入本地文件 $file = fopen("weights.csv", "a"); fwrite($file, "$timestamp,$weight\n"); fclose($file); // 提交成功后进行重定向 header('Location: index.php'); } else { // 读取体重数据并生成折线图 // 检查文件是否存在 if (file_exists("weights.csv")) { $weights = []; $timestamps = []; $file = fopen("weights.csv", "r"); while (!feof($file)) { $line = fgets($file); $data = explode(",", $line); if (count($data) == 2) { $timestamps[] = $data[0]; $weights[] = $data[1]; } } fclose($file); // 检查是否有体重数据,如果有则生成折线图的JavaScript代码 if (!empty($weights)) { // 计算日期差 $prev_date = date('Y-m-d', strtotime($timestamps[0])); $start_date = strtotime($prev_date); $table_data = []; for ($i = 0; $i < count($weights); $i++) { $curr_date = date('Y-m-d', strtotime($timestamps[$i])); if ($curr_date != $prev_date) { $date_diff++; $prev_date = $curr_date; } $table_data[] = [ 'day' => $date_diff + 1, // 加1修正为第一天 'date' => $timestamps[$i], 'weight' => $weights[$i] ]; // 判断差值 for ($j = 1; $j < count($table_data); $j++) { $prev_weight = $table_data[$j - 1]['weight']; $curr_weight = $table_data[$j]['weight']; $weight_diff = $curr_weight - $prev_weight; $weight_diff = number_format($weight_diff, 2); // 保留两位小数 $table_data[$j]['weight_diff'] = $weight_diff; // 标记颜色 if ($weight_diff < 0) { $table_data[$j]['color'] = 'green'; } elseif ($weight_diff > 0) { $weight_diff = '+' . $weight_diff; $table_data[$j]['color'] = 'red'; } } } echo '<div id="chart"></div><div id="chart_"></div>'; echo '<script>'; echo 'var trace = {'; echo ' x: [' . implode(',', array_map('json_encode', array_column($table_data, 'date'))) . '],'; echo ' y: [' . implode(',', array_column($table_data, 'weight')) . '],'; echo ' type: "scatter"'; echo '};'; echo 'var layout = {'; echo ' title: "体重变化图",'; echo ' xaxis: {'; echo ' title: ""'; echo ' },'; echo ' yaxis: {'; echo ' title: ""'; echo ' },'; echo ' margin: {'; echo ' l: 40,'; echo ' r: 40,'; echo ' t: 40,'; echo ' b: 40'; echo ' },'; echo ' hovermode: false,'; echo ' modebar: {'; echo ' displayModeBar: false'; echo ' }'; echo '};'; echo 'Plotly.newPlot("chart", [trace], layout, { displayModeBar: false, responsive: true, staticPlot: true, });'; echo '</script>'; echo '</div>'; } } else { echo "暂无体重数据。"; } ?> <form method="post" action="index.php"> <input type="text" autocomplete="off" id="weight" name="weight" placeholder="请输入当前体重(kg*2)" required><br> <input type="text" autocomplete="off" id="paw" name="paw" placeholder="请输入当前密码哦 (paw)" required><br> <input type="submit" value="提交"> </form> <?php // 输出表格 echo '<h3>体重记录</h3>'; echo '<table>'; echo '<tr><th>第N天</th><th>日期</th><th>体重(wg)</th><th>差值</th></tr>'; // 检查 $table_data 是否为空 if (!empty($table_data)) { rsort($table_data); foreach ($table_data as $data) { $weight_diff = isset($data['weight_diff']) ? $data['weight_diff'] : ''; $color = isset($data['color']) ? $data['color'] : ''; if ($weight_diff == "") { $weight_diff = '0.00' ; } elseif ($weight_diff < 0) { } elseif ($weight_diff > 0) { $weight_diff = '+' . $weight_diff; } // 根据颜色设置样式 $style = ''; if ($color) { $style = 'style="color: ' . $color . ';"'; } echo '<tr><td>' . $data['day'] . '</td><td>' . $data['date'] . '</td><td>' . $data['weight'] . '</td><td ' . $style . '>' . $weight_diff . '</td></tr>'; } } else { echo '<tr><td colspan="4">暂无体重数据。</td></tr>'; } echo '</table>'; } // 在顶部显示数值 function addAnnotations($data) { $annotations = []; for ($i = 0; $i < count($data['x']); $i++) { $annotation = array( 'x' => $data['x'][$i], 'y' => $data['y'][$i], 'text' => number_format($data['y'][$i], 2), // 显示数值,保留两位小数 'xref' => 'x', 'yref' => 'y', 'showarrow' => true, 'arrowhead' => 0, 'ax' => 0, 'ay' => -30 ); $annotations[] = $annotation; } return $annotations; } ?> </body> </html>
2024年04月21日
422 阅读
0 评论
2 点赞
joe主题优化记录(更新中)
一. 评论打卡/夸夸在主题的 themes/Joe/public/comment.php 中找到 <div class="owo joe_owo__contain"></div> 这行代码,在其下面添加下面的代码html 代码: <div class="comment-clockIn" onclick="javascript:clockIn()">打卡</div> 然后在你的css中添加下列样式css 代码:/*评论打卡*/ .joe_comment__respond-form .foot { justify-content: flex-start!important } .comment-clockIn { text-align: center; color: #606266; height: 26px; line-height: 26px; background: rgba(255,255,255,0.7); opacity: .85; border-radius: 13px; width: 70px; margin-left: 5px; cursor: pointer }最后在把下列代码加入js中,即可完成js 代码:/*评论打卡*/ function clockIn() { let time = (new Date).toLocaleTimeString(); let clockInCon = '滴!贵宾卡!打卡时间:' + time + ',请上车的乘客系好安全带~'; $(".joe_owo__target").val(clockInCon); }/*评论夸夸*/ function clockIn() { const compliments = [ "你的才华真是无与伦比!", "这篇文章写得非常精彩,让人印象深刻。", "你总是能用最简单的方式表达复杂的思想。", "你的视角独特,给我带来了新的启发。", "你的工作总是如此高效,令人佩服。", "这段文字充满了智慧和深度。", "你对细节的关注让作品更加完美。", "你的创意真是令人惊叹,太有才了!", "谢谢你分享如此宝贵的知识。", "你的努力和坚持令人感动。", "这篇文章让我对这个话题有了全新的理解。", "你的思维方式深具启发性,让我大开眼界。", "你在写作中展现出的热情感染了我。", "每次阅读你的作品,我都能学到新东西。", "你的表达能力非常出色,令人钦佩。", "这段论述逻辑严谨,分析透彻。", "你的人生经历丰富多彩,非常令人向往。", "你的幽默感真是让人开心!", "每一句话都展现了你深厚的知识储备。", "你总能把复杂的事情讲得如此简单易懂。", "这篇文章的结构设计得很巧妙,流畅自然。", "你的想法非常前卫,值得深入探讨。", "这段文字的情感表达非常真诚。", "你在文中提出的观点非常有洞察力。", "你的表现超出了我的预期,太棒了!", "你对主题的理解让人叹服。", "这篇文章的每个细节都体现了你的用心。", "你的作品总能引发我深入思考。", "这段论述让我对未来充满希望。", "你的写作风格独具魅力,令人陶醉。", "你用生动的语言描绘了一个美好的画面。", "你的激情和热忱令人鼓舞。", "这篇文章让人感觉温暖而亲切。", "你的批判性思维真是令人敬佩。", "这段文字让我感受到深厚的人文关怀。", "你总是能够触及事物的本质。", "这篇文章的主题选择非常契合时宜。", "你的见解让我重新思考自己的观点。", "每一次阅读都像是一次新的发现。", "你的文字散发着智慧的光芒。", "这段话让我对生活有了新的思考。", "你的写作总能让我感受到强烈的情感。", "这篇文章的内容让我感到振奋。", "你在文中使用的比喻非常生动形象。", "这段论述层次分明,让人易于理解。", "你的观察力真让人佩服!", "这篇文章是一场思维的盛宴。", "你将个人经验与理论结合得很好。", "这段文字的情感流露非常自然。", "你的文字总能触动我的内心。", "这篇文章的内容丰富且耐人寻味。", "你对话题的深刻理解让我感到敬佩。", "这段话的感染力非常强,令人印象深刻。", "你的写作技巧真是让人赞叹不已。", "这篇文章的主题非常贴近生活,真实感人。", "你的思维方式让我大开眼界,充满启发。", "这段话让我感受到深刻的哲理。", "你的文章总是那么引人入胜,令人期待。", "这篇文章的结论非常有力,令人信服。", "你的表达能力让人印象深刻,真是优秀!", "这段文字的情感流露非常自然。", "你的作品总是能让我感受到温暖和希望。", "这篇文章的例证恰到好处,增强了说服力。", "你在写作中展现出的深厚的文化底蕴真让人佩服。", "这段文字激励了我,让我充满动力。", "你对事物的敏锐观察让我敬佩。", "这篇文章是对我思维的极大挑战,感谢!", "你的作品总能引导我思考人生的意义。", "这段话的逻辑性和条理性令人赞赏。", "你的写作总是如此真诚,打动人心。", "这篇文章的内容让我倍感温暖。", "你的写作风格让人感受到一种亲切感。", "这段文字以生动的方式传达了复杂的情感。", "你的努力和坚持真是令人钦佩,继续加油!", "这篇文章的每个部分都展现了你的才华与智慧。" ]; const randomIndex = Math.floor(Math.random() * compliments.length); const randomCompliment = compliments[randomIndex]; $(".joe_owo__target").val(randomCompliment); $(".joe_owo__target").val(clockInCon); }二. 首页导航栏美化找了网上好多教程,好少关于joe导航栏美化的知识,今天自己琢磨了一下,参考了网上一些教程 ::(玫瑰) 效果图:首先我们需要打开网站阿里云的icon资源站 https://www.iconfont.cn ,将自己的资源导入到joe后台的自定义head中然后找到joe根目录的Joe/public/header.php文件,大概83-99行的位置,将以下文件放入至红色框框中即可,注意,需要将里面的icon换成自己的,还有页面$iconClassMap中的对应页面设置好,这个就是你后台 - 独立页面 - 缩略名修改前修改后<a class="item <?php echo $this->is('index') ? 'active' : '' ?>" href="<?php $this->options->siteUrl(); ?>" title="首页"> <svg class="joeicon" aria-hidden="true"> <use xlink:href="#icon-EC_wendang-tiyuyule"></use> </svg> 首页 </a> <?php $this->widget('Widget_Contents_Page_List')->to($pages); ?> <?php if (count($pages->stack) <= $this->options->JNavMaxNum) : ?> <?php foreach (array_slice($pages->stack, 0, $this->options->JNavMaxNum) as $item) : ?> <?php $iconClassMap = [ 'start-page' => 'icon-zhongduan', '3' => 'icon-liuyanmoban', '4' => 'icon-MBEfenggeduosetubiao-fasong', //你的页面名和对应的图标 ]; $iconClass = isset($iconClassMap[$item['slug']]) ? $iconClassMap[$item['slug']] : ''; ?> <a class="item <?php echo $this->is('page', $item['slug']) ? 'active' : '' ?>" href="<?php echo $item['permalink'] ?>" title="<?php echo $item['title'] ?>"> <?php if ($iconClass !== '') : ?> <svg class="joeicon" aria-hidden="true"> <use xlink:href="#<?php echo $iconClass ?>"></use> </svg> <?php endif; ?> <?php echo $item['title'] ?> </a> <?php endforeach; ?> <?php else : ?> <?php foreach (array_slice($pages->stack, 0, $this->options->JNavMaxNum) as $item) : ?> <?php $iconClassMap = [ 'start-page' => 'icon-zhongduan', '3' => 'icon-liuyanmoban', '4' => 'icon-MBEfenggeduosetubiao-fasong', //你的页面名和对应的图标 ]; $iconClass = isset($iconClassMap[$item['slug']]) ? $iconClassMap[$item['slug']] : ''; ?> <a class="item <?php echo $this->is('page', $item['slug']) ? 'active' : '' ?>" href="<?php echo $item['permalink'] ?>" title="<?php echo $item['title'] ?>"> <?php if ($iconClass !== '') : ?> <svg class="joeicon" aria-hidden="true"> <use xlink:href="#<?php echo $iconClass ?>"></use> </svg> <?php endif; ?> <?php echo $item['title'] ?> </a> <?php endforeach; ?> <div class="joe_dropdown" trigger="hover" placement="60px" style="margin-right: 15px;"> <div class="joe_dropdown__link"> <svg class="joeicon" aria-hidden="true"> <use xlink:href="#icon-dianzan"></use> </svg> <a href="#" rel="nofollow">更多</a> <svg class="joe_dropdown__link-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="14" height="14"> <path d="M561.873 725.165c-11.262 11.262-26.545 21.72-41.025 18.502-14.479 2.413-28.154-8.849-39.415-18.502L133.129 375.252c-17.697-17.696-17.697-46.655 0-64.352s46.655-17.696 64.351 0l324.173 333.021 324.977-333.02c17.696-17.697 46.655-17.697 64.351 0s17.697 46.655 0 64.351L561.873 725.165z" p-id="3535" fill="var(--main)"></path> </svg> </div>最后还需要将css代码放入joe后台的自定义css中,可以根据需要修改.joeicon { width: 20px; height: 20px; vertical-align: -.15em; fill: currentColor; overflow: hidden; }三. CSS美化在后台Joe/assets/css/joe.global.min.css中1. 顶部导航栏固定 将joe_header.active{top:-60px}删除或者设置为0即可2. 顶部导航栏高斯模糊效果图:首先需要将背景颜色取消,然后在后台自定义css中加入一下css代码@media screen and (min-width: 759px) { /* 在屏幕宽度大于760像素时应用以下样式 */ .joe_header{backdrop-filter: saturate(5) blur(20px);} }四.添加侧边目录转载的网络上的,自己修改了一点编辑joe/public/aside.php文件,这个文件包含了所有侧边栏组件,在博主栏和人生倒计时中间插入下面这段代码 <?php if (($this->is('post') || $this->is('page'))) : ?> <section class="joe_aside__item catalogue"> <div class="joe_aside__item-title"> <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2084" width="18" height="18"><path d="M640 192H224c-17.7 0-32-14.3-32-32s14.3-32 32-32h416c17.7 0 32 14.3 32 32s-14.3 32-32 32zM960 544H224c-17.7 0-32-14.3-32-32s14.3-32 32-32h736c17.7 0 32 14.3 32 32s-14.3 32-32 32zM640 896H224c-17.7 0-32-14.3-32-32s14.3-32 32-32h416c17.7 0 32 14.3 32 32s-14.3 32-32 32zM96 192H64c-17.7 0-32-14.3-32-32s14.3-32 32-32h32c17.7 0 32 14.3 32 32s-14.3 32-32 32zM96 544H64c-17.7 0-32-14.3-32-32s14.3-32 32-32h32c17.7 0 32 14.3 32 32s-14.3 32-32 32zM96 896H64c-17.7 0-32-14.3-32-32s14.3-32 32-32h32c17.7 0 32 14.3 32 32s-14.3 32-32 32z" p-id="2085"></path></svg> <span class="text">导航目录</span> </div> <div class="joe_aside__item-contain"> <ul class="catalogue-items"> </ul> </div> </section> <?php endif; ?>接下来修改joe\assets\js\joe.post_page.min.js文件,在文件开头的第一个大括号后面添加下面这段代码function get_catalogs(article_content) { let titles = []; let diffLevel = 0; const titleTag = ["H1", "H2", "H3", "H4", "H5", "H6"]; // Filter out non-element nodes const elements = Array.from(article_content.children); elements.forEach((e, index) => { const nodeName = e.nodeName; if (titleTag.includes(nodeName)) { const level = parseInt(nodeName.substring(1, 2), 10) - diffLevel; titles.push({ id: "header-" + index, text: e.textContent, level: level }); e.id = "header-" + index; } }); return titles; } article_content = document.querySelector('.joe_detail__article'); if (article_content) { var catalog = get_catalogs(article_content); if (catalog.length == 0) { $('.catalogue').hide() } else { let asideArr = ['timelife', 'today', 'hot', 'newreply', 'weather', 'tags', 'flatterer']; asideArr.forEach(item => $('.joe_aside__item.' + item).remove()); let catalogue = ''; for (let i = 0; i < catalog.length; i++) { let node = '<li class="catalogue-item">' + '<a id="to-' + catalog[i].id + '" title="' + catalog[i].text + '" href="#' + catalog[i].id + '">' + '<span class="dir_name">' + catalog[i].text + '</span>' + '</a>' + '</li>'; if (i == catalog.length - 1) { catalogue += node + '</li>' } else { if (catalog[i + 1].level == catalog[i].level) { catalogue += node + '</li>' } else if (catalog[i + 1].level > catalog[i].level) { catalogue += (catalog[i + 1].level > 1) ? node + '<ul class="level-' + catalog[i + 1].level + '">' : node + '</li>' } else { if (catalog[i + 1].level - catalog[i].level == -2) { catalogue += i > 1 ? node + '</li></ul></li></ul></li>' : node + '</li></ul></li>' } else { catalogue += i > 1 ? node + '</li></ul></li>' : node + '</li>' } } } } document.querySelector('.catalogue-items').innerHTML = catalogue; $('.catalogue-item > a').on('mouseenter', function() { $(this).parent().addClass('_active') }); $('.catalogue-item > a').on('mouseleave', function() { $(this).parent().removeClass('_active') }); $('.catalogue-item > a').on('click', function() { document.removeEventListener("scroll", autoActive); $('.catalogue-item').removeClass('active'); $(this).parent().addClass('active'); let aim = document.querySelector('#' + $(this).attr('to')); let aim_top = aim.offsetTop; let aim_h = aim.clientHeight; let above_h = document.querySelector('.joe_header__above').clientHeight; let below_h = document.querySelector('.joe_header__below').clientHeight; let offset = 0; let case1 = !document.querySelector('.joe_header__above').className.includes('active'); let case2 = document.getElementsByTagName("html")[0].scrollTop + above_h > aim_top; if (case1 && case2) { offset = above_h } window.scrollTo({ top: aim_top - offset - below_h - 10, behavior: 'smooth' }); setTimeout(() => { document.addEventListener("scroll", autoActive) }, 500) }); if (catalog.length) $('.catalogue-item').eq(0).addClass('active'); let autoActive = function() { let html_top = document.getElementsByTagName("html")[0].scrollTop; let contain = $(".joe_aside__item.catalogue .joe_aside__item-contain"); for (let i = 0; i < catalog.length; i++) { let offset = 0; let h_id = '#' + catalog[i].id; let h_offset = document.querySelector(h_id).offsetTop; let above_h = document.querySelector('.joe_header__above').clientHeight; let below_h = document.querySelector('.joe_header__below').clientHeight; if (!document.querySelector('.joe_header').className.includes('active')) offset = above_h; if (h_offset + below_h + offset + 10 >= html_top) { $('.catalogue-item').removeClass('active'); if (i > 0 && i < catalog.length - 1 && document.querySelector('#' + catalog[i].id).offsetTop > html_top + window.innerHeight * 0.2) { i-- } $('#to-' + catalog[i].id).parent().addClass('active'); break } } }; document.addEventListener("scroll", autoActive) } } else { $('.catalogue').hide() }后面就是样式问题了,接下来修改joe\assets\css\joe.post.min.css在文件末尾添加下面这段CSS .joe_aside__item.catalogue{margin-bottom:15px;transition:top 0.35s;background:var(--background)} .joe_aside__item.catalogue .joe_aside__item-contain{padding:0;margin:0;margin-left:10px;max-height:500px;overflow-y:auto} .joe_aside__item.catalogue .joe_aside__item-contain::-webkit-scrollbar{width:3px} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items{border-left:2px solid var(--classC);padding:10px 15px} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item{margin:0;padding:0;line-height:26px;font-size:15px} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item a{position:relative;display:block;line-height:26px;color:var(--main);transition:color 0.5s} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item a:hover{color:var(--theme)} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item._active>a,.joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item.active>a{color:var(--theme)} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item._active>a::before,.joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item.active>a::before{content:"";position:absolute;left:-17px;top:0;width:2px;height:26px;background-color:var(--theme);transition:height 0.35s} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-2>.catalogue-item,.joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-3 .catalogue-item{font-size:14px} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-2 .catalogue-item._active>a::before,.joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-2 .catalogue-item.active>a::before,.joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-3 .catalogue-item._active>a::before,.joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-3 .catalogue-item.active>a::before{left:-34px} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-2 .catalogue-item .level-3 .catalogue-item,.joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-3 .catalogue-item .level-3 .catalogue-item{font-size:14px} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-2 .catalogue-item .level-3 .catalogue-item._active>a::before,.joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-2 .catalogue-item .level-3 .catalogue-item.active>a::before,.joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-3 .catalogue-item .level-3 .catalogue-item._active>a::before,.joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-3 .catalogue-item .level-3 .catalogue-item.active>a::before{left:-51px} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item .level-3>.catalogue-item{font-size:14px} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item ul{padding-left:17px} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items ul{display:block;list-style-type:disc} .joe_aside__item.catalogue .joe_aside__item-contain .catalogue-items .catalogue-item a span.dir_name{display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis} 五.侧边栏滑动位置这个的位置觉得太靠上可以改以下,滑动的时候位置 usr/themes/Joe/assets/js/joe.global.min.js ,-60的哪个表示往下滑的时候侧边栏与顶部距离,+15的表示上滑时侧边栏与顶部距离六.代码展示优化有时候代码太长反而影响用户阅读,所以我们可以将这个进行缩小,加个滚顶条即可,找到joe\assets\css\joe.global.min.css,搜索 .joe_detail__article pre[class*='language-'] ,然后把这个overflow:hidden改为 overflow-y: auto;后面加个max-height: 500px;自定义一下高度就可以了
2024年03月23日
446 阅读
0 评论
1 点赞
1
2
3
4