首页
关于
留言
统计
更多
友联
壁纸
图床
Search
1
下次见面又是什么时候呢
747 阅读
2
小程序npn构建
424 阅读
3
joe主题优化记录(更新中)
388 阅读
4
和他
374 阅读
5
在线网页体重记录表
367 阅读
Search
标签搜索
日常
joe
js
php
window
编程知识
小程序
html
Blank
累计撰写
19
篇文章
累计收到
7
条评论
首页
栏目
最新文章
日常记录
微言微语
风景分享
生活知识
电脑知识
编程知识
办公技巧
node
页面
关于
留言
统计
友联
壁纸
图床
搜索到
7
篇与
编程知识
的结果
颜色展示网页
一个展示预设颜色的HTML页面,使用您提供的颜色预设数组,创建一个美观的颜色展示界面 Vue风格颜色矩阵展示器 * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; } body { background: linear-gradient(135deg, #f8fafc 0%, #eef2f6 100%); min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 40px 20px; color: #2c3e50; } .container { max-width: 1200px; width: 100%; } header { text-align: center; margin-bottom: 40px; padding: 20px; } .logo { display: flex; align-items: center; justify-content: center; gap: 15px; margin-bottom: 20px; } .logo-icon { font-size: 2.8rem; color: #42b883; } h1 { font-size: 2.8rem; margin-bottom: 5px; background: linear-gradient(90deg, #42b883, #35495e); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 2px 2px 4px rgba(0,0,0,0.1); } .subtitle { font-size: 1.2rem; color: #5a6c7d; max-width: 700px; margin: 0 auto; line-height: 1.6; } .color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 15px; margin-top: 20px; background: white; padding: 25px; border-radius: 20px; box-shadow: 0 15px 40px rgba(0,0,0,0.08); } .color-row-header { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 15px; margin-bottom: 10px; } .row-title { grid-column: 1 / -1; text-align: center; font-size: 1.4rem; font-weight: 600; padding: 12px; margin-bottom: 10px; border-radius: 10px; background: #f8f9fa; } .color-card { height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 6px 15px rgba(0,0,0,0.08); transition: all 0.3s ease; cursor: pointer; position: relative; display: flex; flex-direction: column; justify-content: space-between; } .color-card:hover { transform: translateY(-8px); box-shadow: 0 12px 25px rgba(0,0,0,0.15); } .color-preview { flex-grow: 1; display: flex; align-items: center; justify-content: center; } .color-info { padding: 10px; background: rgba(255, 255, 255, 0.85); text-align: center; font-weight: 600; font-size: 0.9rem; } .color-hex { font-family: 'Fira Code', monospace; font-size: 0.85rem; } .copy-btn { position: absolute; top: 10px; right: 10px; background: rgba(255, 255, 255, 0.8); border: none; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: all 0.3s; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .color-card:hover .copy-btn { opacity: 1; } .copy-btn:hover { background: white; transform: scale(1.1); } .copy-notification { position: fixed; top: 30px; left: 50%; transform: translateX(-50%); background: rgba(66, 184, 131, 0.9); color: white; padding: 12px 25px; border-radius: 8px; font-weight: 500; opacity: 0; transition: opacity 0.3s; pointer-events: none; display: flex; align-items: center; gap: 10px; } .copy-notification.show { opacity: 1; } .footer { margin-top: 40px; text-align: center; color: #5a6c7d; padding: 20px; font-size: 0.9rem; border-top: 1px solid #eaeaea; width: 100%; } @media (max-width: 992px) { .color-grid { grid-template-columns: repeat(3, 1fr); } } @media (max-width: 768px) { .color-grid { grid-template-columns: repeat(2, 1fr); } h1 { font-size: 2.2rem; } } @media (max-width: 480px) { .color-grid { grid-template-columns: 1fr; } h1 { font-size: 1.8rem; } } Vue风格颜色矩阵 精心设计的6×6颜色矩阵,包含6种不同色系,每行6个颜色 颜色值已复制到剪贴板! © 2023 Vue风格颜色矩阵 | 共展示 36 个预设颜色 // 颜色预设数组 - 6行每行6个颜色 const colorPresets = [ // 第一行:白色到黑色(灰色系) [ { hex: '#FFFFFF', name: '纯白' }, { hex: '#F8F9FA', name: '雪白' }, { hex: '#E9ECEF', name: '浅灰' }, { hex: '#DEE2E6', name: '银灰' }, { hex: '#6C757D', name: '中灰' }, { hex: '#212529', name: '深黑' } ], // 第二行:蓝色系 [ { hex: '#E7F5FF', name: '浅天蓝' }, { hex: '#D0EBFF', name: '天蓝' }, { hex: '#74C0FC', name: '湖蓝' }, { hex: '#339AF0', name: '钴蓝' }, { hex: '#1C7ED6', name: '深蓝' }, { hex: '#1864AB', name: '海军蓝' } ], // 第三行:绿色系 [ { hex: '#E6FCF5', name: '薄荷绿' }, { hex: '#C3FAE8', name: '春绿' }, { hex: '#96F2D7', name: '翡翠绿' }, { hex: '#40C057', name: '草绿' }, { hex: '#2F9E44', name: '森林绿' }, { hex: '#2B8A3E', name: '深绿' } ], // 第四行:紫色系 [ { hex: '#F3F0FF', name: '薰衣草' }, { hex: '#E5DBFF', name: '淡紫' }, { hex: '#D0BFFF', name: '紫藤' }, { hex: '#B197FC', name: '紫罗兰' }, { hex: '#845EF7', name: '皇家紫' }, { hex: '#5F3DC4', name: '深紫' } ], // 第五行:红色系 [ { hex: '#FFF5F5', name: '粉红' }, { hex: '#FFE3E3', name: '玫瑰红' }, { hex: '#FFC9C9', name: '珊瑚红' }, { hex: '#FF6B6B', name: '鲜红' }, { hex: '#F03E3E', name: '绯红' }, { hex: '#C92A2A', name: '深红' } ], // 第六行:其他色系(黄色、橙色、青色等) [ { hex: '#FFF9DB', name: '浅黄' }, { hex: '#FFEC99', name: '柠檬黄' }, { hex: '#FFD43B', name: '金黄' }, { hex: '#FFA94D', name: '橙黄' }, { hex: '#FF922B', name: '橙红' }, { hex: '#20C997', name: '青绿' } ] ]; // 行标题 const rowTitles = [ "灰色系 (白到黑)", "蓝色系", "绿色系", "紫色系", "红色系", "其他色系" ]; // 获取DOM元素 const colorGrid = document.getElementById('colorGrid'); const copyNotification = document.getElementById('copyNotification'); const colorCount = document.getElementById('colorCount'); // 计算总颜色数量 const totalColors = colorPresets.reduce((total, row) => total + row.length, 0); colorCount.textContent = totalColors; // 创建颜色网格 colorPresets.forEach((row, rowIndex) => { // 添加行标题 const rowTitle = document.createElement('div'); rowTitle.className = 'row-title'; rowTitle.textContent = rowTitles[rowIndex]; colorGrid.appendChild(rowTitle); // 添加颜色卡片 row.forEach(color => { const colorCard = document.createElement('div'); colorCard.className = 'color-card'; // 计算文字颜色(深色背景用白色文字,浅色背景用黑色文字) const rgb = hexToRgb(color.hex); const brightness = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; const textColor = brightness > 128 ? '#000' : '#FFF'; colorCard.innerHTML = ` ${color.name} ${color.hex} `; colorGrid.appendChild(colorCard); }); }); // 添加复制功能 document.querySelectorAll('.copy-btn').forEach(button => { button.addEventListener('click', function(e) { e.stopPropagation(); const color = this.getAttribute('data-color'); copyToClipboard(color); // 显示通知 copyNotification.classList.add('show'); setTimeout(() => { copyNotification.classList.remove('show'); }, 2000); }); }); // 辅助函数:十六进制转RGB function hexToRgb(hex) { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); return result ? { r: parseInt(result[1], 16), g: parseInt(result[2], 16), b: parseInt(result[3], 16) } : { r: 0, g: 0, b: 0 }; } // 辅助函数:复制到剪贴板 function copyToClipboard(text) { const textarea = document.createElement('textarea'); textarea.value = text; document.body.appendChild(textarea); textarea.select(); document.execCommand('copy'); document.body.removeChild(textarea); } <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Vue风格颜色矩阵展示器</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; } body { background: linear-gradient(135deg, #f8fafc 0%, #eef2f6 100%); min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 40px 20px; color: #2c3e50; } .container { max-width: 1200px; width: 100%; } header { text-align: center; margin-bottom: 40px; padding: 20px; } .logo { display: flex; align-items: center; justify-content: center; gap: 15px; margin-bottom: 20px; } .logo-icon { font-size: 2.8rem; color: #42b883; } h1 { font-size: 2.8rem; margin-bottom: 5px; background: linear-gradient(90deg, #42b883, #35495e); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 2px 2px 4px rgba(0,0,0,0.1); } .subtitle { font-size: 1.2rem; color: #5a6c7d; max-width: 700px; margin: 0 auto; line-height: 1.6; } .color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 15px; margin-top: 20px; background: white; padding: 25px; border-radius: 20px; box-shadow: 0 15px 40px rgba(0,0,0,0.08); } .color-row-header { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 15px; margin-bottom: 10px; } .row-title { grid-column: 1 / -1; text-align: center; font-size: 1.4rem; font-weight: 600; padding: 12px; margin-bottom: 10px; border-radius: 10px; background: #f8f9fa; } .color-card { height: 140px; border-radius: 12px; overflow: hidden; box-shadow: 0 6px 15px rgba(0,0,0,0.08); transition: all 0.3s ease; cursor: pointer; position: relative; display: flex; flex-direction: column; justify-content: space-between; } .color-card:hover { transform: translateY(-8px); box-shadow: 0 12px 25px rgba(0,0,0,0.15); } .color-preview { flex-grow: 1; display: flex; align-items: center; justify-content: center; } .color-info { padding: 10px; background: rgba(255, 255, 255, 0.85); text-align: center; font-weight: 600; font-size: 0.9rem; } .color-hex { font-family: 'Fira Code', monospace; font-size: 0.85rem; } .copy-btn { position: absolute; top: 10px; right: 10px; background: rgba(255, 255, 255, 0.8); border: none; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: all 0.3s; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .color-card:hover .copy-btn { opacity: 1; } .copy-btn:hover { background: white; transform: scale(1.1); } .copy-notification { position: fixed; top: 30px; left: 50%; transform: translateX(-50%); background: rgba(66, 184, 131, 0.9); color: white; padding: 12px 25px; border-radius: 8px; font-weight: 500; opacity: 0; transition: opacity 0.3s; pointer-events: none; display: flex; align-items: center; gap: 10px; } .copy-notification.show { opacity: 1; } .footer { margin-top: 40px; text-align: center; color: #5a6c7d; padding: 20px; font-size: 0.9rem; border-top: 1px solid #eaeaea; width: 100%; } @media (max-width: 992px) { .color-grid { grid-template-columns: repeat(3, 1fr); } } @media (max-width: 768px) { .color-grid { grid-template-columns: repeat(2, 1fr); } h1 { font-size: 2.2rem; } } @media (max-width: 480px) { .color-grid { grid-template-columns: 1fr; } h1 { font-size: 1.8rem; } } </style> </head> <body> <div class="container"> <header> <div class="logo"> <i class="fas fa-palette logo-icon"></i> <h1>Vue风格颜色矩阵</h1> </div> <p class="subtitle"> 精心设计的6×6颜色矩阵,包含6种不同色系,每行6个颜色 </p> </header> <div class="color-grid" id="colorGrid"> <!-- 颜色将通过JS动态生成 --> </div> </div> <div class="copy-notification" id="copyNotification"> <i class="fas fa-check-circle"></i> <span>颜色值已复制到剪贴板!</span> </div> <div class="footer"> <p>© 2023 Vue风格颜色矩阵 | 共展示 <span id="colorCount">36</span> 个预设颜色</p> </div> <script> // 颜色预设数组 - 6行每行6个颜色 const colorPresets = [ // 第一行:白色到黑色(灰色系) [ { hex: '#FFFFFF', name: '纯白' }, { hex: '#F8F9FA', name: '雪白' }, { hex: '#E9ECEF', name: '浅灰' }, { hex: '#DEE2E6', name: '银灰' }, { hex: '#6C757D', name: '中灰' }, { hex: '#212529', name: '深黑' } ], // 第二行:蓝色系 [ { hex: '#E7F5FF', name: '浅天蓝' }, { hex: '#D0EBFF', name: '天蓝' }, { hex: '#74C0FC', name: '湖蓝' }, { hex: '#339AF0', name: '钴蓝' }, { hex: '#1C7ED6', name: '深蓝' }, { hex: '#1864AB', name: '海军蓝' } ], // 第三行:绿色系 [ { hex: '#E6FCF5', name: '薄荷绿' }, { hex: '#C3FAE8', name: '春绿' }, { hex: '#96F2D7', name: '翡翠绿' }, { hex: '#40C057', name: '草绿' }, { hex: '#2F9E44', name: '森林绿' }, { hex: '#2B8A3E', name: '深绿' } ], // 第四行:紫色系 [ { hex: '#F3F0FF', name: '薰衣草' }, { hex: '#E5DBFF', name: '淡紫' }, { hex: '#D0BFFF', name: '紫藤' }, { hex: '#B197FC', name: '紫罗兰' }, { hex: '#845EF7', name: '皇家紫' }, { hex: '#5F3DC4', name: '深紫' } ], // 第五行:红色系 [ { hex: '#FFF5F5', name: '粉红' }, { hex: '#FFE3E3', name: '玫瑰红' }, { hex: '#FFC9C9', name: '珊瑚红' }, { hex: '#FF6B6B', name: '鲜红' }, { hex: '#F03E3E', name: '绯红' }, { hex: '#C92A2A', name: '深红' } ], // 第六行:其他色系(黄色、橙色、青色等) [ { hex: '#FFF9DB', name: '浅黄' }, { hex: '#FFEC99', name: '柠檬黄' }, { hex: '#FFD43B', name: '金黄' }, { hex: '#FFA94D', name: '橙黄' }, { hex: '#FF922B', name: '橙红' }, { hex: '#20C997', name: '青绿' } ] ]; // 行标题 const rowTitles = [ "灰色系 (白到黑)", "蓝色系", "绿色系", "紫色系", "红色系", "其他色系" ]; // 获取DOM元素 const colorGrid = document.getElementById('colorGrid'); const copyNotification = document.getElementById('copyNotification'); const colorCount = document.getElementById('colorCount'); // 计算总颜色数量 const totalColors = colorPresets.reduce((total, row) => total + row.length, 0); colorCount.textContent = totalColors; // 创建颜色网格 colorPresets.forEach((row, rowIndex) => { // 添加行标题 const rowTitle = document.createElement('div'); rowTitle.className = 'row-title'; rowTitle.textContent = rowTitles[rowIndex]; colorGrid.appendChild(rowTitle); // 添加颜色卡片 row.forEach(color => { const colorCard = document.createElement('div'); colorCard.className = 'color-card'; // 计算文字颜色(深色背景用白色文字,浅色背景用黑色文字) const rgb = hexToRgb(color.hex); const brightness = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; const textColor = brightness > 128 ? '#000' : '#FFF'; colorCard.innerHTML = ` <div class="color-preview" style="background-color: ${color.hex};"> <span style="color: ${textColor}; font-size: 1.1rem; font-weight: bold; text-shadow: 0 0 3px rgba(0,0,0,0.3);">${color.name}</span> </div> <div class="color-info"> <span class="color-hex">${color.hex}</span> </div> <button class="copy-btn" data-color="${color.hex}"> <i class="far fa-copy"></i> </button> `; colorGrid.appendChild(colorCard); }); }); // 添加复制功能 document.querySelectorAll('.copy-btn').forEach(button => { button.addEventListener('click', function(e) { e.stopPropagation(); const color = this.getAttribute('data-color'); copyToClipboard(color); // 显示通知 copyNotification.classList.add('show'); setTimeout(() => { copyNotification.classList.remove('show'); }, 2000); }); }); // 辅助函数:十六进制转RGB function hexToRgb(hex) { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); return result ? { r: parseInt(result[1], 16), g: parseInt(result[2], 16), b: parseInt(result[3], 16) } : { r: 0, g: 0, b: 0 }; } // 辅助函数:复制到剪贴板 function copyToClipboard(text) { const textarea = document.createElement('textarea'); textarea.value = text; document.body.appendChild(textarea); textarea.select(); document.execCommand('copy'); document.body.removeChild(textarea); } </script> </body> </html>
2025年06月07日
5 阅读
0 评论
0 点赞
网站顶部浏览进度条
前言非常的简单,根据自己需求复制就好了,记得确保 jQuery 已加载 ::(你懂的)效果代码<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>浏览进度条示例</title> <style> :root { --back-line-right: linear-gradient(to right, #4caf50, #4caf50); /* 确保定义 CSS 变量 */ } #scrollProgressBar { width: 0; height: 3px; z-index: 1001; background-image: var(--back-line-right); border-radius: 5px; position: fixed; /* 确保进度条固定在页面顶部 */ top: 0; left: 0; transition: width 0.45s; } </style> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <!-- 顶部浏览进度条 --> <div id="scrollProgressBar"></div> <div style="height: 2000px;"> <!-- 模拟长页面内容 --> <h1>滚动以查看进度条</h1> <p>这是一个示例页面,滚动以查看顶部进度条如何工作。</p> <!-- 添加更多内容以增加页面高度 --> </div> <script> $(window).scroll(function() { let scrollTop = $(window).scrollTop(), documentHeight = $(document).height(), windowHeight = $(window).height(); let scrollPercent = (scrollTop / (documentHeight - windowHeight)) * 100; scrollPercent = scrollPercent.toFixed(1); $("#scrollProgressBar").css({ width: scrollPercent + "%" }); }).trigger("scroll"); </script> <!-- 顶部浏览进度条结束 --> </body> </html>
2024年10月20日
99 阅读
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日
246 阅读
4 评论
0 点赞
在线网页体重记录表
前言代码在小程序端展示会异常需要的请移步网址 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日
367 阅读
0 评论
2 点赞
RSA加密示例
前言这是一种非对称式加密,很适合用在前端与后端的通信上它分为公钥和私钥,公钥仅可用于加密,私钥用于解密这样一来就可以将公钥发送给客户端,客户端拿着公钥加密后返回给服务器,服务器再使用私钥进行解密我小程序也采用了这种加密方式给需要的大佬借鉴一下首先是php端代码(后端或者服务器端),这里使用了base64_decode和url解码,因为我前端也进行了相应的编码教程我们需要先生成一个密钥在线RAS密钥生成:https://www.lddgo.net/encrypt/rsa // 解密 function Rsa_decrypts($data) { // 加载openssl扩展 if (!extension_loaded('openssl')) { die('OpenSSL 扩展未加载'); } // 密钥文件路径 $privateKeyFile = '改为自己路径private_key.pem'; $publicKeyFile = '改为自己路径public_key.pem'; // 加载私钥 $privateKeyResource = openssl_pkey_get_private(file_get_contents($privateKeyFile)); if ($privateKeyResource === false) { return '无法加载私钥'; } $data=urldecode($data); $data=base64_decode($data); $decryptedText = ''; if (openssl_private_decrypt(base64_decode($data), $decryptedText, $privateKeyResource, OPENSSL_PKCS1_PADDING) === false) { return ''; } return $decryptedText; } 然后我们开始在微信小程序安装一下相应的库选择小程序的调试器 —— 选择终端 —— 输入npm i wxmp-rsa -S进行安装安装完成后小程序目录里面会生成node_modules文件夹,里面会有wxmp-rsa文件夹安装完成后在编辑器左上角的菜单栏中找到工具 —— 构建npm完成后小程序文件目录会构建出miniprogram_npm文件夹,里面会有wxmp-rsa文件夹然后将你就可以开始使用了,下面是一个参考示例,同样这里我使用了Base64和url编码,./base64.js可以百度下载一个,如果不需要移除即可,这样就可以实现小程序与后端的加密通讯了,但是需要注意数据长度不能超过太长!否则将加密失败! // 导入包 import WxmpRsa from 'wxmp-rsa' const Base64 = require('./base64.js'); // 实例化rsa const rsa = new WxmpRsa() rsa.default_key_size = 512 const publicKey = "这里放公钥" // 加密 function encrypt(data) { if (typeof data != 'string') { data = data.toString() } if (data == '') { return '' } if (publicKey != "") { rsa.setPublicKey(publicKey) const cryptStr = rsa.encryptLong(data) var r = Base64.encode(cryptStr) var r = encodeURIComponent(r) return r } return '' } //暴露接口 module.exports = { encrypt, UPglobalData, }
2023年11月02日
206 阅读
0 评论
2 点赞
Android studio安装教程
Android studio安装:下载链接:http://www.android-studio.org/找到自己想要的版本:(或者直接点击上面的,默认是windows 64位)等待一段时间,下载完成后:点击安装包点击next;点击next;选择安装路径:点击Install安装;进度条完成后,点击next点击Finish完成(注意勾选start Android studio会启动程序)启动后:选择第二个,然后点击OK点击后会出现一个弹窗,两个都可以选,推荐选的Don‘t sen然后点击Cancel进入界面,点击next点击next选择你的布局颜色,选择完成后,点击next点击Finish,等待进度条完成点击finish完成文章转载于:https://blog.csdn.net/alzzw/article/details/102692135
2023年10月12日
300 阅读
0 评论
10 点赞
1
2