chore: deploy 触发分支改 master,竞品调研/原型/色板/i18n/分享组件/文档等成果入库
This commit is contained in:
1 parent
5a97e6124e
commit
40e2342a02
75 files changed
+6848
-540
No files matched your search
+181
-64
@@ -49,9 +49,10 @@ input,textarea{font-family:inherit}
|
||||
.brand-mark{width:26px;height:26px;border-radius:6px;background:var(--accent);color:var(--text-primary);display:inline-flex;align-items:center;justify-content:center;font-weight:var(--weight-bold);font-size:14px}
|
||||
.nav-links{display:flex;align-items:center;gap:var(--space-4);margin-left:var(--space-3)}
|
||||
.nav-link{text-decoration:none;color:var(--text-secondary);font-size:var(--text-sm);font-weight:var(--weight-medium);padding:6px 2px;position:relative}
|
||||
.nav-link::after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--accent);border-radius:2px;transform:scaleX(0);transform-origin:left;transition:transform .28s cubic-bezier(.16,1,.3,1)}
|
||||
.nav-link:hover{color:var(--text-primary)}
|
||||
.nav-link.is-active{color:var(--text-primary);font-weight:var(--weight-bold)}
|
||||
.nav-link.is-active::after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--accent);border-radius:2px}
|
||||
.nav-link:hover::after,.nav-link.is-active::after{transform:scaleX(1)}
|
||||
.pro-tag{display:inline-block;background:var(--accent);color:var(--text-primary);font-size:10px;font-weight:var(--weight-bold);padding:1px 6px;border-radius:var(--radius-full);margin-left:6px;vertical-align:2px}
|
||||
.nav-spacer{flex:1}
|
||||
.nav-actions{display:flex;align-items:center;gap:var(--space-4)}
|
||||
@@ -204,7 +205,10 @@ canvas{display:block;max-width:100%;height:auto;border-radius:4px;background:#ff
|
||||
.mobile-cta{display:none;position:fixed;bottom:0;left:0;right:0;background:var(--bg-card);border-top:1px solid var(--border);padding:10px 16px calc(10px + env(safe-area-inset-bottom));z-index:40}
|
||||
|
||||
/* ── MODAL ── */
|
||||
.modal-mask{position:fixed;inset:0;background:rgba(23,23,19,.4);display:flex;align-items:center;justify-content:center;z-index:100;padding:16px}
|
||||
.modal-mask{position:fixed;inset:0;background:rgba(23,23,19,.4);display:flex;align-items:center;justify-content:center;z-index:100;padding:16px;opacity:0;visibility:hidden;transition:opacity .24s ease,visibility .24s}
|
||||
.modal-mask.is-visible{opacity:1;visibility:visible}
|
||||
.modal-mask .modal{transform:scale(.96) translateY(10px);opacity:0;transition:transform .28s cubic-bezier(.16,1,.3,1),opacity .28s ease}
|
||||
.modal-mask.is-visible .modal{transform:scale(1) translateY(0);opacity:1}
|
||||
.modal{background:var(--bg-card);border-radius:var(--radius-lg);box-shadow:var(--shadow-modal);width:100%;max-width:380px;padding:var(--space-5);position:relative;max-height:90vh;overflow:auto}
|
||||
.modal-close{position:absolute;top:12px;right:12px;width:32px;height:32px;border-radius:50%;font-size:18px;color:var(--text-tertiary);line-height:1}
|
||||
.modal-close:hover{background:var(--bg-subtle);color:var(--text-primary)}
|
||||
@@ -256,6 +260,40 @@ canvas{display:block;max-width:100%;height:auto;border-radius:4px;background:#ff
|
||||
.toast{position:fixed;left:50%;bottom:80px;transform:translateX(-50%) translateY(20px);background:var(--text-primary);color:#fff;font-size:var(--text-sm);padding:10px 18px;border-radius:var(--radius-full);opacity:0;transition:all .25s;z-index:200;pointer-events:none;max-width:90vw;text-align:center}
|
||||
.toast.is-show{opacity:1;transform:translateX(-50%) translateY(0)}
|
||||
|
||||
/* ── 微交互 · 动画系统(纯 CSS,零依赖) ── */
|
||||
button{position:relative;overflow:hidden}
|
||||
.btn-primary,.pass-btn,.redeem-btn,.download-btn,.quick-btn,.result-btn{transition:transform .12s ease,background .22s,border-color .22s,box-shadow .22s}
|
||||
.btn-primary:active,.pass-btn:active,.redeem-btn:active,.quick-btn:active{transform:translateY(1px)}
|
||||
.pass-card{transition:transform .25s cubic-bezier(.16,1,.3,1),box-shadow .25s}
|
||||
.pass-card:hover{transform:translateY(-3px);box-shadow:0 8px 24px rgba(23,23,19,.09)}
|
||||
.pass-card.is-featured:hover{transform:translateY(-3px);box-shadow:0 0 0 1px var(--accent),0 8px 24px rgba(237,176,69,.25)}
|
||||
|
||||
/* 按钮涟漪 */
|
||||
.ripple{position:absolute;border-radius:50%;background:rgba(255,255,255,.45);transform:scale(0);animation:ripple .62s ease-out forwards;pointer-events:none;z-index:1}
|
||||
@keyframes ripple{to{transform:scale(1);opacity:0}}
|
||||
|
||||
/* 图纸生成进度扫描(conic-gradient 旋转) */
|
||||
.gen-sweep{position:absolute;inset:0;z-index:3;pointer-events:none;overflow:hidden;border-radius:var(--radius-md);display:none}
|
||||
.gen-sweep.is-active{display:block}
|
||||
.gen-sweep::before{content:"";position:absolute;left:50%;top:50%;width:160%;height:160%;transform:translate(-50%,-50%);background:conic-gradient(from 0deg,rgba(237,176,69,0) 0deg,rgba(237,176,69,.5) 80deg,rgba(255,255,255,.92) 115deg,rgba(237,176,69,0) 150deg);animation:sweep .95s linear infinite}
|
||||
@keyframes sweep{to{transform:translate(-50%,-50%) rotate(360deg)}}
|
||||
|
||||
/* 备料清单行闪烁(颜色/数量变化时) */
|
||||
.inv-color-row.is-flash{animation:row-flash 1.1s ease-out}
|
||||
@keyframes row-flash{0%{background:rgba(237,176,69,.32)}100%{background:transparent}}
|
||||
|
||||
/* 下载成功勾勾 */
|
||||
.check-svg{width:15px;height:15px;stroke:currentColor;stroke-width:2.6;fill:none;stroke-linecap:round;stroke-linejoin:round;vertical-align:-2px;margin-right:6px}
|
||||
.check-svg polyline{stroke-dasharray:24;stroke-dashoffset:24;animation:check-draw .5s ease forwards .12s}
|
||||
@keyframes check-draw{to{stroke-dashoffset:0}}
|
||||
.download-btn.is-downloading{background:var(--success)}
|
||||
|
||||
/* 动效减弱偏好 */
|
||||
@media (prefers-reduced-motion:reduce){
|
||||
*,*::before,*::after{animation-duration:.001s!important;animation-iteration-count:1!important;transition-duration:.001s!important;scroll-behavior:auto!important}
|
||||
.gen-sweep,.preview-loading,.ripple{display:none!important}
|
||||
}
|
||||
|
||||
/* ── RESPONSIVE ── */
|
||||
@media (max-width:1023px){
|
||||
.workspace{grid-template-columns:320px 1fr}
|
||||
@@ -423,6 +461,7 @@ canvas{display:block;max-width:100%;height:auto;border-radius:4px;background:#ff
|
||||
<span class="spinner"></span>
|
||||
<span>图纸生成中…</span>
|
||||
</div>
|
||||
<div class="gen-sweep" id="genSweep"></div>
|
||||
<canvas id="previewCanvas"></canvas>
|
||||
</div>
|
||||
<div class="file-info">
|
||||
@@ -641,79 +680,115 @@ function generatePattern(gridSize, maxColors){
|
||||
return { cells: cells, palette: palette, totalBeads: cells.length, colorCount: palette.length, gridSize: gridSize };
|
||||
}
|
||||
|
||||
/* ── 画布渲染 ── */
|
||||
function renderCanvas(){
|
||||
if (!pattern) return;
|
||||
/* ── 画布渲染(拆分:底图 / 豆粒 / 网格,支持逐行揭示动画) ── */
|
||||
function canvasGeom(){
|
||||
var g = pattern.gridSize;
|
||||
var maxPx = 560;
|
||||
var cell = Math.max(3, Math.floor(maxPx / g));
|
||||
if (cell * g > 700) cell = Math.max(2, Math.floor(700 / g));
|
||||
var size = g * cell;
|
||||
// DPR 清晰度
|
||||
return { g: g, cell: cell, size: g * cell };
|
||||
}
|
||||
function prepareCanvas(){
|
||||
if (!pattern) return;
|
||||
var gm = canvasGeom();
|
||||
var dpr = Math.min(2, window.devicePixelRatio || 1);
|
||||
canvas.width = size * dpr; canvas.height = size * dpr;
|
||||
canvas.style.width = size + 'px'; canvas.style.height = size + 'px';
|
||||
canvas.width = gm.size * dpr; canvas.height = gm.size * dpr;
|
||||
canvas.style.width = gm.size + 'px'; canvas.style.height = gm.size + 'px';
|
||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
ctx.clearRect(0, 0, size, size);
|
||||
|
||||
// 底色
|
||||
ctx.fillStyle = '#f4f3ef'; ctx.fillRect(0, 0, size, size);
|
||||
|
||||
// 豆粒
|
||||
var r = cell * 0.42;
|
||||
for (var y = 0; y < g; y++){
|
||||
for (var x = 0; x < g; x++){
|
||||
var c = pattern.cells[y * g + x];
|
||||
ctx.clearRect(0, 0, gm.size, gm.size);
|
||||
ctx.fillStyle = '#f4f3ef'; ctx.fillRect(0, 0, gm.size, gm.size);
|
||||
}
|
||||
function drawBeadRows(rows){
|
||||
if (!pattern) return;
|
||||
var gm = canvasGeom();
|
||||
var r = gm.cell * 0.42;
|
||||
var n = Math.max(0, Math.min(rows, gm.g));
|
||||
for (var y = 0; y < n; y++){
|
||||
for (var x = 0; x < gm.g; x++){
|
||||
var c = pattern.cells[y * gm.g + x];
|
||||
ctx.beginPath();
|
||||
ctx.arc(x * cell + cell / 2, y * cell + cell / 2, r, 0, Math.PI * 2);
|
||||
ctx.arc(x * gm.cell + gm.cell / 2, y * gm.cell + gm.cell / 2, r, 0, Math.PI * 2);
|
||||
ctx.fillStyle = c.color; ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
// 网格线
|
||||
if (settings.showGrid){
|
||||
for (var i = 0; i <= g; i++){
|
||||
var strong = i % 10 === 0, medium = i % 5 === 0;
|
||||
ctx.strokeStyle = strong ? 'rgba(20,20,18,.55)' : (medium ? 'rgba(30,30,28,.35)' : 'rgba(30,30,28,.14)');
|
||||
ctx.lineWidth = strong ? 1.4 : (medium ? 1 : 0.6);
|
||||
ctx.beginPath(); ctx.moveTo(i * cell, 0); ctx.lineTo(i * cell, size); ctx.stroke();
|
||||
ctx.beginPath(); ctx.moveTo(0, i * cell); ctx.lineTo(size, i * cell); ctx.stroke();
|
||||
}
|
||||
// 每 10 格标号
|
||||
if (cell >= 8){
|
||||
ctx.font = 'bold ' + Math.max(9, Math.round(cell * 0.55)) + 'px system-ui, sans-serif';
|
||||
for (var j = 10; j < g; j += 10){
|
||||
ctx.fillStyle = 'rgba(20,20,18,.72)';
|
||||
ctx.fillText(String(j), j * cell + 2, 10);
|
||||
ctx.fillText(String(j), 2, j * cell + 10);
|
||||
}
|
||||
}
|
||||
function drawGridLines(){
|
||||
if (!pattern || !settings.showGrid) return;
|
||||
var gm = canvasGeom(), g = gm.g, cell = gm.cell, size = gm.size;
|
||||
for (var i = 0; i <= g; i++){
|
||||
var strong = i % 10 === 0, medium = i % 5 === 0;
|
||||
ctx.strokeStyle = strong ? 'rgba(20,20,18,.55)' : (medium ? 'rgba(30,30,28,.35)' : 'rgba(30,30,28,.14)');
|
||||
ctx.lineWidth = strong ? 1.4 : (medium ? 1 : 0.6);
|
||||
ctx.beginPath(); ctx.moveTo(i * cell, 0); ctx.lineTo(i * cell, size); ctx.stroke();
|
||||
ctx.beginPath(); ctx.moveTo(0, i * cell); ctx.lineTo(size, i * cell); ctx.stroke();
|
||||
}
|
||||
if (cell >= 8){
|
||||
ctx.font = 'bold ' + Math.max(9, Math.round(cell * 0.55)) + 'px system-ui, sans-serif';
|
||||
for (var j = 10; j < g; j += 10){
|
||||
ctx.fillStyle = 'rgba(20,20,18,.72)';
|
||||
ctx.fillText(String(j), j * cell + 2, 10);
|
||||
ctx.fillText(String(j), 2, j * cell + 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
function renderCanvas(){
|
||||
if (!pattern) return;
|
||||
prepareCanvas(); drawBeadRows(pattern.gridSize); drawGridLines();
|
||||
}
|
||||
/* 豆子逐行落下动画:rAF 渐进绘制,最终补齐网格线 */
|
||||
function renderCanvasStaggered(duration, cb){
|
||||
if (!pattern){ if (cb) cb(); return; }
|
||||
prepareCanvas();
|
||||
var g = pattern.gridSize;
|
||||
var start = null;
|
||||
var raf = window.requestAnimationFrame || function(f){ return setTimeout(function(){ f(Date.now()); }, 16); };
|
||||
function frame(t){
|
||||
if (start === null) start = t;
|
||||
var p = Math.min(1, (t - start) / duration);
|
||||
drawBeadRows(Math.floor(g * p));
|
||||
if (p < 1){ raf(frame); }
|
||||
else { drawBeadRows(g); drawGridLines(); if (cb) cb(); }
|
||||
}
|
||||
raf(frame);
|
||||
}
|
||||
|
||||
/* ── 统计更新 ── */
|
||||
function updateStats(){
|
||||
if (!pattern) return;
|
||||
$('heroBeads').textContent = fmt(pattern.totalBeads);
|
||||
$('heroColors').textContent = pattern.colorCount;
|
||||
$('useCount').textContent = fmt(pattern.totalBeads);
|
||||
var g = pattern.gridSize;
|
||||
$('fileSpec').textContent = g + ' × ' + g + ' · 实际使用 ' + fmt(pattern.totalBeads) + ' 颗';
|
||||
$('fileSpec').innerHTML = g + ' × ' + g + ' · 实际使用 <b id="useCount">' + fmt(pattern.totalBeads) + '</b> 颗';
|
||||
}
|
||||
|
||||
/* ── 重新生成 ── */
|
||||
function regenerate(showLoading){
|
||||
var doGen = function(){
|
||||
pattern = generatePattern(settings.gridSize, settings.maxColors);
|
||||
renderCanvas(); updateStats(); renderInventory();
|
||||
/* ── 重新生成(动画版:进度扫描 + 豆子逐行落下) ── */
|
||||
function regenerate(showLoading, opts){
|
||||
opts = opts || {};
|
||||
if (showLoading && generating) return;
|
||||
var sweep = $('genSweep');
|
||||
var done = function(){
|
||||
wrap.classList.remove('is-loading'); previewLoading.style.display = 'none';
|
||||
sweep.classList.remove('is-active');
|
||||
generating = false;
|
||||
if (opts.onDone) opts.onDone();
|
||||
};
|
||||
if (showLoading){
|
||||
generating = true;
|
||||
wrap.classList.add('is-loading'); previewLoading.style.display = 'flex';
|
||||
setTimeout(function(){ wrap.classList.remove('is-loading'); previewLoading.style.display = 'none'; doGen(); }, 650);
|
||||
} else doGen();
|
||||
if (opts.sweep) sweep.classList.add('is-active');
|
||||
setTimeout(function(){
|
||||
pattern = generatePattern(settings.gridSize, settings.maxColors);
|
||||
renderCanvasStaggered(opts.duration || 480, done);
|
||||
updateStats(); renderInventory();
|
||||
}, opts.delay || 600);
|
||||
} else {
|
||||
pattern = generatePattern(settings.gridSize, settings.maxColors);
|
||||
renderCanvas(); updateStats(); renderInventory();
|
||||
}
|
||||
}
|
||||
|
||||
/* ── MARD 备料清单渲染 ── */
|
||||
/* ── MARD 备料清单渲染(变化行闪烁高亮) ── */
|
||||
var lastInvRows = null;
|
||||
function renderInventory(){
|
||||
var body = $('invBody');
|
||||
if (redeemed && pattern){
|
||||
@@ -723,16 +798,27 @@ function renderInventory(){
|
||||
'<div class="inv-stat"><strong>' + fmt(pattern.totalBeads) + '</strong><span>实际总颗数</span></div>' +
|
||||
'<div class="inv-stat"><strong>' + pattern.colorCount + '</strong><span>使用颜色</span></div></div>';
|
||||
var rows = pattern.palette.slice(0, 10);
|
||||
var rowsData = [];
|
||||
for (var r = 0; r < rows.length; r++) rowsData.push(rows[r].hex + '|' + rows[r].count);
|
||||
var changed = null;
|
||||
if (lastInvRows){
|
||||
changed = {};
|
||||
var len = Math.max(lastInvRows.length, rowsData.length);
|
||||
for (var c = 0; c < len; c++) if (lastInvRows[c] !== rowsData[c]) changed[c] = true;
|
||||
}
|
||||
html += '<div>';
|
||||
for (var i = 0; i < rows.length; i++){
|
||||
html += '<div class="inv-color-row"><span class="inv-swatch" style="background:' + rows[i].hex + '"></span>' +
|
||||
var flash = (!lastInvRows || (changed && changed[i])) ? ' is-flash' : '';
|
||||
html += '<div class="inv-color-row' + flash + '"><span class="inv-swatch" style="background:' + rows[i].hex + '"></span>' +
|
||||
'<span class="inv-code">' + rows[i].hex + '</span><span class="inv-count">' + fmt(rows[i].count) + ' 颗</span></div>';
|
||||
}
|
||||
html += '</div>';
|
||||
html += '<p class="inv-extra">建议多备 10% · 约 <strong>' + fmt(Math.round(pattern.totalBeads * 1.1)) + '</strong> 颗</p>';
|
||||
body.innerHTML = html;
|
||||
lastInvRows = rowsData;
|
||||
} else {
|
||||
$('invTag').textContent = '🔒 受保护'; $('invTag').className = 'inv-lock-tag';
|
||||
lastInvRows = null;
|
||||
var locked = '';
|
||||
locked += '<div class="inv-stats"><div class="inv-stat"><strong>••••</strong><span>实际总颗数</span></div>' +
|
||||
'<div class="inv-stat"><strong>••</strong><span>使用颜色</span></div></div>';
|
||||
@@ -811,7 +897,7 @@ var gridSlider = $('gridSlider'), colorSlider = $('colorSlider');
|
||||
var regenTimer = null;
|
||||
function scheduleRegen(){
|
||||
clearTimeout(regenTimer);
|
||||
regenTimer = setTimeout(function(){ regenerate(true); }, 240);
|
||||
regenTimer = setTimeout(function(){ if (generating) return; regenerate(true, { duration: 320, delay: 360 }); }, 240);
|
||||
}
|
||||
function syncRangeFill(slider){
|
||||
var pct = ((slider.value - slider.min) / (slider.max - slider.min)) * 100;
|
||||
@@ -842,33 +928,64 @@ $('toggleGrid').addEventListener('click', function(){
|
||||
renderCanvas();
|
||||
});
|
||||
|
||||
/* ── 重新生成 ── */
|
||||
/* ── 重新生成(主按钮:完整扫描 + 豆子落下) ── */
|
||||
$('regenerateBtn').addEventListener('click', function(){
|
||||
if (generating) return;
|
||||
generating = true;
|
||||
wrap.classList.add('is-loading'); previewLoading.style.display = 'flex';
|
||||
setTimeout(function(){
|
||||
pattern = generatePattern(settings.gridSize, settings.maxColors);
|
||||
renderCanvas(); updateStats(); renderInventory();
|
||||
wrap.classList.remove('is-loading'); previewLoading.style.display = 'none';
|
||||
generating = false;
|
||||
toast('已生成 ' + settings.gridSize + ' × ' + settings.gridSize + ' 图纸');
|
||||
}, 750);
|
||||
regenerate(true, {
|
||||
sweep: true, duration: 560, delay: 550,
|
||||
onDone: function(){ toast('已生成 ' + settings.gridSize + ' × ' + settings.gridSize + ' 图纸'); }
|
||||
});
|
||||
});
|
||||
|
||||
/* ── 下载 ── */
|
||||
/* ── 下载(涟漪 + 成功勾勾) ── */
|
||||
function buttonSuccess(btn, label){
|
||||
if (btn.dataset.busy) return;
|
||||
btn.dataset.busy = '1';
|
||||
var orig = btn.innerHTML;
|
||||
btn.classList.add('is-downloading');
|
||||
btn.innerHTML = '<svg class="check-svg" viewBox="0 0 24 24" aria-hidden="true"><polyline points="4 12 10 18 20 6"/></svg><span>' + label + '</span>';
|
||||
setTimeout(function(){ btn.innerHTML = orig; btn.classList.remove('is-downloading'); delete btn.dataset.busy; }, 2000);
|
||||
}
|
||||
$('downloadBtn').addEventListener('click', function(){
|
||||
if (!redeemed){
|
||||
openModal('redeemMask');
|
||||
toast('请先输入兑换码解锁完整图纸');
|
||||
return;
|
||||
}
|
||||
buttonSuccess(this, '已下载 · 图纸开始生成');
|
||||
toast('图纸下载已开始(原型演示)');
|
||||
});
|
||||
|
||||
/* ── 弹窗系统 ── */
|
||||
function openModal(id){ $(id).style.display = 'flex'; document.body.style.overflow = 'hidden'; }
|
||||
function closeModal(id){ $(id).style.display = 'none'; document.body.style.overflow = ''; }
|
||||
/* ── 弹窗系统(scale + fade 过渡) ── */
|
||||
function openModal(id){
|
||||
var m = $(id);
|
||||
m.classList.add('is-open');
|
||||
m.style.display = 'flex';
|
||||
m.classList.add('is-visible');
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
function closeModal(id){
|
||||
var m = $(id);
|
||||
m.classList.remove('is-visible');
|
||||
setTimeout(function(){
|
||||
if (!m.classList.contains('is-visible')){ m.style.display = 'none'; m.classList.remove('is-open'); document.body.style.overflow = ''; }
|
||||
}, 260);
|
||||
}
|
||||
/* 全局涟漪反馈 */
|
||||
document.addEventListener('click', function(e){
|
||||
var b = e.target && e.target.closest ? e.target.closest('button') : null;
|
||||
if (!b || b.disabled || b.classList.contains('ripple-parent')) return;
|
||||
var rect = b.getBoundingClientRect();
|
||||
var d = Math.max(rect.width, rect.height) * 1.15;
|
||||
var r = document.createElement('span');
|
||||
r.className = 'ripple';
|
||||
r.style.width = r.style.height = d + 'px';
|
||||
r.style.left = (e.clientX - rect.left - d / 2) + 'px';
|
||||
r.style.top = (e.clientY - rect.top - d / 2) + 'px';
|
||||
b.appendChild(r);
|
||||
setTimeout(function(){ r.remove(); }, 700);
|
||||
});
|
||||
|
||||
document.querySelectorAll('.modal-mask').forEach(function(mask){
|
||||
mask.addEventListener('mousedown', function(e){ if (e.target === mask) closeModal(mask.id); });
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user