first commit
This commit is contained in:
216
miniprogram/generate-icons.html
Normal file
216
miniprogram/generate-icons.html
Normal file
@@ -0,0 +1,216 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>TabBar 图标生成器</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
max-width: 800px;
|
||||
margin: 50px auto;
|
||||
padding: 20px;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
h1 {
|
||||
color: #333;
|
||||
text-align: center;
|
||||
}
|
||||
.icon-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 20px;
|
||||
margin: 30px 0;
|
||||
}
|
||||
.icon-card {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||||
text-align: center;
|
||||
}
|
||||
canvas {
|
||||
border: 1px solid #ddd;
|
||||
margin: 10px 0;
|
||||
}
|
||||
button {
|
||||
background: #07c160;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
}
|
||||
button:hover {
|
||||
background: #06ad56;
|
||||
}
|
||||
.info {
|
||||
background: #e6f7ed;
|
||||
padding: 15px;
|
||||
border-radius: 4px;
|
||||
margin: 20px 0;
|
||||
border-left: 4px solid #07c160;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>🎨 TabBar 图标生成器</h1>
|
||||
|
||||
<div class="info">
|
||||
<strong>使用说明:</strong><br>
|
||||
1. 点击每个图标下方的"下载"按钮<br>
|
||||
2. 将下载的 PNG 文件重命名并保存到 <code>miniprogram/images/tabbar/</code> 目录<br>
|
||||
3. 在 app.json 中配置图标路径
|
||||
</div>
|
||||
|
||||
<div class="icon-grid">
|
||||
<div class="icon-card">
|
||||
<h3>🏠 首页 (未选中)</h3>
|
||||
<canvas id="home" width="81" height="81"></canvas>
|
||||
<br>
|
||||
<button onclick="downloadIcon('home', 'home.png')">下载 home.png</button>
|
||||
</div>
|
||||
|
||||
<div class="icon-card">
|
||||
<h3>🏠 首页 (选中)</h3>
|
||||
<canvas id="home-active" width="81" height="81"></canvas>
|
||||
<br>
|
||||
<button onclick="downloadIcon('home-active', 'home-active.png')">下载 home-active.png</button>
|
||||
</div>
|
||||
|
||||
<div class="icon-card">
|
||||
<h3>📄 我的发布 (未选中)</h3>
|
||||
<canvas id="article" width="81" height="81"></canvas>
|
||||
<br>
|
||||
<button onclick="downloadIcon('article', 'article.png')">下载 article.png</button>
|
||||
</div>
|
||||
|
||||
<div class="icon-card">
|
||||
<h3>📄 我的发布 (选中)</h3>
|
||||
<canvas id="article-active" width="81" height="81"></canvas>
|
||||
<br>
|
||||
<button onclick="downloadIcon('article-active', 'article-active.png')">下载 article-active.png</button>
|
||||
</div>
|
||||
|
||||
<div class="icon-card">
|
||||
<h3>👤 我的 (未选中)</h3>
|
||||
<canvas id="user" width="81" height="81"></canvas>
|
||||
<br>
|
||||
<button onclick="downloadIcon('user', 'user.png')">下载 user.png</button>
|
||||
</div>
|
||||
|
||||
<div class="icon-card">
|
||||
<h3>👤 我的 (选中)</h3>
|
||||
<canvas id="user-active" width="81" height="81"></canvas>
|
||||
<br>
|
||||
<button onclick="downloadIcon('user-active', 'user-active.png')">下载 user-active.png</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 绘制房子图标
|
||||
function drawHome(ctx, color) {
|
||||
ctx.strokeStyle = color;
|
||||
ctx.fillStyle = color;
|
||||
ctx.lineWidth = 3;
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineJoin = 'round';
|
||||
|
||||
// 房顶
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(20, 40);
|
||||
ctx.lineTo(40, 25);
|
||||
ctx.lineTo(60, 40);
|
||||
ctx.stroke();
|
||||
|
||||
// 房子主体
|
||||
ctx.strokeRect(25, 38, 30, 25);
|
||||
|
||||
// 门
|
||||
ctx.fillRect(35, 48, 10, 15);
|
||||
}
|
||||
|
||||
// 绘制文档图标
|
||||
function drawDocument(ctx, color) {
|
||||
ctx.strokeStyle = color;
|
||||
ctx.fillStyle = color;
|
||||
ctx.lineWidth = 3;
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineJoin = 'round';
|
||||
|
||||
// 文档外框
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(28, 22);
|
||||
ctx.lineTo(28, 59);
|
||||
ctx.lineTo(52, 59);
|
||||
ctx.lineTo(52, 32);
|
||||
ctx.lineTo(42, 22);
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
|
||||
// 折角
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(42, 22);
|
||||
ctx.lineTo(42, 32);
|
||||
ctx.lineTo(52, 32);
|
||||
ctx.stroke();
|
||||
|
||||
// 横线
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(33, 40);
|
||||
ctx.lineTo(47, 40);
|
||||
ctx.moveTo(33, 47);
|
||||
ctx.lineTo(47, 47);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// 绘制用户图标
|
||||
function drawUser(ctx, color) {
|
||||
ctx.strokeStyle = color;
|
||||
ctx.fillStyle = color;
|
||||
ctx.lineWidth = 3;
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineJoin = 'round';
|
||||
|
||||
// 头部
|
||||
ctx.beginPath();
|
||||
ctx.arc(40, 32, 8, 0, Math.PI * 2);
|
||||
ctx.stroke();
|
||||
|
||||
// 身体
|
||||
ctx.beginPath();
|
||||
ctx.arc(40, 58, 15, Math.PI, 0, true);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// 初始化所有图标
|
||||
function initIcons() {
|
||||
// 首页图标
|
||||
drawHome(document.getElementById('home').getContext('2d'), '#999999');
|
||||
drawHome(document.getElementById('home-active').getContext('2d'), '#07c160');
|
||||
|
||||
// 文档图标
|
||||
drawDocument(document.getElementById('article').getContext('2d'), '#999999');
|
||||
drawDocument(document.getElementById('article-active').getContext('2d'), '#07c160');
|
||||
|
||||
// 用户图标
|
||||
drawUser(document.getElementById('user').getContext('2d'), '#999999');
|
||||
drawUser(document.getElementById('user-active').getContext('2d'), '#07c160');
|
||||
}
|
||||
|
||||
// 下载图标
|
||||
function downloadIcon(canvasId, filename) {
|
||||
const canvas = document.getElementById(canvasId);
|
||||
const url = canvas.toDataURL('image/png');
|
||||
const link = document.createElement('a');
|
||||
link.download = filename;
|
||||
link.href = url;
|
||||
link.click();
|
||||
}
|
||||
|
||||
// 页面加载完成后初始化
|
||||
window.onload = initIcons;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user