Files
wecom_it_smart_desk/deploy-server/tmp/h5-main-part3.bin
T

6 lines
97 KiB
Plaintext
Raw Normal View History

osError:DE,CanceledError:$E,isCancel:NE,CancelToken:LE,VERSION:ME,all:VE,Cancel:jE,isAxiosError:UE,spread:HE,toFormData:qE,AxiosHeaders:zE,HttpStatusCode:WE,formToJSON:KE,getAdapter:GE,mergeConfig:JE,create:XE}=Me;let ai=null;function Vy(e){ai=e}async function jy(){return ai?(await ai(),!0):!1}const $e=Me.create({baseURL:"/api",timeout:2e4,headers:{"Content-Type":"application/json"}});$e.interceptors.request.use(e=>{const t=localStorage.getItem("h5_token");return t&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e));$e.interceptors.response.use(e=>{const t=e.data;return t.code!==0?t.code===1002?(Ia("biz1002"),Promise.reject({code:1002,message:t.message||"未授权"})):(ve(t.message||"请求失败"),Promise.reject({code:t.code,message:t.message||"请求失败"})):t.data},async e=>{let t="网络异常,请稍后重试",n=-1;if(e.response)switch(n=e.response.status,e.response.status){case 401:await Ia("http401");break;case 403:t="拒绝访问";break;case 404:t="请求的资源不存在";break;case 500:t="服务器内部错误";break;default:t=`请求失败 (${e.response.status})`}else e.code==="ECONNABORTED"&&(t="请求超时,请稍后重试");return n!==401&&ve(t),Promise.reject({code:n,message:t})});const Uy="oauth_redirect_count",Pa=3;let ps=null;async function Ia(e){const t=e==="http401"?"HTTP 401":"业务码 1002";return ps?(console.warn(`[API] ${t} 未授权 — 已有处理进行中,等待完成`),ps):(console.warn(`[API] ${t} 未授权,清除凭证并跳转登录`),ps=(async()=>{try{if(localStorage.removeItem("h5_token"),localStorage.removeItem("employee_id"),localStorage.removeItem("employee_name"),"wwa8c87970b2011f41"){const s=parseInt(localStorage.getItem(Uy)||"0",10);if(s>=Pa){console.error("[API] OAuth2 重定向次数超限,疑似无限循环,停止重定向"),ve("登录状态异常,请刷新页面重试");return}console.warn(`[API] OAuth2 重定向计数: ${s}/${Pa}`),await jy()||(console.warn("[API] 认证过期处理器未注册,降级为刷新页面"),window.location.reload())}}catch(n){console.warn("[API] 401 处理失败,刷新页面:",n),window.location.reload()}finally{ps=null}})(),ps)}function ci(e){return{message_id:e.id||e.message_id||"",conversation_id:e.conversation_id||"",message_type:e.sender_type||e.message_type||"text",msg_type:e.msg_type,content:e.content||"",sender_name:e.sender_name||"",created_at:e.created_at||"",media_url:e.media_url,file_name:e.file_name,file_size:e.file_size,extra_data:e.extra_data,reply_to_id:e.reply_to_id}}function Df(e){return(e||[]).map(ci)}async function Hy(){return await $e.get("/h5/user")}async function qy(){return await $e.get("/h5/conversations/current")}async function zy(e){const t=await $e.post("/h5/conversations/current/messages",e,{timeout:3e4});return{user_message:ci(t.user_message),ai_reply:t.ai_reply?ci(t.ai_reply):t.ai_reply,is_guidance:t.is_guidance,ai_reply_count:t.ai_reply_count,can_call_agent:t.can_call_agent}}async function Wy(e){const n=await $e.get("/h5/conversations/current/messages/poll",{params:e}),s=(n==null?void 0:n.items)||n||[];return Df(s)}async function Fa(e){const n=await $e.get("/h5/conversations/current/messages",{params:e}),s=(n==null?void 0:n.items)||[];return{items:Df(s),has_more:(n==null?void 0:n.has_more)||!1}}async function Ky(e){return await $e.post("/h5/conversations/current/shake",e)}async function Gy(){const t=await $e.get("/h5/approval-links");return(t==null?void 0:t.items)||t||[]}async function Jy(){return await $e.get("/approval/keywords")||[]}async function Xy(e){return await $e.post("/approval/jump",{template_id:e})}async function Yy(e){return await $e.post("/approval/detect-intent",{text:e})}async function Qy(){const t=await $e.get("/h5/software-downloads");return(t==null?void 0:t.items)||t||[]}async function Zy(e){return await $e.post(`/h5/conversations/${e}/join`)}async function ew(e){return await $e.post(`/h5/conversations/${e}/leave-participant`)}async function tw(e,t){return await $e.post(`/conversation/${e}/evaluate`,t)}async function nw(e){return await $e.get(`/conversation/${e}/e
🎉 坐席已为您服务,请稍候...`,t.value&&(t.value.status="serving")):q.assign_result==="queued"&&(te.content=`${q.funny_phrase}
⏳ 当前无空闲坐席,您已进入排队,请耐心等待...`),((I=q.conversation)==null?void 0:I.status)==="serving"&&await G(),q.assign_result||"queued"}catch(F){return console.error("[Store] 招手失败:",F),"error"}finally{o.value=!1}}async function ye(){try{const b=await Gy();c.value=b,console.log("[Store] 获取审批链接成功:",b.length,"条")}catch(b){console.error("[Store] 获取审批链接失败:",b)}}async function Ue(b){var I;try{const F=await Yy(b);if(console.log("[Store] 审批意图检测结果:",F),F.is_approval_request){const q={message_id:`approval_card_${Date.now()}`,conversation_id:((I=t.value)==null?void 0:I.conversation_id)||"",message_type:"system",msg_type:"approval_card",content:"",sender_name:"",created_at:new Date().toISOString(),extra_data:{approval_type:F.approval_type,confidence:F.confidence}};n.value.push(q),console.log("[Store] 已插入审批卡片消息, approval_type:",F.approval_type)}}catch(F){console.warn("[Store] 审批意图检测失败:",F)}}function Ve(){u.value=!1,f.value=""}function He(b=""){var F;const I={message_id:`approval_card_${Date.now()}`,conversation_id:((F=t.value)==null?void 0:F.conversation_id)||"",message_type:"system",msg_type:"approval_card",content:"",sender_name:"",created_at:new Date().toISOString(),extra_data:{approval_type:"",confidence:0}};n.value.push(I),console.log("[Store] 手动插入审批卡片消息(快捷按钮触发)")}async function E(){try{const b=await Qy();d.value=b,console.log("[Store] 获取软件下载列表成功:",b.length,"条")}catch(b){console.error("[Store] 获取软件下载列表失败:",b)}}function $(){a.value=!a.value}async function V(b){try{await G();const I=t.value;I&&I.conversation_id!==b&&console.warn("[Store] 当前会话ID不匹配, 期望:",b,"实际:",I.conversation_id),n.value=[],h.value="",await xe(),console.log("[Store] 已切换到邀请会话:",b)}catch(I){console.error("[Store] 切换会话失败:",I)}}async function Q(){if(!t.value)return;const b=t.value.conversation_id;try{await ew(b),console.log("[Store] 已退出会话:",b),t.value=null,S.value=[],n.value=[],h.value="",be()}catch(I){throw console.error("[Store] 退出会话失败:",I),I}}function le(){T.value=!T.value}async function y(b){const I=n.value.findIndex(te=>te.message_id===b);if(I===-1){console.warn("[Store] 重试消息找不到:",b);return}const F=n.value[I];if(F.status!=="failed"){console.warn("[Store] 消息状态不是 failed,无法重试:",b);return}const q=F.content;n.value.splice(I,1),console.log("[Store] 删除失败消息:",b),await X(q,{msg_type:F.msg_type,media_url:F.media_url,file_name:F.file_name,file_size:F.file_size})}function w(b){S.value=b,t.value&&(t.value.participants=b),console.log("[Store] 参与者列表已通过WS更新:",b.length,"人")}function R(){console.log("[Store] 当前用户被移除会话,清空状态"),t.value=null,S.value=[],n.value=[],h.value="",T.value=!1,be()}function N(b){var F;if(((F=t.value)==null?void 0:F.conversation_id)!==b.conversation_id||!b.chunk)return;if(!C.value){const q=`ai_stream_${b.conversation_id}_${Date.now()}`;C.value=q,n.value.push({message_id:q,conversation_id:b.conversation_id,message_type:"ai",msg_type:"text",content:"",sender_name:"Duckula(达寇拉)",created_at:new Date().toISOString()})}const I=n.value.findIndex(q=>q.message_id===C.value);I!==-1&&(n.value[I].content+=b.chunk)}function U(b){var te,pe;if(((te=t.value)==null?void 0:te.conversation_id)!==b.conversation_id)return;const I={message_id:b.message_id,conversation_id:b.conversation_id,message_type:b.sender_type||"ai",msg_type:b.msg_type||"text",content:b.content,sender_name:b.sender_name||"Duckula(达寇拉)",created_at:new Date().toISOString(),status:"sent"},F=C.value?n.value.findIndex(ge=>ge.message_id===C.value):-1;if(F!==-1?n.value[F]=I:n.value.push(I),C.value=null,H(b.message_id),h.value=b.message_id,r.value=b.can_call_agent??!1,t.value){t.value.can_call_agent=b.can_call_agent??!1,t.value.ai_substantive_reply_count=b.ai_reply_count??0;const ge={ai_handling:"waiting",queued:"waiting",serving:"serving"
`)}mt(()=>{document.addEventListener("paste",_),document.addEventListener("keydown",se),h()&&u().catch(j=>{console.warn("[InputBar] 企微 JS-SDK 初始化失败:",j)})}),Fn(()=>{document.removeEventListener("paste",_),document.removeEventListener("keydown",se)});async function _(j){var G;const W=j.target;if(W.tagName==="TEXTAREA"||W.isContentEditable)return;const ee=(G=j.clipboardData)==null?void 0:G.items;if(ee){for(const X of Array.from(ee))if(X.kind==="file"){j.preventDefault();const ae=X.getAsFile();if(!ae)continue;ae.type.startsWith("image/")?await g(ae):await O(ae);return}}}const m=["😀","😃","😄","😁","😆","😅","🤣","😂","🙂","😊","😇","🥰","😍","🤩","😘","😗","😚","😙","😋","😛","😜","🤪","😝","🤑","🤗","🤭","🤫","🤔","🤐","🤨","😐","😑","😶","😏","😒","🙄","😬","😮","🤯","😲","😳","🥺","😢","😭","😤","😠","😡","🤬","👍","👎","👏","🙌","🤝","💪","✌️","🤞","❤️","🧡","💛","💚","💙","💜","💯","✅"];function v(j){s.value+=j,a.value=!1,_t(()=>{var ee,G;const W=(G=(ee=o.value)==null?void 0:ee.$el)==null?void 0:G.querySelector("textarea");W==null||W.focus()})}function S(j){/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)||j.shiftKey||(j.preventDefault(),T())}async function T(){const j=s.value.trim();!j||n.loading||(s.value="",await n.sendNewMessage(j))}async function C(j){var ee;const W=(ee=j.clipboardData)==null?void 0:ee.items;if(W){for(const G of Array.from(W))if(G.kind==="file"){j.preventDefault();const X=G.getAsFile();if(!X)continue;X.type.startsWith("image/")?await g(X):await O(X);return}}}async function g(j){var W,ee;try{ve("图片上传中...");const G=await kr(j),X=j instanceof File?j.name:"截图";await n.sendNewMessage(`[图片] ${X}`,{msg_type:"image",media_url:G.url,file_name:G.filename,file_size:G.file_size}),ve("图片发送成功")}catch(G){console.error("图片上传失败:",G),ve(t((ee=(W=G==null?void 0:G.response)==null?void 0:W.data)==null?void 0:ee.detail)||(G==null?void 0:G.message)||"图片上传失败,请重试")}}async function O(j){var W,ee;try{const G=j instanceof File?j.name:"文件";ve(`文件上传中: ${G}`);const X=await kr(j);await n.sendNewMessage(`[文件] ${X.filename}`,{msg_type:"file",media_url:X.url,file_name:X.filename,file_size:X.file_size}),ve("文件发送成功")}catch(G){console.error("文件上传失败:",G),ve(t((ee=(W=G==null?void 0:G.response)==null?void 0:W.data)==null?void 0:ee.detail)||(G==null?void 0:G.message)||"文件上传失败,请重试")}}async function P(j){const W=j.target,ee=W.files;if(!(!ee||ee.length===0)){for(const G of Array.from(ee))try{ve(`正在上传: ${G.name}`);const X=await kr(G);ve(`${G.name} 上传成功`),console.log("[InputBar] 文件上传成功:",X.url)}catch(X){console.error("文件上传失败:",X),ve(`${G.name} 上传失败`)}W.value=""}}function z(){a.value=!a.value}function D(){r.value&&(r.value.accept="",r.value.multiple=!0,r.value.click())}async function J(){if(!h()){ve("当前环境不支持语音识别");return}try{if(c.isRecording){const j=await d();j?(x(s.value)&&(s.value+=" "),s.value+=j,ve("语音识别完成")):ve("未识别到语音内容")}else await f(),ve("正在录音,点击停止")}catch(j){const W=c.error||(j==null?void 0:j.message)||"语音识别失败";ve(W),console.error("[InputBar] 语音识别错误:",j)}}function se(j){j.ctrlKey&&(j.key==="d"||j.key==="D")&&(j.preventDefault(),J())}function H(j){l.value=!0;const W=j.clientY,ee=j.target.closest(".input-bar"),G=ee?ee.offsetHeight:100;function X(xe){if(!l.value)return;const we=W-xe.clientY;let be=G+we;be=Math.max(100,Math.min(400,be)),ee&&(ee.style.height=`${be}px`,ee.style.flexShrink="0")}function ae(){l.value=!1,document.removeEventListener("mousemove",X),document.removeEventListener("mouseup",ae),document.body.style.cursor="",document.body.style.userSelect=""}document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",X),document.addEventListener("mouseup",ae)}return(j,