PageSourceSearch

https://slugish.ai/build/assets/remixedpun-YD1OroX8.js

js slugish.ai collected 2026-10-05 12:40:28 UTC 19,079 bytes, 38 lines download raw bytes

1import{u as we,r as n,j as e,H as Ne}from"./app-DP13319Q.js";import{F as m,h as ve,bt as re,k as W,bu as ke,bm as Ce,aw as Ee,$ as Se,_ as Ie,ae as $e,aU as Te}from"./index-CtyZ6W6U.js";import{M as ae}from"./react-tooltip.min-DW3XhwOj.js";/* empty css            */const Ae=`你是一位精通中英文雙關語的語言創意大師,專門設計「同音不同義」的諧音梗成語。
2
3核心規則:每個成語必須有至少一個字,與原成語中對應的字「同音(或近音)但字不同、義不同」,形成真正的諧音雙關。
4
5用戶輸入中文或英文詞語,產生「正好四個」創意幽默的四字諧音成語,每個須:
61. 諧音自真實中文成語(標明原成語)
72. 改換 1~2 字為同音近音但字義不同的字,且與輸入主題相關
83. 標出諧音梗(原字→換字,注音)
94. 一句幽默解釋,點出雙關妙處
10
11請只回傳以下 JSON 格式,不要任何前言或 markdown 代碼塊:
12[
13  {"pun":"四字諧音成語","original":"原成語","emoji":"emoji","homophones":"諧音說明,例如:甘→咖(ㄍㄚ)","explanation":"幽默解釋"},
14  {"pun":"...","original":"...","emoji":"...","homophones":"...","explanation":"..."},
15  {"pun":"...","original":"...","emoji":"...","homophones":"...","explanation":"..."},
16  {"pun":"...","original":"...","emoji":"...","homophones":"...","explanation":"..."}
17]`,Pe=["咖啡","ChatGPT","減肥","台灣","程式設計","愛情"],ne=[{bg:"#fff0f6",border:"#f9a8d4",text:"#9d174d",badge:"#fce7f3",badgeText:"#be185d"},{bg:"#eff6ff",border:"#93c5fd",text:"#1e40af",badge:"#dbeafe",badgeText:"#1d4ed8"},{bg:"#f0fdf4",border:"#86efac",text:"#166534",badge:"#dcfce7",badgeText:"#15803d"},{bg:"#fffbeb",border:"#fcd34d",text:"#92400e",badge:"#fef3c7",badgeText:"#b45309"}],oe=["🥇","🥈","🥉","4️⃣"],le="pun_hist",Re="0329",De="sk-6WgIud23PdYluNxmJp6laFlAuBCE0hfsX4PJvtBXuGcoiapI",Oe="https://api.moonshot.ai/v1/chat/completions",Me="kimi-k3",U={timeZone:"Asia/Taipei"};function O(l){return new Date(l).toLocaleDateString("zh-TW",{...U,year:"numeric",month:"2-digit",day:"2-digit"}).replace(/\//g,"-")}function He(l){return new Date(l).toLocaleTimeString("zh-TW",{...U,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function ie(l){return new Date(l).toLocaleTimeString("zh-TW",{...U,hour:"2-digit",hour12:!1}).slice(0,2)}function Y(l){const o=O(Date.now());if(l===o)return"今天";if(l===O(Date.now()-864e5))return"昨天";const[,g,c]=l.split("-");return`${g}/${c}`}function _e(l){const o={};return l.forEach(g=>{const c=ie(g.id);o[c]||(o[c]=[]),o[c].push(g)}),o}async function Le(l){try{const o=localStorage.getItem(l);return o?JSON.parse(o):null}catch{return null}}async function Je(l,o){try{localStorage.setItem(l,JSON.stringify(o))}catch{}}const Be=({title:l,onConfirm:o,onCancel:g,tooltips:c})=>{const[$,w]=n.useState(""),[M,T]=n.useState(!1),[H,_]=n.useState(!1),L=n.useRef(null);n.useEffect(()=>{setTimeout(()=>{var u;return(u=L.current)==null?void 0:u.focus()},50)},[]);const h=()=>{$===Re?o():(T(!0),_(!0),w(""),setTimeout(()=>T(!1),420))};return e.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4",children:e.jsxs("div",{className:"bg-[#235A72] border border-[#3a7a94] text-white p-6 rounded-lg shadow-lg w-80",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx(m,{icon:Te,className:"text-red-400 text-2xl mb-2"}),e.jsx("h3",{className:"text-lg font-bold",children:"刪除驗證"}),e.jsx("p",{className:"text-sm text-[#a8d0e6] mt-1",children:l})]}),e.jsx("input",{ref:L,type:"password",value:$,maxLength:8,onChange:u=>{w(u.target.value),_(!1)},onKeyDown:u=>u.key==="Enter"&&h(),placeholder:"輸入密碼",className:`w-full bg-gray-700 text-white py-2 px-4 rounded-md border focus:outline-none focus:ring-2 focus:ring-yellow-400 text-center tracking-widest ${H?"border-red-500":"border-gray-600"}`,style:{animation:M?"shake 0.4s ease":"none"}}),H&&e.jsx("p",{className:"text-red-400 text-xs mt-2 text-center",children:"密碼錯誤,請再試"}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsx("button",{onClick:g,className:"flex-1 bg-gray-600 text-white py-2 rounded-md hover:bg-gray-500 transition-colors",children:"取消"}),e.jsx("button",{onClick:h,className:"flex-1 bg-red-600 text-white py-2 rounded-md hover:bg-red-700 transition-colors",children:"確認刪除"})]}),e.jsx("style",{children:`
18          @keyframes shake {
19            0%, 100% { transform: translateX(0); }
20            25%, 75% { transform: translateX(-6px); }
21            50% { transform: translateX(6px); }
22          }
23        `})]})})},q=({label:l,onClick:o,tooltips:g})=>e.jsx("button",{onClick:c=>{c.stopPropagation(),o()},className:"text-xs px-2 py-0.5 rounded-md border border-red-500/50 bg-transparent text-red-400 hover:bg-red-500/20 transition-colors cursor-pointer opacity-75 hover:opacity-100",children:l});function Ge(){const{tooltips:l}=we().props||{},[o,g]=n.useState(""),[c,$]=n.useState(!1),[w,M]=n.useState(null),[T,H]=n.useState(""),[_,L]=n.useState(""),[h,u]=n.useState([]),[N,ce]=n.useState(!0),[A,P]=n.useState({}),[J,de]=n.useState(!1),[xe,K]=n.useState({}),[me,ge]=n.useState({}),[X,z]=n.useState(null),[Z,Q]=n.useState(""),[V,F]=n.useState(""),[j,he]=n.useState(!1),[ee,v]=n.useState("");n.useEffect(()=>{Le(le).then(t=>{t&&typeof t=="object"&&P(t),de(!0);const s=O(Date.now());t!=null&&t[s]&&K(r=>({...r,[s]:!0}))})},[]),n.useEffect(()=>{J&&Je(le,A)}
23,[A,J]);const ue=n.useCallback(t=>{const s=Date.now(),r=O(s),d={id:s,keyword:t,time:He(s)};P(a=>({...a,[r]:[d,...a[r]||[]]})),K(a=>({...a,[r]:!0}))},[]),R=async t=>{var r,d,a,B,x,p,k;const s=(t||o).trim();if(s){$(!0),H(""),M(null),u([]),L(s),F(""),v("");try{const f={model:Me,messages:[{role:"system",content:Ae},{role:"user",content:s}],max_tokens:4096,temperature:.6,top_p:.95,thinking:{type:"disabled"}};j&&v(`Request: ${JSON.stringify(f,null,2)}
24
25`);const i=await fetch(Oe,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${De}`},body:JSON.stringify(f)}),D=await i.json();if(j&&v(y=>y+`Response Status: ${i.status}
26Response Body: ${JSON.stringify(D,null,2)}
27
28`),!i.ok)throw new Error(((r=D.error)==null?void 0:r.message)||`API request failed: ${i.status}`);const C=(d=D.choices)==null?void 0:d[0];if(!C)throw new Error("API returned no choices in response");const E=((a=C.message)==null?void 0:a.content)||((B=C.delta)==null?void 0:B.content)||"";if(!E||E.trim().length===0){const y=((x=C.message)==null?void 0:x.reasoning_content)||((p=C.message)==null?void 0:p.reasoning)||"";y&&(console.error("Model returned reasoning content instead of content:",y),j&&v(I=>I+`⚠️ Reasoning Content (not used): ${y.substring(0,500)}...
29
30`));const b=(k=C.message)==null?void 0:k.refusal;throw b?new Error(`Model refused: ${b}`):new Error("API returned empty content. Try disabling thinking mode or increasing max_tokens.")}j&&v(y=>y+`Raw Content: ${E}
31
32`),console.log("Raw API response:",E);let S;try{S=JSON.parse(E)}catch{let b=E.replace(/```json\s*/gi,"").replace(/```\s*/gi,"").trim();if(!b.startsWith("[")){const I=b.match(/\[[\s\S]*\]/);I&&(b=I[0])}if(b.length===0)throw new Error("Content was empty after cleaning markdown");try{S=JSON.parse(b)}catch(I){throw new Error(`Failed to parse JSON: ${I.message}`)}}if(!Array.isArray(S))throw new Error("API response is not a JSON array");S.length!==4&&console.warn(`Expected 4 puns, got ${S.length}`),M(S),ue(s),Q("生成成功!"),setTimeout(()=>Q(""),3e3)}catch(f){console.error("Generation error:",f),F(f.message||"產生失敗,請再試一次。"),setTimeout(()=>F(""),5e3)}finally{$(!1)}}},pe=t=>{u(s=>s.includes(t)?s.filter(r=>r!==t):s.length>=4?s:[...s,t])},G=(t,s)=>{z({title:t,onConfirm:s})},fe=(t,s)=>{P(r=>{const d=(r[t]||[]).filter(a=>a.id!==s);if(!d.length){const a={...r};return delete a[t],a}return{...r,[t]:d}})},ye=(t,s)=>{P(r=>{const d=(r[t]||[]).filter(a=>ie(a.id)!==s);if(!d.length){const a={...r};return delete a[t],a}return{...r,[t]:d}})},be=t=>{P(s=>{const r={...s};return delete r[t],r})},te=Object.keys(A).sort((t,s)=>s.localeCompare(t)),je=O(Date.now()),se=Object.values(A).reduce((t,s)=>t+s.length,0);return e.jsxs(e.Fragment,{children:[e.jsxs(Ne,{children:[e.jsx("title",{children:"雙關語產生器 - AI 諧音梗成語生成"}),e.jsx("meta",{name:"description",content:"輸入詞語,AI 生成四字諧音成語,點擊排出你的最愛"})]}),e.jsx(ae,{id:"main-tooltip"}),e.jsx(ae,{id:"history-tooltip"}),X&&e.jsx(Be,{title:X.title,onConfirm:()=>{X.onConfirm(),z(null)},onCancel:()=>z(null),tooltips:l}),V&&e.jsxs("div",{className:"fixed top-20 right-4 bg-red-600 text-white px-4 py-2 rounded-md shadow-lg z-50 flex items-center gap-2",children:[e.jsx(m,{icon:ve,className:"text-white"}),V]}),Z&&e.jsxs("div",{className:"fixed top-20 right-4 bg-green-600 text-white px-4 py-2 rounded-md shadow-lg z-50 flex items-center gap-2",children:[e.jsx(m,{icon:re,className:"text-white"}),Z]}),e.jsx("main",{className:"min-h-screen bg-gradient-to-br from-gray-900 via-[#1a2a3a] to-gray-900 p-6",children:e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"text-5xl mb-3",children:"🀄"}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-white mb-2",children:"雙關語產生器"}),e.jsx("p",{className:"text-gray-400 text-sm",children:"輸入詞語,AI 生成四字諧音成語,點擊排出你的最愛"})]}),e.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm rounded-2xl p-6 border border-gray-700 mb-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsx("input",{type:"text",value:o,onChange:t=>g(t.target.value),onKeyDown:t=>t.key==="Enter"&&R(o),placeholder:"輸入詞語,例如:咖啡、AI、台灣…",className:"flex-1 bg-gray-700 text-white py-3 px-5 rounded-xl border border-gray-600 focus:outline-none focus:ring-2 focus:ring-yellow-400 focus:border-transparent transition-all","data-tooltip-id":"main-tooltip","data-tooltip-content":"輸入任何中文或英文詞語"}),e.jsx("button",{onClick:()=>R(o),disabled:!o.trim()||c,className:`px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2 transition-all ${o.trim()&&!c?"bg-gradient-to-r from-yellow-400 to-yellow-500 text-gray-900 hover:from-yellow-500 hover:to-yellow-600":"bg-gray-600 text-gray-400 cursor-not-allowed"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":c?"AI 思考中...":"生成諧音成語",children:c?e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:W,className:"animate-spin"}),"生成中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:re}),"生成"]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-4",children:[e.jsx("span",{className:"text-xs text-gray-500 self-center mr-1",children:"試試:"}),Pe.map(t=>e.jsx("button",{onClick:()=>{g(t),R(t)},className:"text-xs px-3 py-1.5 rounded-full border border-gray-600 bg-gray-700/50 text-gray-300 hover:bg-gray-700 hover:text-yellow-400 transition-colors",children:t},t))]}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t border-gray-700",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:j,onChange:t=>he(t.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-gray-700 text-yellow-400 focus:ring-yellow-400"}),e.jsx("span",{className:"text-xs text-gray-400",children:"除錯模式"}),e.jsx(m,{icon:ke,className:"text-gray-500 text-xs"})]}),j&&e.jsx("span",{className:"text-xs text-yellow-500",children:"開啟中 - 將顯示 API 原始回應"})]})]}),j&&ee&&e.jsxs("div",{className:"bg-gray-900/80 border border-yellow-500/30 rounded-xl p-4 mb-6 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-bold text-yellow-400 uppercase tracking-wider",children:"API 除錯資訊"}),e.jsx("button",{onClick:()=>v(""),className:"text-xs text-gray-500 hover:text-white",children:"清除"})]}),e.jsx("pre",{className:"text-xs text-green-400 font-mono whitespace-pre-wrap overflow-auto max-h-96",children:ee})]}),c&&e.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm rounded-2xl p-12 text-center border border-gray-700",children:[e.jsx("div",{className:"text-4xl mb-4",children:"🎭"}),e.jsxs("p",{className:"text-gray-400",children:["正在為「",e.jsx("span",{className:"text-yellow-400",children:_}),"」發揮創意..."]}),e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx(m,{icon:W,className:"animate-spin text-yellow-400 text-2xl"})})]}),T&&!c&&e.jsx("div",{className:"bg-red-900/30 border border-red-500/50 rounded-2xl p-6 text-center",children:e.jsx("p",{className:"text-red-400",children:T})}),w&&!c&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between bg-gray-800/30 backdrop-blur-sm rounded-xl p-3 border border-gray-700",children:[e.jsx("span",{className:"text-xs text-gray-400",children:h.length<4?`點擊卡片排名(已選 ${h.length}/4)`:"排名完成!再點可取消"}),h.length>0&&e.jsx("button",{onClick:()=>u([]),className:"text-xs px-3 py-1 rounded-full border border-gray-600 text-gray-400 hover:text-yellow-400 hover:border-yellow-400 transition-colors",children:"重置排名"})]}),h.length>0&&e.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm rounded-xl p-3 border border-gray-700 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500 mr-1",children:"🏆 排名:"}),h.map((t,s)=>{var r;return e.jsxs("span",{className:"text-sm text-white",children:[oe[s]," ",(r=w[t])==null?void 0:r.pun,s<h.length-1&&e.jsx(m,{icon:Ce,className:"text-gray-600 mx-1 text-xs"})]},t)})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:w.map((t,s)=>{const r=ne[s%ne.length],d=h.indexOf(s),a=d!==-1;return e.jsxs("div",{onClick:()=>
32pe(s),className:`cursor-pointer transition-all duration-300 rounded-xl p-5 ${a?"ring-2 ring-offset-2 ring-offset-gray-900":"hover:translate-y-[-2px]"} ${h.length===4&&!a?"opacity-60":"opacity-100"}`,style:{backgroundColor:r.bg,borderColor:a?r.text:r.border,borderWidth:a?"2px":"1px",borderStyle:"solid"},children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("div",{className:"text-3xl",children:t.emoji}),e.jsx("div",{className:"text-sm font-semibold",style:{color:r.text},children:a?oe[d]:"點擊排名"})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-baseline flex-wrap gap-2 mb-2",children:[e.jsx("span",{className:"text-xl font-bold",style:{color:r.text},children:t.pun}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{backgroundColor:r.badge,color:r.badgeText},children:["原:",t.original]})]}),e.jsxs("div",{className:"text-xs inline-block px-2 py-1 rounded-md mb-2",style:{backgroundColor:r.badge,color:r.badgeText},children:["🔊 ",t.homophones]}),e.jsx("p",{className:"text-sm",style:{color:r.text,opacity:.8},children:t.explanation})]})]},s)})}),e.jsx("div",{className:"text-center pt-4",children:e.jsx("button",{onClick:()=>R(o),className:"px-6 py-2 rounded-full border border-gray-600 text-gray-400 hover:text-yellow-400 hover:border-yellow-400 transition-colors text-sm",children:"↻ 再生成一組"})})]})]}),e.jsx("div",{className:`transition-all duration-300 ${N?"w-72":"w-12"}`,children:e.jsxs("div",{className:"sticky top-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[N&&e.jsxs("span",{className:"text-sm font-medium text-gray-400 flex items-center gap-2",children:[e.jsx(m,{icon:Ee}),"使用紀錄",se>0&&e.jsxs("span",{className:"text-xs text-gray-500",children:["(",se,")"]}),!J&&e.jsx(m,{icon:W,className:"animate-spin text-xs"})]}),e.jsx("button",{onClick:()=>ce(!N),className:"w-7 h-7 rounded-full bg-gray-700 flex items-center justify-center hover:bg-gray-600 transition-colors","data-tooltip-id":"history-tooltip","data-tooltip-content":N?"收起側邊欄":"展開側邊欄",children:e.jsx(m,{icon:N?Se:Ie,className:"text-gray-400 text-sm"})})]}),N&&e.jsx("div",{className:"bg-gray-800/50 backdrop-blur-sm rounded-xl border border-gray-700 overflow-hidden max-h-[calc(100vh-120px)] overflow-y-auto",children:J&&te.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-4xl mb-2",children:"📭"}),e.jsx("p",{className:"text-gray-500 text-sm",children:"尚無使用紀錄"})]}):e.jsx("div",{className:"divide-y divide-gray-700",children:te.map(t=>{const s=A[t]||[],r=t===je,d=!!xe[t],a=_e(s),B=Object.keys(a).sort((x,p)=>p.localeCompare(x));return e.jsxs("div",{className:"overflow-hidden",children:[e.jsxs("div",{className:`flex items-center justify-between p-3 cursor-pointer transition-colors ${r?"bg-yellow-500/10":"hover:bg-gray-700/50"}`,onClick:()=>K(x=>({...x,[t]:!x[t]})),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(m,{icon:$e,className:"text-yellow-400 text-xs"}),e.jsx("span",{className:`text-sm font-medium ${r?"text-yellow-400":"text-gray-300"}`,children:Y(t)}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",s.length,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{label:"刪當日",onClick:()=>G(`刪除「${Y(t)}」全部 ${s.length} 筆?`,()=>be(t))}),e.jsx("span",{className:"text-gray-500 text-xs",children:d?"▲":"▼"})]})]}),d&&B.map(x=>{const p=a[x],k=`${t}_${x}`,f=!!me[k];return e.jsxs("div",{className:"border-t border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center justify-between p-2 pl-6 cursor-pointer hover:bg-gray-700/30",onClick:()=>ge(i=>({...i,[k]:!i[k]})),children:[e.jsxs("span",{className:"text-xs text-gray-400",children:[x,":xx 時段 (",p.length,")"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{label:"刪此時",onClick:i=>{i.stopPropagation(),G(`刪除 ${Y(t)} ${x}:xx 時段共 ${p.length} 筆?`,()=>ye(t,x))}}),e.jsx("span",{className:"text-gray-500 text-xs",children:f?"▲":"▼"})]})]}),f&&e.jsx("div",{className:"pl-8 pb-1",children:p.map(i=>e.jsxs("div",{className:"flex items-center justify-between py-2 px-2 hover:bg-gray-700/30 rounded-lg cursor-pointer group",onClick:()=>{g(i.keyword),R(i.keyword)},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-white truncate",children:i.keyword}),e.jsx("p",{className:"text-xs text-gray-500",children:i.time})]}),e.jsx(q,{label:"刪",onClick:D=>{D.stopPropagation(),G(`刪除詞條「${i.keyword}」(${i.time})?`,()=>fe(t,i.id))}})]},i.id))})]},x)})]},t)})})})]})})]})})}),e.jsx("style",{children:`
33        @keyframes shake {
34          0%, 100% { transform: translateX(0); }
35          25%, 75% { transform: translateX(-6px); }
36          50% { transform: translateX(6px); }
37        }
38      `})]})}
38export{Ge 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.