PageSourceSearch

https://shike-web.vercel.app/_nuxt/CqEJif98.js

js shike-web.vercel.app collected 2026-10-03 07:43:01 UTC 13,347 bytes, 1 lines download raw bytes

1import{_ as le}from"./AvDEdqDT.js";import{J as Q,al as C,aV as K,a8 as ae,aa as re,ab as m,B as w,y as o,d as R,am as P,a6 as k,a5 as H,aw as T,A as W,H as $,z,m as Y,aY as A,G as U,n as X,x as M,r as ie,c as Fe,aH as ce}from"./BRmlP7xU.js";import{u as ue}from"./BVT59sr3.js";import{_ as de}from"./C6IXV3VF.js";import{_ as ge}from"./Vt_RF1Q8.js";import{_ as fe}from"./Y4rNzQtG.js";import{h as be,i as me,j as xe}from"./CshGXoZE.js";import{u as ve}from"./DPoMep2H.js";import{u as pe}from"./X5ghqqtO.js";import"./BsvMOEaX.js";import"./D8Y2ukjb.js";import"./B8XgxyKV.js";import"./Bz5BUBp2.js";import"./D_j0JRW0.js";const Z="game-2048-best",ee="game-2048-theme";let ye=0;function he(e,t,s){return{id:++ye,value:e,row:t,col:s,isNew:!0,merged:!1,willMerge:!1,toRemove:!1}}function Be(e){const t=new Map;for(const s of e)t.set(`${s.row},${s.col}`,s);return t}function V(e){const t=[];for(let r=0;r<4;r++)for(let u=0;u<4;u++)e.get(`${r},${u}`)||t.push([r,u]);if(t.length===0)return null;const[s,i]=t[Math.floor(Math.random()*t.length)],l=he(Math.random()<.9?2:4,s,i);return e.set(`${s},${i}`,l),l}function q(e,t){return e>=0&&e<4&&t>=0&&t<4}function we(e){const t=[0,1,2,3],s=[0,1,2,3];return e.r===1&&t.reverse(),e.c===1&&s.reverse(),{r:t,c:s}}function _e(e){for(let t=0;t<4;t++)for(let s=0;s<4;s++){if(!e.get(`${t},${s}`))return!0;const i=e.get(`${t},${s}`);if(s<3){const l=e.get(`${t},${s+1}`);if(l&&l.value===i.value)return!0}if(t<3){const l=e.get(`${t+1},${s}`);if(l&&l.value===i.value)return!0}}return!1}function Ee(e){for(const t of e.values())if(t.value===2048)return!0;return!1}function J(){const e=new Map;V(e),V(e);const t=De();return{tiles:Array.from(e.values()),pendingTile:null,score:0,bestScore:t,isGameOver:!1,isWin:!1,keepPlaying:!1,moved:!1}}function Ce(e,t){if(e.isGameOver)return e;const s=e.tiles.map(c=>({...c,isNew:!1,merged:!1,willMerge:!1,toRemove:!1})),i=new Map;for(const c of s)i.set(`${c.row},${c.col}`,c);const r={up:{r:-1,c:0},down:{r:1,c:0},left:{r:0,c:-1},right:{r:0,c:1}}[t],u=we(r);let B=!1,D=0;for(const c of u.r)for(const g of u.c){const f=i.get(`${c},${g}`);if(!f)continue;let y=c,_=g,x=c+r.r,v=g+r.c;for(;q(x,v)&&!i.get(`${x},${v}`);)y=x,_=v,x+=r.r,v+=r.c;const h=q(x,v)?i.get(`${x},${v}`):void 0;h&&h.value===f.value&&!h.willMerge&&!h.toRemove?(f.row=x,f.col=v,f.toRemove=!0,h.willMerge=!0,i.delete(`${c},${g}`),i.set(`${x},${v}`,h),D+=h.value*2,B=!0):(y!==c||_!==g)&&(i.delete(`${c},${g}`),f.row=y,f.col=_,i.set(`${y},${_}`,f),B=!0)}if(!B)return{...e,moved:!1};const p=V(i),S=e.score+D,E=Math.max(S,e.bestScore);return E>e.bestScore&&Se(E),{tiles:s,pendingTile:p,score:S,bestScore:E,isGameOver:!1,isWin:!1,keepPlaying:e.keepPlaying,moved:!0}}function Te(e){let t=e.tiles.filter(r=>!r.toRemove).map(r=>r.willMerge?{...r,value:r.value*2,merged:!0,willMerge:!1}:{...r,merged:!1});e.pendingTile&&(t=[...t,e.pendingTile]);const s=Be(t),i=!_e(s),l=!e.keepPlaying&&Ee(s);return{...e,tiles:t,pendingTile:null,isGameOver:i,isWin:l}}function $e(e){return{...e,keepPlaying:!0,isWin:!1}}function ke(){try{return localStorage.getItem(ee)||"classic"}catch{}return"classic"}function Ae(e){localStorage.setItem(ee,e)}function De(){try{return parseInt(localStorage.getItem(Z)||"0",10)||0}catch{}return 0}function Se(e){localStorage.setItem(Z,e.toString())}const Me={class:"mx-auto max-w-md px-4 py-8"},Ge={class:"mb-5 flex items-start justify-between gap-3"},Oe={class:"flex flex-col items-end gap-2"},Re={class:"flex gap-1.5"},Pe=["title","onClick"],We={class:"mb-4 flex justify-center gap-4"},ze={class:"rounded-2xl px-6 py-3 text-center shadow-inner",style:{background:"var(--score-bg)",color:"var(--score-text)"}},Ve={class:"text-3xl font-bold"},Ie={class:"rounded-2xl px-6 py-3 text-center shadow-inner",style:{background:"var(--score-bg)",color:"var(--score-text)"}},Le={class:"text-3xl font-bold opacity-90"},Ne={class:"tile-value"},je={key:0,class:"tile-face"},Ke={key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm"},He={class:"mx-4 w-full max-w-sm rounded-3xl bg-white p-8 text-center shadow-2xl ring-1 ring-slate-200"},Ye={class:"mb-6 text-slate-600"},Ue={class:"font-bold text-amber-500"},Xe={key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm"},qe={class:"mx-4 w-full max-w-sm rounded-3xl bg-white p-8 text-center shadow-2xl ring-1 ring-slate-200"},Je={class:"mb-6 text-slate-600"},Qe={class:"font-bold text-amber-500"},Ze=130,et=Q({__name:"Game2048View",setup(e){const t={classic:{name:"经典",cardBg:"#FAF8EF",boardBg:"#BBADA0",emptyBg:"#CDC1B4",title:"#776E65",scoreBg:"#BBADA0",scoreText:"#FFFFFF",btnBg:"#8F7A66",btnText:"#F9F6F2",tiles:{2
1:{bg:"#EEE4DA",text:"#776E65"},4:{bg:"#EDE0C8",text:"#776E65"},8:{bg:"#F2B179",text:"#F9F6F2"},16:{bg:"#F59563",text:"#F9F6F2"},32:{bg:"#F67C5F",text:"#F9F6F2"},64:{bg:"#F65E3B",text:"#F9F6F2"},128:{bg:"#EDCF72",text:"#F9F6F2"},256:{bg:"#EDCC61",text:"#F9F6F2"},512:{bg:"#EDC850",text:"#F9F6F2"},1024:{bg:"#EDC53F",text:"#F9F6F2"},2048:{bg:"#EDC22E",text:"#F9F6F2"},4096:{bg:"#3C3A32",text:"#F9F6F2"}}},ocean:{name:"海洋蓝",cardBg:"linear-gradient(135deg, #5BC0FF, #7B5CEB)",boardBg:"#4A9EFF",emptyBg:"#C7E0FF",title:"#FFFFFF",scoreBg:"#4A9EFF",scoreText:"#FFFFFF",btnBg:"#4A9EFF",btnText:"#FFFFFF",tiles:{2:{bg:"#DBEAFF",text:"#1A56C4"},4:{bg:"#A5CCFF",text:"#1A56C4"},8:{bg:"#7BB8FF",text:"#FFFFFF"},16:{bg:"#3B8BDB",text:"#FFFFFF"},32:{bg:"#2563EB",text:"#FFFFFF"},64:{bg:"#7B5CEB",text:"#FFFFFF"},128:{bg:"#6B4DDB",text:"#FFFFFF"},256:{bg:"#5B3ECB",text:"#FFFFFF"},512:{bg:"#4B2FBB",text:"#FFFFFF"},1024:{bg:"#3B1FAB",text:"#FFFFFF"},2048:{bg:"#2B0F8B",text:"#FFFFFF"},4096:{bg:"#1B0F7B",text:"#FFFFFF"}}},candy:{name:"糖果",cardBg:"linear-gradient(135deg, #FFB347, #FF6B9D)",boardBg:"#F06292",emptyBg:"#FCE4EC",title:"#FFFFFF",scoreBg:"#FF6B9D",scoreText:"#FFFFFF",btnBg:"#FF6B9D",btnText:"#FFFFFF",tiles:{2:{bg:"#FFF8E1",text:"#C44569"},4:{bg:"#FFE082",text:"#C44569"},8:{bg:"#FFCA28",text:"#FFFFFF"},16:{bg:"#FFA726",text:"#FFFFFF"},32:{bg:"#FF7043",text:"#FFFFFF"},64:{bg:"#EF5350",text:"#FFFFFF"},128:{bg:"#EC407A",text:"#FFFFFF"},256:{bg:"#D81B60",text:"#FFFFFF"},512:{bg:"#AD1457",text:"#FFFFFF"},1024:{bg:"#7CB342",text:"#FFFFFF"},2048:{bg:"#FBC02D",text:"#FFFFFF"},4096:{bg:"#5D4037",text:"#FFFFFF"}}},cartoon:{name:"卡通",cardBg:"linear-gradient(135deg, #FFD54F, #FFAB91)",boardBg:"#FF8A65",emptyBg:"#FFD4C4",title:"#5D4037",scoreBg:"#FF7043",scoreText:"#FFFFFF",btnBg:"#FF7043",btnText:"#FFFFFF",cartoon:!0,tiles:{2:{bg:"#FFF3E0",text:"#5D4037"},4:{bg:"#FFE0B2",text:"#5D4037"},8:{bg:"#FFCC80",text:"#5D4037"},16:{bg:"#FFB74D",text:"#FFFFFF"},32:{bg:"#FF7043",text:"#FFFFFF"},64:{bg:"#EC407A",text:"#FFFFFF"},128:{bg:"#AB47BC",text:"#FFFFFF"},256:{bg:"#7E57C2",text:"#FFFFFF"},512:{bg:"#5C6BC0",text:"#FFFFFF"},1024:{bg:"#42A5F5",text:"#FFFFFF"},2048:{bg:"#26A69A",text:"#FFFFFF"},4096:{bg:"#66BB6A",text:"#FFFFFF"}}}},s=["classic","ocean","candy","cartoon"],i=["目标:合并数字凑出 2048","上下左右滑动,所有方块向该方向移动","两个相同数字相撞会合并为它们的和","每次移动后随机生成一个新数字(2或4)","无法移动时游戏结束"],l=C(J()),r=C(!1),u=C(!1),B=ke(),D=s.includes(B)?B:"classic",p=C(D),{fireLarge:S}=ue(),E=M(()=>!!t[p.value].cartoon);K(()=>l.value.isWin,a=>{a&&S()}),K(p,a=>{Ae(a)},{immediate:!1});const c=M(()=>({background:t[p.value].cardBg})),g=C(null),f=C(0);let y=null;function _(){g.value&&(f.value=g.value.clientWidth)}const x=M(()=>{const a=f.value||320,n=a*.03,d=a*.025,F=(a-2*n-3*d)/4,b=t[p.value];return{"--cell":`${F}px`,"--gap":`${d}px`,"--pad":`${n}px`,"--board-bg":b.boardBg,"--empty-bg":b.emptyBg,"--title":b.title,"--score-bg":b.scoreBg,"--score-text":b.scoreText,"--btn-bg":b.btnBg,"--btn-text":b.btnText}});function v(a){return{width:"var(--cell)",height:"var(--cell)",transform:`translate(calc(var(--pad) + ${a.col} * (var(--cell) + var(--gap))), calc(var(--pad) + ${a.row} * (var(--cell) + var(--gap))))`}}function h(a){const n=t[p.value],d=n.tiles[a.value]??n.tiles[4096];return{background:d.bg,color:d.text}}const I=["😀","😎","🤩","😺","🐱","🐶","🦊","🐼","🦁","🐯","🐸","🐵"];function te(a){const n=Math.max(0,Math.min(I.length-1,Math.log2(a)-1));return I[n]}function G(a){if(r.value)return;const n=Ce(l.value,a);n.moved&&(r.value=!0,l.value=n,window.setTimeout(()=>{l.value=Te(l.value),r.value=!1},Ze))}function O(){l.value=J(),r.value=!1}function oe(){l.value=$e(l.value)}function L(a){const d={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",w:"up",s:"down",a:"left",d:"right"}[a.key];d&&(a.preventDefault(),G(d))}let N=0,j=0;function ne(a){N=a.touches[0].clientX,j=a.touches[0].clientY}function se(a){const n=a.changedTouches[0].clientX-N,d=a.changedTouches[0].clientY-j,F=Math.abs(n),b=Math.abs(d);Math.max(F,b)<30||(F>b?G(n>0?"right":"left"):G(d>0?"down":"up"))}return ae(()=>{_(),g.value&&typeof ResizeObserver<"u"&&(y=new ResizeObserver(_),y.observe(g.value)),window.addEventListener("keydown",L)}),re(()=>{window.removeEventListener("keydown",L),y&&y.disconnect()}),(a,n)=>{const d=le;return m(),w("div",Me,[o("div",{class:"overflow-hidden rounded-3xl p-6 shadow-2xl",style:k(c.value)},[o("div",Ge,[n[2]||(n[2]=o("div",null,[o("h1",{class:"text-3xl font-bold",style:{color:"var(--title)"}},"2048"),o("p",{class:"mt-1 text-sm opacity-70",style:{color:"var(--title)"}}," 合并数字,挑战最高分 ")],-1)),o("div",Oe,[o("button",{type:"button",class:"rounded-full px-3 py-1.5 text-xs font-medium shadow transition-all hover:scale-105 active:scale-95",style:{background:"var(--btn-bg)",color:"var(--btn-text)"},onClick:n[0]||(n[0]=F=>u.value=!0)}," 📖 玩法介绍 "),o("div",Re,[(m(),w(R,null,P(s,F=>
1o("button",{key:F,type:"button",title:t[F].name,class:H(["h-6 w-6 rounded-full border-2 transition-all",p.value===F?"scale-110 border-white shadow":"border-transparent opacity-70 hover:opacity-100"]),style:k({background:t[F].cardBg}),onClick:b=>p.value=F},null,14,Pe)),64))])])]),o("div",We,[o("div",ze,[n[3]||(n[3]=o("p",{class:"text-xs opacity-80"},"分数",-1)),o("p",Ve,T(l.value.score),1)]),o("div",Ie,[n[4]||(n[4]=o("p",{class:"text-xs opacity-80"},"最高",-1)),o("p",Le,T(l.value.bestScore),1)])]),o("div",{ref_key:"boardOuter",ref:g,class:"mb-4 rounded-2xl p-0 shadow-inner",style:{background:"var(--board-bg)"},onTouchstart:ne,onTouchend:se},[o("div",{class:"relative aspect-square w-full",style:k(x.value)},[(m(),w(R,null,P(16,F=>o("div",{key:`slot-${F}`,class:"slot",style:{background:"var(--empty-bg)"}})),64)),(m(!0),w(R,null,P(l.value.tiles,F=>(m(),w("div",{key:F.id,class:"tile",style:k(v(F))},[o("div",{class:H(["tile-inner",{"tile-spawn":F.isNew,cartoon:E.value}]),style:k(h(F))},[o("span",Ne,T(F.value),1),E.value?(m(),w("span",je,T(te(F.value)),1)):W("",!0)],6)],4))),128))],4)],544),o("div",{class:"mb-4 flex justify-center"},[o("button",{type:"button",class:"rounded-full px-8 py-3 font-bold shadow-lg transition-all hover:scale-105 hover:shadow-xl active:scale-95",style:{background:"var(--btn-bg)",color:"var(--btn-text)"},onClick:O}," 🔄 新游戏 ")]),n[5]||(n[5]=o("div",{class:"text-center text-sm opacity-70",style:{color:"var(--title)"}},[o("p",null,"⬆️⬇️⬅️➡️ 方向键 · WASD 移动"),o("p",{class:"mt-1"},"📱 移动端支持触摸滑动")],-1))],4),$(d,{open:u.value,"onUpdate:open":n[1]||(n[1]=F=>u.value=F),title:"玩法介绍",rules:i},null,8,["open"]),(m(),z(Y,{to:"body"},[$(X,{name:"fade"},{default:A(()=>[l.value.isWin?(m(),w("div",Ke,[o("div",He,[n[7]||(n[7]=o("div",{class:"mb-4 text-6xl animate-bounce"},"🏆",-1)),n[8]||(n[8]=o("h2",{class:"mb-2 text-2xl font-bold text-slate-900"},"恭喜达到 2048!",-1)),o("p",Ye,[n[6]||(n[6]=U(" 当前分数:",-1)),o("span",Ue,T(l.value.score),1)]),o("div",{class:"flex justify-center gap-3"},[o("button",{type:"button",class:"rounded-full bg-slate-100 px-6 py-3 font-medium text-slate-700 transition-all hover:bg-slate-200 active:scale-95",onClick:O}," 新游戏 "),o("button",{type:"button",class:"rounded-full bg-amber-500 px-6 py-3 font-bold text-white shadow-md transition-all hover:scale-105 active:scale-95",onClick:oe}," 继续挑战 ")])])])):W("",!0)]),_:1})])),(m(),z(Y,{to:"body"},[$(X,{name:"fade"},{default:A(()=>[l.value.isGameOver?(m(),w("div",Xe,[o("div",qe,[n[10]||(n[10]=o("div",{class:"mb-4 text-6xl"},"😵",-1)),n[11]||(n[11]=o("h2",{class:"mb-2 text-2xl font-bold text-slate-900"},"游戏结束",-1)),o("p",Je,[n[9]||(n[9]=U(" 最终分数:",-1)),o("span",Qe,T(l.value.score),1)]),o("button",{type:"button",class:"rounded-full bg-amber-500 px-8 py-3 font-bold text-white shadow-md transition-all hover:scale-105 active:scale-95",onClick:O}," 再来一局 ")])])):W("",!0)]),_:1})]))])}}}),tt=ie(et,[["__scopeId","data-v-cd4fca4f"]]),mt=Q({__name:"index",setup(e){const t=Fe["game/2048"];return ve("fun","game/2048"),pe(M(()=>({title:xe(t),description:me(t),path:"/fun/game/2048",keywords:be(t),ogType:"article"}))),ce({meta:[{name:"theme-color",content:"#f59e0b"}]}),(s,i)=>{const l=tt,r=de,u=ge,B=fe;return m(),z(B,{width:"main",compact:""},{default:A(()=>[$(r,null,{fallback:A(()=>[...i[0]||(i[0]=[o("div",{class:"py-24 text-center text-sm text-slate-500"},"加载中...",-1)])]),default:A(()=>[$(l)]),_:1}),$(u,{kind:"fun",slug:"game/2048"})]),_:1})}}});
1export{mt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.