lingjing/.next/static/chunks/5144a89350aa95f0.js

1 line
5.7 KiB
JavaScript

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,18566,(e,t,i)=>{t.exports=e.r(76562)},33919,e=>{"use strict";var t=e.i(43476),i=e.i(71645),n=e.i(18566);function s(){let e=(0,i.useRef)(null);return(0,i.useEffect)(()=>{let t,i=e.current,n=i.getContext("2d"),s=Array.from({length:180},()=>({x:Math.random()*window.innerWidth,y:Math.random()*window.innerHeight,z:Math.random()*window.innerWidth,pz:0})),a=()=>{i.width=window.innerWidth,i.height=window.innerHeight};a(),window.addEventListener("resize",a);let r=()=>{n.fillStyle="rgba(5,3,15,0.25)",n.fillRect(0,0,i.width,i.height),s.forEach(e=>{e.pz=e.z,e.z-=4,e.z<=0&&(e.x=Math.random()*i.width,e.y=Math.random()*i.height,e.z=i.width,e.pz=e.z);let t=(e.x-i.width/2)*(i.width/e.z)+i.width/2,s=(e.y-i.height/2)*(i.width/e.z)+i.height/2,a=(e.x-i.width/2)*(i.width/e.pz)+i.width/2,r=(e.y-i.height/2)*(i.width/e.pz)+i.height/2,l=Math.max(.3,(1-e.z/i.width)*2.5),o=1-e.z/i.width;n.strokeStyle=`rgba(200,190,255,${o})`,n.lineWidth=l,n.beginPath(),n.moveTo(a,r),n.lineTo(t,s),n.stroke()}),t=requestAnimationFrame(r)};return r(),()=>{cancelAnimationFrame(t),window.removeEventListener("resize",a)}},[]),(0,t.jsx)("canvas",{ref:e,className:"fixed inset-0 z-0",style:{background:"#05030f"}})}function a({text:e,visible:i,className:n=""}){return(0,t.jsx)("div",{className:`transition-all duration-1000 ${n}`,style:{opacity:+!!i,transform:i?"translateY(0)":"translateY(12px)"},children:e})}function r({onDone:e}){let[n,s]=(0,i.useState)(0);return(0,i.useEffect)(()=>{let e=[setTimeout(()=>s(1),600),setTimeout(()=>s(2),2200),setTimeout(()=>s(3),3e3),setTimeout(()=>s(4),4800),setTimeout(()=>s(5),5600)];return()=>e.forEach(clearTimeout)},[]),(0,t.jsxs)("div",{className:"relative z-10 flex h-screen h-dvh flex-col items-center justify-center px-8 text-center",children:[(0,t.jsx)(a,{text:"灵镜",visible:1===n||2===n,className:"text-5xl font-light tracking-[0.3em] text-white/90"}),(0,t.jsx)(a,{text:"一场温柔但有穿透力的对话",visible:3===n||4===n,className:"text-lg font-light tracking-widest text-white/60"}),(0,t.jsx)("div",{className:"transition-all duration-1000",style:{opacity:+(n>=5),transform:n>=5?"translateY(0)":"translateY(12px)"},children:(0,t.jsx)("button",{onClick:e,style:{color:"white",textDecoration:"underline",textUnderlineOffset:"4px",fontSize:"0.875rem",letterSpacing:"0.2em",background:"none",border:"none",cursor:"pointer"},children:"开始探索"})})]})}function l({question:e,onAnswer:n,questionIndex:s,total:a}){let[r,l]=(0,i.useState)(!1),[o,c]=(0,i.useState)(""),[d,h]=(0,i.useState)(!1),u=(0,i.useRef)(null);(0,i.useEffect)(()=>{l(!1),c(""),h(!1);let e=setTimeout(()=>{l(!0),setTimeout(()=>u.current?.focus(),600)},100);return()=>clearTimeout(e)},[e]);let m=()=>{o.trim()&&(h(!0),setTimeout(()=>n(o.trim()),800))};return(0,t.jsx)("div",{className:"chat-page relative z-10 flex h-screen h-dvh flex-col items-center justify-center px-8",children:(0,t.jsxs)("div",{className:"w-full max-w-md space-y-8",children:[(0,t.jsx)("div",{className:"text-center text-lg font-light leading-relaxed tracking-wide text-white/85 transition-all duration-700",style:{opacity:r&&!d?1:0,transform:r&&!d?"translateY(0)":d?"translateY(-16px)":"translateY(16px)"},children:e}),(0,t.jsxs)("div",{className:"transition-all duration-700",style:{opacity:r&&!d?1:0,transform:r&&!d?"translateY(0)":"translateY(16px)"},children:[(0,t.jsx)("textarea",{ref:u,rows:3,value:o,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),m())},placeholder:"输入你的回答,或输入 跳过",className:"w-full resize-none rounded-2xl border border-white/10 bg-white/5 px-5 py-4 text-sm text-white/80 placeholder-white/20 outline-none focus:border-white/25 transition-colors"}),(0,t.jsx)("div",{className:"mt-4 flex justify-center",children:(0,t.jsx)("button",{type:"button",onClick:m,disabled:!o.trim(),className:"continue-btn !text-white underline underline-offset-4 text-sm tracking-widest disabled:opacity-100",style:{color:"#fff",background:"none",border:"none",cursor:o.trim()?"pointer":"not-allowed",letterSpacing:"0.1em"},children:"继续 →"})})]})]})})}function o(){let[e,a]=(0,i.useState)("intro"),[o,c]=(0,i.useState)(""),[d,h]=(0,i.useState)(0),[u,m]=(0,i.useState)(30),[x,f]=(0,i.useState)(""),w=(0,n.useRouter)(),g=async()=>{a("loading");try{let e=await fetch("/api/session/new",{method:"POST"}),t=await e.json();f(t.sessionId),localStorage.setItem("lingjing_sid",t.sessionId),c(t.opening),h(1),m(t.total||30),a("chat")}catch{a("chat"),c("开始前,我想先简单认识你一下。就像朋友聊天,想到什么说什么就行,没有标准答案。咱们先从几个轻松的小问题开始,可以吗?"),h(1)}},p=async e=>{try{let t=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:x,answer:e})}),i=await t.json();if(i.done){a("done"),setTimeout(()=>w.push("/waiting"),1200);return}c(i.reply),h(e=>e+1)}catch{c("网络有点问题,我们继续。你刚才的回答我已经记住了。"),h(e=>e+1)}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s,{}),"intro"===e&&(0,t.jsx)(r,{onDone:g}),"loading"===e&&(0,t.jsx)("div",{className:"relative z-10 flex h-screen h-dvh items-center justify-center",children:(0,t.jsx)("div",{className:"text-sm tracking-widest text-white/30 animate-pulse",children:"正在连接..."})}),"chat"===e&&(0,t.jsx)(l,{question:o,onAnswer:p,questionIndex:d,total:u}),"done"===e&&(0,t.jsx)("div",{className:"relative z-10 flex h-screen h-dvh items-center justify-center",children:(0,t.jsx)("div",{className:"text-sm tracking-widest text-white/30 animate-pulse",children:"正在生成你的报告..."})})]})}e.s(["default",()=>o])}]);