This website requires JavaScript.
0
Issues
Pull Requests
Milestones
Explore
0
Create…
New Repository
New Migration
New Organization
public
Signed in as
public
Profile
Starred
Subscriptions
Settings
Help
Sign Out
public
/
jinzuanwork
Unwatch
1
Star
0
Fork
0
Code
Issues
Pull Requests
Actions
Packages
Projects
Releases
Wiki
Activity
Settings
Files
jinzuanwork
/
portal
/
assets
/
or
Cancel
Edit File
Preview
Preview Changes
Spaces
Tabs
2
4
8
Wrap
No wrap
/* 金钻客栈 · 全站交互(设计预览站原版,2026-10-06 搬进仓库):流动背景、手机「更多」、视差、卡片倾斜、滚动浮现、星尘、翻牌 */ (function () { 'use strict'; var reduce = window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches; var finePointer = window.matchMedia && matchMedia('(hover: hover) and (pointer: fine)').matches; document.documentElement.classList.add('js'); /* ---------- 整页动态背景:WebGL 流动渐变(低分辨率、30fps、标签页不可见时浏览器自动暂停) ---------- */ var mouseX = 0, mouseY = 0; (function glBackground() { var c = document.createElement('canvas'); c.className = 'bg-gl'; c.setAttribute('aria-hidden', 'true'); var gl = null; try { gl = c.getContext('webgl', { antialias: false, alpha: false, depth: false, stencil: false, powerPreference: 'low-power' }); } catch (e) {} if (!gl) return; var VS = 'attribute vec2 p;void main(){gl_Position=vec4(p,0.0,1.0);}'; var FS = [ 'precision mediump float;uniform vec2 uRes;uniform float uTime;uniform vec2 uMouse;uniform float uUni;uniform float uDark;', 'vec3 m289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec4 m289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}', 'vec4 perm(vec4 x){return m289(((x*34.0)+1.0)*x);}vec4 tis(vec4 r){return 1.79284291400159-0.85373472095314*r;}', 'float sn(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);', 'vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;', 'vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;', 'i=m289(i);vec4 p=perm(perm(perm(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));', 'float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);', 'vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);', 'vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;', 'vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);', 'vec4 nm=tis(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=nm.x;p1*=nm.y;p2*=nm.z;p3*=nm.w;', 'vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;', 'return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}', 'void main(){vec2 uv=gl_FragCoord.xy/uRes;vec2 q=vec2(uv.x*uRes.x/uRes.y,uv.y)*1.25+uMouse*0.09;float t=uTime*0.085;', 'float n1=sn(vec3(q*0.85,t));float n2=sn(vec3(q*1.4+vec2(3.1,1.7),t*1.25));float n3=sn(vec3(q*0.6-vec2(5.2,2.3),t*0.8));float n4=sn(vec3(q*1.1+vec2(-2.7,4.4),t*1.1));', 'vec3 pink=vec3(0.55,0.90,0.90);vec3 blue=vec3(0.58,0.72,1.0);vec3 mint=vec3(0.56,0.88,0.64);vec3 peach=vec3(1.0,0.86,0.48);vec3 lav=vec3(0.76,0.66,0.98);', 'vec3 col=mix(pink,blue,smoothstep(-0.55,0.55,n1));col=mix(col,mint,smoothstep(0.05,0.85,n2)*0.85);', 'col=mix(col,peach,smoothstep(0.15,0.9,n3)*0.75);col=mix(col,lav,smoothstep(0.2,0.95,n4)*0.7);col=mix(col,lav,0.28*uUni);', 'float w=0.74+0.14*sn(vec3(q*0.45,t*0.6));vec3 lite=mix(col,vec3(0.975,0.98,0.985),clamp(w,0.6,0.9));', /* 手机深色模式:同一团流动的彩光,压暗后往深蓝黑里混(uDark 0 → 1) */ 'vec3 dark=mix(col*0.34,vec3(0.05,0.06,0.12),clamp(w,0.6,0.9)*0.9);gl_FragColor=vec4(mix(lite,dark,uDark),1.0);}' ].join(''); function sh(type, src) { var o = gl.createShader(type); gl.shaderSource(o, src); gl.compileShader(o); return gl.getShaderParameter(o, gl.COMPILE_STATUS) ? o : null; } var v = sh(gl.VERTEX_SHADER, VS), f = sh(gl.FRAGMENT_SHADER, FS); if (!v || !f) return; var prog = gl.createProgram(); gl.attachShader(prog, v); gl.attachShader(prog, f); gl.linkProgram(prog); if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) return; gl.useProgram(prog); var buf = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, buf); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW); var loc = gl.getAttribLocation(prog, 'p'); gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0); var uRes = gl.getUniformLocation(prog, 'uRes'), uTime = gl.getUniformLocation(prog, 'uTime'), uMouse = gl.getUniformLocation(prog, 'uMouse'), uUni = gl.getUniformLocation(prog, 'uUni'), uDark = gl.getUniformLocation(prog, 'uDark'); /* 深色模式:只在手机宽度跟系统走(和 site.css 里那段一致);切换时实时换 */ var mqDark = window.matchMedia ? matchMedia('(max-width: 760px) and (prefers-color-scheme: dark)') : null; function setDark() { gl.uniform1f(uDark, mqDark && mqDark.matches ? 1 : 0); } setDark(); if (mqDark) { var onDark = function () { setDark(); draw(performance.now()); }; if (mqDark.addEventListener) mqDark.addEventListener('change', onDark); else if (mqDark.addListener) mqDark.addListener(onDark); } gl.uniform1f(uUni, document.body.classList.contains('uni') ? 1 : 0); document.body.insertBefore(c, document.body.firstChild); document.documentElement.classList.add('has-gl'); var scale = window.innerWidth < 760 ? 0.25 : 0.18, t0 = performance.now(), last = 0; function resize() { var w = Math.max(16, Math.round(window.innerWidth * scale)), h = Math.max(16, Math.round(window.innerHeight * scale)); c.width = w; c.height = h; gl.viewport(0, 0, w, h); gl.uniform2f(uRes, w, h); draw(performance.now()); } function draw(now) { gl.uniform1f(uTime, (now - t0) / 1000 + 20); gl.uniform2f(uMouse, mouseX, -mouseY); gl.drawArrays(gl.TRIANGLES, 0, 3); } function loop(now) { requestAnimationFrame(loop); if (now - last < 33) return; last = now; draw(now); } resize(); window.addEventListener('resize', function () { clearTimeout(c._rt); c._rt = setTimeout(resize, 150); }); if (!reduce) requestAnimationFrame(loop); })(); /* ---------- 手机:「更多」——底栏按钮开/关,底栏保持可点;返回键、点空白、Esc 都能收起 ---------- */ (function sheet() { var sh = document.getElementById('more'), btn = document.querySelector('[data-sheet="more"]'), bar = btn && btn.parentNode, pushed = false, timer; if (!sh || !btn) return; function isOpen() { return btn.getAttribute('aria-expanded') === 'true'; } function open(kb) { clearTimeout(timer); sh.hidden = false; btn.setAttribute('aria-expanded', 'true'); requestAnimationFrame(function () { requestAnimationFrame(function () { sh.classList.add('open'); }); }); if (kb) { var a = sh.querySelector('a'); if (a) a.focus(); } try { history.pushState({ jzMore: 1 }, ''); pushed = true; } catch (e) {} } function close(fromPop) { if (!isOpen()) return; sh.classList.remove('open'); btn.setAttribute('aria-expanded', 'false'); timer = setTimeout(function () { sh.hidden = true; }, reduce ? 0 : 240); if (pushed) { pushed = false; if (!fromPop) history.back(); } } btn.addEventListener('click', function (e) { if (isOpen()) close(); else open(e.detail === 0); }); sh.addEventListener('click', function (e) { if (e.target === sh) close(); }); window.addEventListener('popstate', function () { if (pushed) { pushed = false; close(true); } }); document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && isOpen()) { close(); btn.focus(); } }); /* 开着面板时点链接跳走:替换掉多出来的那条历史,免得返回时要按两次 */ document.addEventListener('click', function (e) { if (!pushed || e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return; var a = e.target.closest('a[href]'); if (!a || a.target === '_blank' || !(sh.contains(a) || bar.contains(a))) return; e.preventDefault(); location.replace(a.href); }); window.addEventListener('pageshow', function (e) { if (e.persisted && isOpen()) { pushed = false; sh.classList.remove('open'); sh.hidden = true; btn.setAttribute('aria-expanded', 'false'); } }); })(); /* ---------- 鼠标视差:背景彩光、首屏钻石跟着鼠标轻轻错位(只改 CSS 变量,GPU 合成) ---------- */ if (!reduce && finePointer) { var tx = 0, ty = 0, cx = 0, cy = 0, pr = 0, docEl = document.documentElement; window.addEventListener('pointermove', function (e) { tx = (e.clientX / window.innerWidth) * 2 - 1; ty = (e.clientY / window.innerHeight) * 2 - 1; mouseX = tx; mouseY = ty; if (!pr) pr = requestAnimationFrame(follow); }, { passive: true }); function follow() { cx += (tx - cx) * 0.08; cy += (ty - cy) * 0.08; docEl.style.setProperty('--mx', cx.toFixed(4)); docEl.style.setProperty('--my', cy.toFixed(4)); pr = (Math.abs(tx - cx) > 0.001 || Math.abs(ty - cy) > 0.001) ? requestAnimationFrame(follow) : 0; } } /* ---------- 卡片:随鼠标轻微倾斜 + 玻璃上跟着鼠标的柔光 ---------- */ if (!reduce && finePointer) { Array.prototype.forEach.call(document.querySelectorAll('.room, .tool, .path, .tpl, .art'), function (el) { el.classList.add('fx'); var raf = 0, lx = 0, ly = 0; el.addEventListener('pointermove', function (e) { var r = el.getBoundingClientRect(); lx = (e.clientX - r.left) / r.width; ly = (e.clientY - r.top) / r.height; if (raf) return; raf = requestAnimationFrame(function () { raf = 0; var max = el.classList.contains('big') ? 3 : 5; el.style.setProperty('--px', (lx * 100).toFixed(1) + '%'); el.style.setProperty('--py', (ly * 100).toFixed(1) + '%'); el.style.setProperty('--ry', ((lx - 0.5) * max * 2).toFixed(2) + 'deg'); el.style.setProperty('--rx', ((0.5 - ly) * max * 2).toFixed(2) + 'deg'); }); }); el.addEventListener('pointerenter', function () { el.classList.add('on'); }); el.addEventListener('pointerleave', function () { el.classList.remove('on'); el.style.setProperty('--rx', '0deg'); el.style.setProperty('--ry', '0deg'); }); }); } /* ---------- 滚动时内容依次浮现 ---------- */ if (!reduce && 'IntersectionObserver' in window) { var targets = document.querySelectorAll('.sec-h, .room, .desk, .board, .tool, .row-title, .disk, .uni-intro, .slots, .letter, .credit, .path, .pickup, .tpl, .pass, .art, .tools-bar'); var groups = new Map(); Array.prototype.forEach.call(targets, function (el) { var k = el.parentNode, n = groups.get(k) || 0; groups.set(k, n + 1); el.style.setProperty('--d', Math.min(n, 6) * 70 + 'ms'); el.classList.add('rv'); }); var rio = new IntersectionObserver(function (es) { es.forEach(function (e) { if (e.isIntersecting) { e.target.classList.add('in'); rio.unobserve(e.target); } }); }, { threshold: 0.08, rootMargin: '0px 0px -6% 0px' }); Array.prototype.forEach.call(targets, function (el) { rio.observe(el); }); } /* ---------- 配色切换(记在本机浏览器里;也可用 ?theme=dawn 直接打开某套) ---------- */ var root = document.documentElement; var listeners = []; function sparkPalette() { var v = getComputedStyle(root).getPropertyValue('--sparks').trim(); return v ? v.split(/\s+/) : ['#FFFFFF']; } function markTheme() { var cur = root.getAttribute('data-theme') || 'navy'; Array.prototype.forEach.call(document.querySelectorAll('[data-theme-btn]'), function (b) { b.setAttribute('aria-pressed', b.getAttribute('data-theme-btn') === cur ? 'true' : 'false'); }); } document.addEventListener('click', function (e) { var b = e.target.closest('[data-theme-btn]'); if (!b) return; var t = b.getAttribute('data-theme-btn'); root.setAttribute('data-theme', t); try { localStorage.setItem('jz-theme', t); } catch (err) {} markTheme(); listeners.forEach(function (fn) { fn(); }); }); markTheme(); /* ---------- 星尘:观景窗 / 宇宙背景里缓慢漂浮的光点 ---------- */ function stars(canvas) { var ctx = canvas.getContext('2d'); var dpr = Math.min(window.devicePixelRatio || 1, 2); var w = 0, h = 0, pts = [], raf = 0, visible = true; var density = +canvas.getAttribute('data-density') || 1; var PAL = sparkPalette(); listeners.push(function () { PAL = sparkPalette(); pts.forEach(function (p) { p.c = PAL[(Math.random() * PAL.length) | 0]; }); draw(performance.now()); }); function resize() { var r = canvas.getBoundingClientRect(); w = r.width; h = r.height; canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr); ctx.setTransform(dpr, 0, 0, dpr, 0, 0); var n = Math.round((w * h) / 5200 * density * (w < 600 ? 0.6 : 1)); pts = []; for (var i = 0; i < n; i++) { pts.push({ x: Math.random() * w, y: Math.random() * h, r: Math.random() < 0.85 ? Math.random() * 1.3 + 0.5 : Math.random() * 2 + 1.6, c: PAL[(Math.random() * PAL.length) | 0], a: Math.random() * 0.6 + 0.25, vx: (Math.random() - 0.5) * 0.12, vy: -(Math.random() * 0.16 + 0.03), tw: Math.random() * Math.PI * 2 }); } draw(0); } function draw(t) { ctx.clearRect(0, 0, w, h); for (var i = 0; i < pts.length; i++) { var p = pts[i]; if (!reduce) { p.x += p.vx; p.y += p.vy; if (p.y < -4) { p.y = h + 4; p.x = Math.random() * w; } if (p.x < -4) p.x = w + 4; else if (p.x > w + 4) p.x = -4; } var a = reduce ? p.a : p.a * (0.65 + 0.35 * Math.sin(t / 900 + p.tw)); ctx.globalAlpha = a; ctx.fillStyle = p.c; var sz = p.r > 1.9 ? 4 : (p.r > 1.1 ? 3 : 2); ctx.fillRect(Math.round(p.x), Math.round(p.y), sz, sz); } ctx.globalAlpha = 1; } function loop(t) { raf = requestAnimationFrame(loop); if (visible) draw(t); } resize(); window.addEventListener('resize', function () { clearTimeout(canvas._rt); canvas._rt = setTimeout(resize, 150); }); if ('IntersectionObserver' in window) { new IntersectionObserver(function (es) { visible = es[0].isIntersecting; }).observe(canvas); } if (!reduce) raf = requestAnimationFrame(loop); } Array.prototype.forEach.call(document.querySelectorAll('canvas.stars'), stars); /* ---------- 出发屏:进入视口时逐行翻牌 ---------- */ var rows = document.querySelectorAll('.flip'); function flipIn(list) { Array.prototype.forEach.call(list, function (el, i) { el.style.animationDelay = (i * 70) + 'ms'; el.classList.add('in'); }); } if (rows.length) { if (reduce || !('IntersectionObserver' in window)) { flipIn(rows); } else { var boards = document.querySelectorAll('.board'); var io = new IntersectionObserver(function (es) { es.forEach(function (e) { if (e.isIntersecting) { flipIn(e.target.querySelectorAll('.flip')); io.unobserve(e.target); } }); }, { threshold: 0.15 }); Array.prototype.forEach.call(boards, function (b) { io.observe(b); }); } } /* ---------- 画展:类型筛选 ---------- */ var seg = document.querySelector('[data-filter-group]'); if (seg) { seg.addEventListener('click', function (e) { var b = e.target.closest('button[data-f]'); if (!b) return; Array.prototype.forEach.call(seg.querySelectorAll('button'), function (x) { x.setAttribute('aria-pressed', x === b ? 'true' : 'false'); }); var f = b.getAttribute('data-f'); Array.prototype.forEach.call(document.querySelectorAll('.wall .art'), function (a) { a.hidden = !(f === 'all' || a.getAttribute('data-type') === f); }); }); } /* ---------- 画展:看大图(切到深色,突出作品) ---------- */ var lb = document.querySelector('.lb'); if (lb) { var img = lb.querySelector('img'), cap = lb.querySelector('.lb-cap'), closeBtn = lb.querySelector('button'); var last = null; document.addEventListener('click', function (e) { var t = e.target.closest('[data-full]'); if (!t) return; last = t; img.src = t.getAttribute('data-full'); img.alt = t.getAttribute('data-title') || ''; cap.textContent = t.getAttribute('data-title') || ''; lb.classList.add('open'); closeBtn.focus(); }); function close() { lb.classList.remove('open'); img.removeAttribute('src'); if (last) last.focus(); } closeBtn.addEventListener('click', close); lb.addEventListener('click', function (e) { if (e.target === lb) close(); }); document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && lb.classList.contains('open')) close(); }); } /* ---------- 手机:当前屋子滚进导航可视区 ---------- */ var cur = document.querySelector('.nav a[aria-current=page]'); if (cur && cur.scrollIntoView) { try { cur.scrollIntoView({ block: 'nearest', inline: 'center' }); } catch (e) {} } })();
Commit Changes
Add a Signed-off-by trailer by the committer at the end of the commit log message.
Commit directly to the
main
branch.
Create a
new branch
for this commit and start a pull request.
Commit Changes
Cancel