- works/menu-icons/index.html:16 个一级菜单 210 个候选图标,点选复制 SVG - works/avatar-library.html + works/avatars/(40 SVG)+ works/avatar-preview.html:默认头像素材库及在线预览 - 面包屑/图片路径改为 works 内相对路径(../avatars → avatars,返回链接指向 works.html) - 删除 works/devdoc 整站(含 3.26MB mermaid),works.js 与版本号同步
294 lines
14 KiB
HTML
294 lines
14 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>默认头像选型</title>
|
||
<style>
|
||
* { box-sizing: border-box; }
|
||
body {
|
||
margin: 0;
|
||
padding: 32px 24px 48px;
|
||
background: #f4f6fa;
|
||
color: #1f2d3d;
|
||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||
}
|
||
.wrap { max-width: 1120px; margin: 0 auto; }
|
||
.brand {
|
||
display: inline-flex; align-items: center; gap: 8px;
|
||
font-size: 12px; color: #6b7787; letter-spacing: .04em;
|
||
}
|
||
.brand i { width: 8px; height: 8px; border-radius: 50%; background: #409eff; display: inline-block; }
|
||
h1 { margin: 10px 0 6px; font-size: 26px; letter-spacing: -.02em; }
|
||
.sub { margin: 0; color: #7b8798; font-size: 13px; line-height: 1.7; }
|
||
.sub code { background: #e9edf5; padding: 1px 6px; border-radius: 4px; font-size: 12px; }
|
||
|
||
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; margin-top: 24px; }
|
||
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
|
||
|
||
.group { margin-bottom: 20px; }
|
||
.group-title {
|
||
margin: 0 0 10px;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
color: #8a94a6;
|
||
letter-spacing: .06em;
|
||
}
|
||
.grid-inner {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
|
||
gap: 14px;
|
||
}
|
||
.card {
|
||
position: relative;
|
||
display: flex; flex-direction: column; align-items: center;
|
||
padding: 20px 12px 14px;
|
||
background: #fff;
|
||
border: 1px solid #e6eaf2;
|
||
border-radius: 14px;
|
||
cursor: pointer;
|
||
transition: border-color .16s, box-shadow .16s, transform .16s;
|
||
text-align: center;
|
||
}
|
||
.card:hover { border-color: #b9c6da; box-shadow: 0 6px 18px rgba(31, 45, 61, .06); transform: translateY(-1px); }
|
||
.card.active { border-color: #409eff; box-shadow: 0 0 0 3px rgba(64, 158, 255, .14); }
|
||
.avatar {
|
||
width: 88px; height: 88px; border-radius: 50%;
|
||
background: #f1f4fa;
|
||
display: flex; align-items: center; justify-content: center;
|
||
}
|
||
.avatar img { width: 56px; height: 56px; display: block; }
|
||
.avatar.bg-avatar img { width: 72px; height: 72px; }
|
||
.name { margin-top: 14px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
|
||
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
|
||
.file { margin-top: 4px; font-size: 11px; color: #9aa4b5; }
|
||
.check {
|
||
position: absolute; top: 10px; right: 10px;
|
||
width: 20px; height: 20px; border-radius: 50%;
|
||
background: #409eff; color: #fff; font-size: 12px;
|
||
display: none; align-items: center; justify-content: center;
|
||
}
|
||
.card.active .check { display: flex; }
|
||
|
||
.panel {
|
||
position: sticky; top: 24px;
|
||
align-self: start;
|
||
background: #fff;
|
||
border: 1px solid #e6eaf2;
|
||
border-radius: 14px;
|
||
padding: 20px;
|
||
}
|
||
.panel h2 { margin: 0 0 16px; font-size: 14px; font-weight: 600; color: #55617a; }
|
||
.preview {
|
||
display: flex; align-items: center; justify-content: center;
|
||
width: 132px; height: 132px; margin: 0 auto;
|
||
border-radius: 50%; background: #f1f4fa;
|
||
}
|
||
.preview img { width: 84px; height: 84px; }
|
||
.empty { color: #a6afbf; font-size: 12px; }
|
||
.sel-name { margin-top: 14px; text-align: center; font-size: 15px; font-weight: 600; min-height: 22px; }
|
||
.sel-path { margin-top: 4px; text-align: center; font-size: 11px; color: #9aa4b5; word-break: break-all; }
|
||
.sizes { display: flex; justify-content: center; gap: 14px; margin-top: 16px; padding-top: 14px; border-top: 1px solid #eef1f6; }
|
||
.size { text-align: center; }
|
||
.size .box { display: flex; align-items: center; justify-content: center; background: #f1f4fa; border-radius: 50%; margin: 0 auto; }
|
||
.size .box.s48 { width: 44px; height: 44px; }
|
||
.size .box.s32 { width: 32px; height: 32px; }
|
||
.size .box img { width: 70%; height: 70%; }
|
||
.size span { display: block; margin-top: 6px; font-size: 10px; color: #9aa4b5; }
|
||
.actions { margin-top: 18px; display: grid; gap: 8px; }
|
||
button {
|
||
font: inherit; border-radius: 8px; padding: 9px 12px; cursor: pointer;
|
||
border: 1px solid #dfe5ef; background: #fff; color: #3d4a60; transition: all .15s;
|
||
}
|
||
button:hover:not(:disabled) { border-color: #b9c6da; background: #f7f9fd; }
|
||
button.primary { background: #409eff; border-color: #409eff; color: #fff; }
|
||
button.primary:hover:not(:disabled) { background: #2f8ff0; }
|
||
button:disabled { opacity: .5; cursor: not-allowed; }
|
||
.tip { margin-top: 18px; padding-top: 14px; border-top: 1px solid #eef1f6; font-size: 11px; color: #9aa4b5; line-height: 1.7; }
|
||
.toast {
|
||
position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%) translateY(10px);
|
||
background: rgba(31, 45, 61, .92); color: #fff; font-size: 13px;
|
||
padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: all .2s;
|
||
}
|
||
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="wrap">
|
||
<div class="brand"><i></i>ZHENOS · 头像素材选型</div>
|
||
<h1>默认头像选型</h1>
|
||
<p class="sub">
|
||
同一线框半身图形(Lucide <code>user</code>,ISC,可商用)的两种做法:<b>线框二十色</b>(仅描边变色)与 <b>彩色背景二十款</b>(渐变底 + 白色图标)。<br>
|
||
选好后把编号告诉我,我再接入个人中心;本页仅用于选型预览,不影响现有系统。
|
||
</p>
|
||
|
||
<div class="layout">
|
||
<div class="grid" id="grid"></div>
|
||
|
||
<aside class="panel">
|
||
<h2>当前选择</h2>
|
||
<div class="preview" id="preview"><span class="empty">尚未选择</span></div>
|
||
<div class="sel-name" id="selName">—</div>
|
||
<div class="sel-path" id="selPath">点击左侧卡片选择</div>
|
||
<div class="sizes">
|
||
<div class="size">
|
||
<div class="box s48"><img id="size48" alt="" src=""></div>
|
||
<span>48px</span>
|
||
</div>
|
||
<div class="size">
|
||
<div class="box s32"><img id="size32" alt="" src=""></div>
|
||
<span>32px</span>
|
||
</div>
|
||
</div>
|
||
<div class="actions">
|
||
<button class="primary" id="copyBtn" disabled>复制文件路径</button>
|
||
<button id="resetBtn" disabled>重新选择</button>
|
||
</div>
|
||
<div class="tip">
|
||
接入后会同步用于:个人中心、顶栏头像、评论区等默认头像位置。<br>
|
||
用户上传自定义头像不受影响。
|
||
</div>
|
||
</aside>
|
||
</div>
|
||
</div>
|
||
<div class="toast" id="toast"></div>
|
||
|
||
<script>
|
||
var AVATARS = [
|
||
{ file: 'avatar-line-01.svg', name: '墨蓝', color: '#3B5BDB', style: 'line' },
|
||
{ file: 'avatar-line-02.svg', name: '湖蓝', color: '#1C7ED6', style: 'line' },
|
||
{ file: 'avatar-line-03.svg', name: '青碧', color: '#0CA678', style: 'line' },
|
||
{ file: 'avatar-line-04.svg', name: '松绿', color: '#2F9E44', style: 'line' },
|
||
{ file: 'avatar-line-05.svg', name: '橄榄', color: '#74B816', style: 'line' },
|
||
{ file: 'avatar-line-06.svg', name: '琥珀', color: '#F08C00', style: 'line' },
|
||
{ file: 'avatar-line-07.svg', name: '珊瑚', color: '#E8590C', style: 'line' },
|
||
{ file: 'avatar-line-08.svg', name: '玫红', color: '#D6336C', style: 'line' },
|
||
{ file: 'avatar-line-09.svg', name: '紫罗兰', color: '#7048E8', style: 'line' },
|
||
{ file: 'avatar-line-10.svg', name: '石墨', color: '#495057', style: 'line' },
|
||
{ file: 'avatar-line-11.svg', name: '天青', color: '#1098AD', style: 'line' },
|
||
{ file: 'avatar-line-12.svg', name: '深青', color: '#0B7285', style: 'line' },
|
||
{ file: 'avatar-line-13.svg', name: '墨绿', color: '#087F5B', style: 'line' },
|
||
{ file: 'avatar-line-14.svg', name: '苔绿', color: '#5C940D', style: 'line' },
|
||
{ file: 'avatar-line-15.svg', name: '酒红', color: '#A61E4D', style: 'line' },
|
||
{ file: 'avatar-line-16.svg', name: '砖红', color: '#C92A2A', style: 'line' },
|
||
{ file: 'avatar-line-17.svg', name: '紫晶', color: '#9C36B5', style: 'line' },
|
||
{ file: 'avatar-line-18.svg', name: '蓝紫', color: '#5F3DC4', style: 'line' },
|
||
{ file: 'avatar-line-19.svg', name: '赭石', color: '#A0522D', style: 'line' },
|
||
{ file: 'avatar-line-20.svg', name: '玄黑', color: '#212529', style: 'line' },
|
||
{ file: 'avatar-bg-01.svg', name: '极光蓝紫', color: '#4C6EF5', style: 'bg' },
|
||
{ file: 'avatar-bg-02.svg', name: '晴空蓝', color: '#1C7ED6', style: 'bg' },
|
||
{ file: 'avatar-bg-03.svg', name: '青碧', color: '#0CA678', style: 'bg' },
|
||
{ file: 'avatar-bg-04.svg', name: '森野绿', color: '#2F9E44', style: 'bg' },
|
||
{ file: 'avatar-bg-05.svg', name: '落日橙', color: '#E8590C', style: 'bg' },
|
||
{ file: 'avatar-bg-06.svg', name: '莓果粉', color: '#D6336C', style: 'bg' },
|
||
{ file: 'avatar-bg-07.svg', name: '星云紫', color: '#7048E8', style: 'bg' },
|
||
{ file: 'avatar-bg-08.svg', name: '深海青', color: '#0B7285', style: 'bg' },
|
||
{ file: 'avatar-bg-09.svg', name: '石墨蓝', color: '#495057', style: 'bg' },
|
||
{ file: 'avatar-bg-10.svg', name: '赤陶红', color: '#C92A2A', style: 'bg' },
|
||
{ file: 'avatar-bg-11.svg', name: '紫藤', color: '#9C36B5', style: 'bg' },
|
||
{ file: 'avatar-bg-12.svg', name: '冰川青', color: '#1098AD', style: 'bg' },
|
||
{ file: 'avatar-bg-13.svg', name: '橄榄', color: '#5C940D', style: 'bg' },
|
||
{ file: 'avatar-bg-14.svg', name: '胭脂', color: '#A61E4D', style: 'bg' },
|
||
{ file: 'avatar-bg-15.svg', name: '海军蓝', color: '#3B5BDB', style: 'bg' },
|
||
{ file: 'avatar-bg-16.svg', name: '鸢尾紫', color: '#6D28D9', style: 'bg' },
|
||
{ file: 'avatar-bg-17.svg', name: '翡翠', color: '#087F5B', style: 'bg' },
|
||
{ file: 'avatar-bg-18.svg', name: '琥珀棕', color: '#B45309', style: 'bg' },
|
||
{ file: 'avatar-bg-19.svg', name: '午夜蓝', color: '#312E81', style: 'bg' },
|
||
{ file: 'avatar-bg-20.svg', name: '陨石灰', color: '#212529', style: 'bg' }
|
||
];
|
||
var STYLE_LABELS = { line: '线框半身 · 二十色', bg: '彩色背景 · 二十款' };
|
||
|
||
var selected = null;
|
||
var grid = document.getElementById('grid');
|
||
var toastTimer = null;
|
||
|
||
function pathOf(item) { return 'avatars/' + item.file; }
|
||
|
||
Object.keys(STYLE_LABELS).forEach(function (style) {
|
||
var list = AVATARS.map(function (item, index) { return { item: item, index: index }; })
|
||
.filter(function (entry) { return entry.item.style === style; });
|
||
if (!list.length) { return; }
|
||
|
||
var group = document.createElement('div');
|
||
group.className = 'group';
|
||
var title = document.createElement('div');
|
||
title.className = 'group-title';
|
||
title.textContent = STYLE_LABELS[style];
|
||
group.appendChild(title);
|
||
|
||
var inner = document.createElement('div');
|
||
inner.className = 'grid-inner';
|
||
list.forEach(function (entry) {
|
||
var item = entry.item;
|
||
var card = document.createElement('button');
|
||
card.type = 'button';
|
||
card.className = 'card';
|
||
card.innerHTML =
|
||
'<span class="check">✓</span>' +
|
||
'<span class="avatar' + (item.style === 'bg' ? ' bg-avatar' : '') + '"><img alt="' + item.name + '" src="' + pathOf(item) + '"></span>' +
|
||
'<span class="name"><i class="dot" style="background:' + item.color + '"></i>' + item.name + '</span>' +
|
||
'<span class="file">' + item.color + '</span>';
|
||
card.addEventListener('click', function () { select(entry.index); });
|
||
inner.appendChild(card);
|
||
});
|
||
group.appendChild(inner);
|
||
grid.appendChild(group);
|
||
});
|
||
|
||
function select(index) {
|
||
selected = AVATARS[index];
|
||
var cards = grid.querySelectorAll('.card');
|
||
for (var i = 0; i < cards.length; i++) {
|
||
cards[i].classList.toggle('active', i === index);
|
||
}
|
||
document.getElementById('preview').innerHTML =
|
||
'<img alt="' + selected.name + '" src="' + pathOf(selected) + '">';
|
||
document.getElementById('selName').textContent = selected.name + '(' + selected.color + ')';
|
||
document.getElementById('selPath').textContent = pathOf(selected);
|
||
document.getElementById('size48').src = pathOf(selected);
|
||
document.getElementById('size32').src = pathOf(selected);
|
||
document.getElementById('copyBtn').disabled = false;
|
||
document.getElementById('resetBtn').disabled = false;
|
||
}
|
||
|
||
function reset() {
|
||
selected = null;
|
||
var cards = grid.querySelectorAll('.card');
|
||
for (var i = 0; i < cards.length; i++) { cards[i].classList.remove('active'); }
|
||
document.getElementById('preview').innerHTML = '<span class="empty">尚未选择</span>';
|
||
document.getElementById('selName').textContent = '—';
|
||
document.getElementById('selPath').textContent = '点击左侧卡片选择';
|
||
document.getElementById('size48').removeAttribute('src');
|
||
document.getElementById('size32').removeAttribute('src');
|
||
document.getElementById('copyBtn').disabled = true;
|
||
document.getElementById('resetBtn').disabled = true;
|
||
}
|
||
|
||
function showToast(text) {
|
||
var toast = document.getElementById('toast');
|
||
toast.textContent = text;
|
||
toast.classList.add('show');
|
||
clearTimeout(toastTimer);
|
||
toastTimer = setTimeout(function () { toast.classList.remove('show'); }, 1600);
|
||
}
|
||
|
||
document.getElementById('resetBtn').addEventListener('click', reset);
|
||
document.getElementById('copyBtn').addEventListener('click', function () {
|
||
if (!selected) { return; }
|
||
var text = pathOf(selected);
|
||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||
navigator.clipboard.writeText(text).then(function () { showToast('已复制:' + text); });
|
||
} else {
|
||
var ta = document.createElement('textarea');
|
||
ta.value = text;
|
||
document.body.appendChild(ta);
|
||
ta.select();
|
||
document.execCommand('copy');
|
||
document.body.removeChild(ta);
|
||
showToast('已复制:' + text);
|
||
}
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|