chatlab-cli 0.23.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -30
- package/dist/{chunk-NTWDG52H.mjs → chunk-AHQQQ5HZ.mjs} +41 -7
- package/dist/chunk-AHQQQ5HZ.mjs.map +1 -0
- package/dist/{chunk-D2BR3MFN.mjs → chunk-L37WJ33K.mjs} +28 -1
- package/dist/chunk-L37WJ33K.mjs.map +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/{http-2DN3XOXO.mjs → http-JDORENHT.mjs} +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{service-WNEVPQ4N.mjs → service-WCGGRZTA.mjs} +3 -3
- package/dist/service-WCGGRZTA.mjs.map +1 -0
- package/dist-web/assets/{DebugToolsPanel-D9O_4J04.css → DebugToolsPanel-Yzfz2ntn.css} +1 -1
- package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-DXxg55kL.js +161 -0
- package/dist-web/assets/{MessageExportModal-CvocO88D.js → MessageExportModal-DMHA4X0b.js} +1 -1
- package/dist-web/assets/{fetch-CfTcWxqG.js → fetch-BxE8RQYE.js} +1 -1
- package/dist-web/assets/{fetch-DTP8Q782.js → fetch-CvfdN4gM.js} +1 -1
- package/dist-web/assets/{index-CxMP0DNd.css → index-BUfibEyG.css} +1 -1
- package/dist-web/assets/{index-CHkXbqMb.js → index-C2439065.js} +6 -6
- package/dist-web/assets/index-CD5Fz-JY.js +7 -0
- package/dist-web/assets/index-DC0LjKV6.js +2 -0
- package/dist-web/assets/index-Dl-X-izi.css +1 -0
- package/dist-web/assets/index-DywUneNT.css +1 -0
- package/dist-web/assets/index-JvmxkAGk.js +173 -0
- package/dist-web/assets/index-vEVpfw-R.js +163 -0
- package/dist-web/assets/{vendor-nuxt-ui-CuCZ1aRl.js → vendor-nuxt-ui-3XQAyMd0.js} +1 -1
- package/dist-web/assets/{web-DGd63PrV.js → web-Bm94rL5B.js} +1 -1
- package/dist-web/index.html +3 -3
- package/package.json +3 -2
- package/dist/chunk-D2BR3MFN.mjs.map +0 -1
- package/dist/chunk-NTWDG52H.mjs.map +0 -1
- package/dist/service-WNEVPQ4N.mjs.map +0 -1
- package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-hp9Mjpub.js +0 -161
- package/dist-web/assets/index-B6dkyIiA.js +0 -2
- package/dist-web/assets/index-CALU1QPF.js +0 -163
- package/dist-web/assets/index-CvuHOeoU.css +0 -1
- package/dist-web/assets/index-DOS5o2_H.js +0 -7
- package/dist-web/assets/index-DuepdDzz.css +0 -1
- package/dist-web/assets/index-niwrSprs.js +0 -173
- /package/dist/{http-2DN3XOXO.mjs.map → http-JDORENHT.mjs.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as de,a as le,j as ce,b as se,g as ue,r as ge}from"./vendor-nuxt-ui-CuCZ1aRl.js";import{u as J,d as ne,T as ye,h as ie,f as ve,H as me,b as xe,x as he,w as O,j as pe}from"./index-DOS5o2_H.js";import{p as X,J as Q,w as W,d as re,G as l,P as u,a5 as t,R as T,T as n,u as y,L as I,K as R,Z as N,a3 as Z,H as Y,U as H,bA as ae,bB as oe,b as $,h as P,bE as fe,a0 as q,a9 as ke,Q as te,n as be,by as _e,W as we,bp as G}from"./vendor-reka-ui-BrTYuIfH.js";import{c as $e}from"./DebugToolsPanel.vue_vue_type_script_setup_true_lang-hp9Mjpub.js";import"./vendor-snapdom-XnBoh1gd.js";import"./index-CHkXbqMb.js";import"./model-catalog-DUuKjIVU.js";import"./vendor-echarts-wordcloud-CZ9gsX8l.js";import"./vendor-echarts-C5u62NnM.js";import"./vendor-zrender-DFl4U2Oe.js";const Se={class:"p-4 space-y-6"},Ie={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ce={class:"text-gray-500 text-xs ml-1"},Te={class:"flex gap-2 mb-2"},Me={key:0,class:"flex flex-wrap gap-2"},ze=["onClick"],De={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Le={class:"space-y-2"},Be={key:0,class:"flex gap-2 items-center"},Fe={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ue={class:"text-gray-500 text-xs ml-1"},Re={class:"max-h-60 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-md"},Pe={key:0,class:"p-4 text-center text-gray-500"},Ve={key:1,class:"p-4 text-center text-gray-500 text-sm"},He={key:2,class:"divide-y divide-gray-100 dark:divide-gray-700"},je=["checked","onChange"],Ee={class:"text-sm text-gray-700 dark:text-gray-300 truncate"},Ne={class:"text-xs text-gray-400 ml-auto"},Ae={key:0,class:"mt-2 text-xs text-gray-500"},Ke={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ye={class:"text-gray-500 text-xs ml-1"},We=X({__name:"ConditionPanel",props:{keywords:{default:()=>[]},keywordsModifiers:{},timeRange:{default:null},timeRangeModifiers:{},senderIds:{default:()=>[]},senderIdsModifiers:{},contextSize:{default:10},contextSizeModifiers:{}},emits:["update:keywords","update:timeRange","update:senderIds","update:contextSize"],setup(v){const{t:C}=J(),M=ne(),h=Q(v,"keywords"),m=Q(v,"timeRange"),w=Q(v,"senderIds"),z=Q(v,"contextSize"),L=$(""),r=$([]),p=$(!1),k=$("all"),x=$(""),D=$(""),B=[{id:"all",label:"analysis.filter.allTime"},{id:"today",label:"analysis.filter.today"},{id:"week",label:"analysis.filter.lastWeek"},{id:"month",label:"analysis.filter.lastMonth"},{id:"3months",label:"analysis.filter.last3Months"},{id:"year",label:"analysis.filter.lastYear"},{id:"custom",label:"analysis.filter.customTime"}],F=P(()=>B.map(s=>({label:C(s.label),value:s.id})));W(k,()=>{a()});const j=$(null);async function E(){const s=M.currentSessionId;if(s){p.value=!0;try{r.value=await ie().getMembers(s)}catch(e){console.error("加载成员失败:",e)}finally{p.value=!1}}}async function V(){const s=M.currentSessionId;if(s)try{const e=await ie().getTimeRange(s);e&&(j.value=e)}catch(e){console.error("加载时间范围失败:",e)}}function U(){const s=L.value.trim();s&&!h.value.includes(s)&&(h.value=[...h.value,s],L.value="")}function c(s){h.value=h.value.filter(e=>e!==s)}function g(s){s.key==="Enter"&&(s.preventDefault(),U())}function o(s){w.value.includes(s)?w.value=w.value.filter(e=>e!==s):w.value=[...w.value,s]}function a(){const s=Math.floor(Date.now()/1e3),e=new Date;e.setHours(0,0,0,0);const d=Math.floor(e.getTime()/1e3);switch(k.value){case"all":m.value=null;break;case"today":m.value={start:d,end:s};break;case"week":m.value={start:s-10080*60,end:s};break;case"month":m.value={start:s-720*60*60,end:s};break;case"3months":m.value={start:s-2160*60*60,end:s};break;case"year":m.value={start:s-365*24*60*60,end:s};break;case"custom":if(x.value&&D.value){const f=new Date(x.value).getTime()/1e3,i=new Date(D.value).getTime()/1e3+86399;m.value={start:f,end:i}}break}}const b=$(""),A=P(()=>{if(!b.value)return r.value;const s=b.value.toLowerCase();return r.value.filter(e=>e.accountName?.toLowerCase().includes(s)||e.groupNickname?.toLowerCase().includes(s)||e.platformId.toLowerCase().includes(s)||e.aliases.some(d=>d.toLowerCase().includes(s)))});return re(()=>{E(),V()}),(s,e)=>{const d=de,f=le,i=se,S=ce;return l(),u("div",Se,[t("div",null,[t("label",Ie,[T(n(y(C)("analysis.filter.keywords"))+" ",1),t("span",Ce,"("+n(y(C)("analysis.filter.keywordsHint"))+")",1)]),t("div",Te,[I(d,{modelValue:L.value,"onUpdate:modelValue":e[0]||(e[0]=_=>L.value=_),placeholder:y(C)("analysis.filter.keywordPlaceholder"),class:"flex-1",onKeydown:g},null,8,["modelValue","placeholder"]),I(f,{size:"sm",onClick:U},{default:R(()=>[T(n(y(C)("common.add")),1)]),_:1})]),h.value.length>0?(l(),u("div",Me,[(l(!0),u(N,null,Z(h.value,_=>(l(),Y(S,{key:_,color:"primary",variant:"subtle",class:"gap-1"},{default:R(()=>[T(n(_)+" ",1),t("button",{class:"ml-1 hover:text-red-500",onClick:K=>c(_)},[I(i,{name:"i-heroicons-x-mark",class:"w-3 h-3"})],8,ze)]),_:2},1024))),128))])):H("",!0)]),t("div",null,[t("label",De,n(y(C)("analysis.filter.timeRange")),1),t("div",Le,[I(ye,{modelValue:k.value,"onUpdate:modelValue":e[1]||(e[1]=_=>k.value=_),items:F.value,size:"sm"},null,8,["modelValue","items"]),k.value==="custom"?(l(),u("div",Be,[ae(t("input",{"onUpdate:modelValue":e[2]||(e[2]=_=>x.value=_),type:"date",class:"flex-1 px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800",onChange:a},null,544),[[oe,x.value]]),e[6]||(e[6]=t("span",{class:"text-gray-500"},"~",-1)),ae(t("input",{"onUpdate:modelValue":e[3]||(e[3]=_=>D.value=_),type:"date",class:"flex-1 px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800",onChange:a},null,544),[[oe,D.value]])])):H("",!0)])]),t("div",null,[t("label",Fe,[T(n(y(C)("analysis.filter.senders"))+" ",1),t("span",Ue,"("+n(y(C)("analysis.filter.sendersHint"))+")",1)]),I(d,{modelValue:b.value,"onUpdate:modelValue":e[4]||(e[4]=_=>b.value=_),placeholder:y(C)("analysis.filter.searchMember"),icon:"i-heroicons-magnifying-glass",size:"sm",class:"mb-2"},null,8,["modelValue","placeholder"]),t("div",Re,[p.value?(l(),u("div",Pe,[I(i,{name:"i-heroicons-arrow-path",class:"w-5 h-5 animate-spin"})])):A.value.length===0?(l(),u("div",Ve,n(y(C)("analysis.filter.noMembers")),1)):(l(),u("div",He,[(l(!0),u(N,null,Z(A.value,_=>(l(),u("label",{key:_.id,class:"flex items-center gap-2 px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer"},[t("input",{type:"checkbox",checked:w.value.includes(_.id),class:"text-primary-500 rounded",onChange:K=>o(_.id)},null,40,je),t("span",Ee,n(_.groupNickname||_.accountName||_.platformId),1),t("span",Ne,"("+n(_.messageCount)+")",1)]))),128))]))]),w.value.length>0?(l(),u("div",Ae,n(y(C)("analysis.filter.selectedCount",{count:w.value.length})),1)):H("",!0)]),t("div",null,[t("label",Ke,[T(n(y(C)("analysis.filter.contextSize"))+" ",1),t("span",Ye,"±"+n(z.value)+" "+n(y(C)("analysis.filter.messages")),1)]),ae(t("input",{"onUpdate:modelValue":e[5]||(e[5]=_=>z.value=_),type:"range",min:"0",max:"50",step:"5",class:"w-full h-2 bg-gray-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer"},null,512),[[oe,z.value,void 0,{number:!0}]]),e[7]||(e[7]=t("div",{class:"flex justify-between text-xs text-gray-400 mt-1"},[t("span",null,"0"),t("span",null,"25"),t("span",null,"50")],-1))])])}}}),Oe={class:"p-4 flex flex-col h-full min-h-0"},Ge={key:0,class:"flex-none mb-2 text-sm text-primary-500"},Qe={class:"flex-1 min-h-0"},Ze={key:0,class:"flex items-center justify-center h-full"},qe={key:1,class:"flex items-center justify-center h-full text-gray-500 text-sm"},Je=["onClick"],Xe={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},et={class:"flex items-center gap-2"},tt={class:"text-xs text-gray-500"},st=["checked","onChange"],nt=["checked","onChange"],at={class:"flex-1 min-w-0"},ot={class:"flex items-center gap-2"},lt={class:"text-sm text-gray-700 dark:text-gray-300"},rt={class:"flex items-center gap-2 text-xs text-gray-500"},it=X({__name:"SessionPanel",props:{selectedIds:{default:()=>[]},selectedIdsModifiers:{}},emits:["update:selectedIds"],setup(v){const{t:C}=J(),M=ne(),h=Q(v,"selectedIds"),m=$(new Set);W(h,c=>{m.value=new Set(c)},{immediate:!0});const w=$([]),z=$(!1),L=$(null),r=P(()=>{const c={};for(const a of w.value){const b=new Date(a.startTs*1e3).toLocaleDateString();c[b]||(c[b]=[]),c[b].push(a)}const g=Object.keys(c).sort((a,b)=>new Date(b).getTime()-new Date(a).getTime()),o=[];for(const a of g){o.push({type:"date",date:a,sessionCount:c[a].length});for(const b of c[a])o.push({type:"session",session:b,date:a})}return o}),p=fe(P(()=>({count:r.value.length,getScrollElement:()=>L.value,estimateSize:c=>r.value[c]?.type==="date"?36:56,overscan:10}))),k=P(()=>p.value.getVirtualItems());async function x(){const c=M.currentSessionId;if(c){z.value=!0;try{w.value=await ve().getSessions(c)}catch(g){console.error("加载会话失败:",g)}finally{z.value=!1}}}function D(c){return m.value.has(c)}function B(c){const g=new Set(m.value);g.has(c)?g.delete(c):g.add(c),m.value=g,h.value=Array.from(g)}function F(c){return r.value.filter(g=>g.type==="session"&&g.date===c).map(g=>g.session.id)}function j(c){const g=F(c),o=g.every(b=>m.value.has(b)),a=new Set(m.value);if(o)for(const b of g)a.delete(b);else for(const b of g)a.add(b);m.value=a,h.value=Array.from(a)}function E(c){const g=F(c);return g.length>0&&g.every(o=>m.value.has(o))}function V(c){return new Date(c*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})}function U(c,g){const o=g-c;return o<60?`${o}秒`:o<3600?`${Math.floor(o/60)}分钟`:`${Math.floor(o/3600)}小时${Math.floor(o%3600/60)}分钟`}return re(()=>{x()}),(c,g)=>{const o=se;return l(),u("div",Oe,[h.value.length>0?(l(),u("div",Ge,n(y(C)("analysis.filter.selectedSessions",{count:h.value.length})),1)):H("",!0),t("div",Qe,[z.value?(l(),u("div",Ze,[I(o,{name:"i-heroicons-arrow-path",class:"w-6 h-6 animate-spin text-gray-400"})])):w.value.length===0?(l(),u("div",qe,n(y(C)("analysis.filter.noSessions")),1)):(l(),u("div",{key:2,ref_key:"scrollContainerRef",ref:L,class:"h-full overflow-y-auto"},[t("div",{style:q({height:`${y(p).getTotalSize()}px`,position:"relative"})},[(l(!0),u(N,null,Z(k.value,a=>(l(),u("div",{key:String(a.key),style:q({position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${a.start}px)`})},[r.value[a.index].type==="date"?(l(),u("div",{key:0,class:"flex items-center justify-between px-2 py-1.5 bg-gray-100 dark:bg-gray-800 rounded-md cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-700",onClick:b=>j(r.value[a.index].date)},[t("span",Xe,n(r.value[a.index].date),1),t("div",et,[t("span",tt,n(r.value[a.index].sessionCount)+" 个会话",1),t("input",{type:"checkbox",checked:E(r.value[a.index].date),class:"text-primary-500 rounded",onClick:g[0]||(g[0]=ke(()=>{},["stop"])),onChange:b=>j(r.value[a.index].date)},null,40,st)])],8,Je)):(l(),u("label",{key:1,class:te(["flex items-center gap-3 px-3 py-2 ml-2 rounded-md hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer border border-transparent",{"border-primary-300 bg-primary-50 dark:border-primary-600 dark:bg-primary-900/20":D(r.value[a.index].session.id)}])},[t("input",{type:"checkbox",checked:D(r.value[a.index].session.id),class:"text-primary-500 rounded",onChange:b=>B(r.value[a.index].session.id)},null,40,nt),t("div",at,[t("div",ot,[t("span",lt,n(V(r.value[a.index].session.startTs))+" - "+n(V(r.value[a.index].session.endTs)),1)]),t("div",rt,[t("span",null,n(r.value[a.index].session.messageCount)+" 条消息",1),g[1]||(g[1]=t("span",null,"·",-1)),t("span",null,n(U(r.value[a.index].session.startTs,r.value[a.index].session.endTs)),1)])])],2))],4))),128))],4)],512))])])}}}),dt={class:"flex-1 flex flex-col overflow-hidden bg-gray-50 dark:bg-gray-900"},ct={key:0,class:"flex-none px-4 py-3 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"},ut={class:"flex items-center justify-between mb-2"},ft={class:"flex items-center gap-6 text-sm"},gt={class:"text-gray-600 dark:text-gray-400"},yt={class:"font-medium text-gray-900 dark:text-white"},vt={class:"text-gray-600 dark:text-gray-400"},mt={class:"font-medium text-gray-900 dark:text-white"},xt={class:"text-gray-600 dark:text-gray-400"},ht={class:"font-medium text-primary-500"},pt={class:"text-gray-600 dark:text-gray-400"},kt={class:"font-medium text-gray-900 dark:text-white"},bt={class:"flex-1 min-h-0 flex overflow-hidden"},_t={key:1,class:"w-full h-full flex items-center justify-center"},wt={class:"text-center text-gray-400"},$t={key:2,class:"flex-1 flex items-center justify-center"},St={class:"text-center text-gray-400"},It={class:"w-64 flex-none border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 flex flex-col"},Ct={class:"flex-none px-3 py-2 border-b border-gray-200 dark:border-gray-700"},Tt={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Mt=["onClick"],zt={class:"flex items-center justify-between mb-1"},Dt={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Lt={key:0,class:"text-xs text-primary-500"},Bt={class:"text-xs text-gray-500"},Ft={class:"flex items-center gap-2 text-xs text-gray-400 mt-1"},Ut={key:0,class:"py-3 text-center text-sm text-gray-500 dark:text-gray-400 border-t border-gray-100 dark:border-gray-700"},Rt={key:1,class:"py-3 text-center text-xs text-gray-400 dark:text-gray-500"},Pt={class:"flex-1 overflow-hidden"},Vt={key:1,class:"flex items-center justify-center h-full text-gray-400"},Ht=X({__name:"PreviewPanel",props:{result:{},isLoading:{type:Boolean},isLoadingMore:{type:Boolean}},emits:["load-more"],setup(v,{emit:C}){const{t:M}=J(),h=v,m=C,w=$(0);let z=!1;const L=$(null),r=$(null),p=$(null);function k(s){if(!h.result)return null;const e=h.result.blocks.length-1-s;return h.result.blocks[e]}const x=P(()=>h.result?.blocks.length??0),D=fe(P(()=>({count:x.value,getScrollElement:()=>p.value,estimateSize:()=>72,overscan:5}))),B=P(()=>D.value.getVirtualItems()),F=P(()=>{if(x.value===0)return[];const s=k(w.value);return s?s.messages.map(e=>({id:e.id,senderName:e.senderName,senderPlatformId:e.senderPlatformId,senderAliases:e.senderAliases,senderAvatar:e.senderAvatar,content:e.content,timestamp:e.timestamp,type:e.type,replyToMessageId:e.replyToMessageId,replyToContent:e.replyToContent,replyToSenderName:e.replyToSenderName})):[]}),j=P(()=>{if(x.value===0)return[];const s=k(w.value);return s?s.messages.filter(e=>e.isHit).map(e=>e.id):[]}),E={startTs:0,endTs:0},V=P(()=>{if(!h.result||h.result.blocks.length===0)return!1;const s=h.result.blocks,e=new Date(s[0].startTs*1e3).getFullYear(),d=new Date(s[s.length-1].endTs*1e3).getFullYear();return e!==d});function U(s){const e={month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};return V.value&&(e.year="numeric"),new Date(s*1e3).toLocaleString("zh-CN",e)}function c(s,e){const d=e-s;return d<60?`${d}秒`:d<3600?`${Math.floor(d/60)}分钟`:`${Math.floor(d/3600)}h${Math.floor(d%3600/60)}m`}function g(s){w.value=s;const e=k(s);if(e){const d=e.messages.find(f=>f.isHit);d&&(L.value=d.id)}}function o(){z||x.value!==0&&w.value<x.value-1&&(z=!0,w.value++,b(w.value),setTimeout(()=>{z=!1},300))}function a(){}function b(s){D.value.scrollToIndex(s,{align:"center"})}W(()=>h.result,()=>{w.value=0,L.value=null}),W(L,async s=>{s!==null&&(await be(),setTimeout(()=>{r.value?.scrollToMessage(s),L.value=null},100))});function A(s){const e=s.target;if(!e||!h.result?.pagination?.hasMore||h.isLoadingMore)return;const d=100,{scrollTop:f,scrollHeight:i,clientHeight:S}=e;i-f-S<d&&m("load-more")}return(s,e)=>{const d=se;return l(),u("div",dt,[v.result&&v.result.blocks.length>0?(l(),u("div",ct,[t("div",ut,[t("div",ft,[t("span",gt,[T(n(y(M)("analysis.filter.stats.blocks"))+": ",1),t("span",yt,[T(n(v.result.blocks.length)+" ",1),v.result.pagination&&v.result.pagination.totalBlocks>v.result.blocks.length?(l(),u(N,{key:0},[T(" / "+n(v.result.pagination.totalBlocks),1)],64)):H("",!0)])]),t("span",vt,[T(n(y(M)("analysis.filter.stats.messages"))+": ",1),t("span",mt,n(v.result.stats.totalMessages),1)]),t("span",xt,[T(n(y(M)("analysis.filter.stats.hits"))+": ",1),t("span",ht,n(v.result.pagination?.totalHits??v.result.stats.hitMessages),1)]),t("span",pt,[T(n(y(M)("analysis.filter.stats.chars"))+": ",1),t("span",kt,n(v.result.stats.totalChars.toLocaleString()),1)])])])])):H("",!0),t("div",bt,[v.isLoading?(l(),Y($e,{key:0,variant:"page",text:y(M)("analysis.filter.filtering")},null,8,["text"])):v.result?v.result.blocks.length===0?(l(),u("div",$t,[t("div",St,[I(d,{name:"i-heroicons-magnifying-glass",class:"w-12 h-12 mb-3 mx-auto"}),t("p",null,n(y(M)("analysis.filter.noResults")),1)])])):(l(),u(N,{key:3},[t("div",It,[t("div",Ct,[t("span",Tt,[T(n(y(M)("analysis.filter.stats.blocks"))+" ("+n(v.result.blocks.length)+" ",1),v.result.pagination&&v.result.pagination.totalBlocks>v.result.blocks.length?(l(),u(N,{key:0},[T(" /"+n(v.result.pagination.totalBlocks),1)],64)):H("",!0),e[1]||(e[1]=T(" ) ",-1))])]),t("div",{ref_key:"blockListRef",ref:p,class:"flex-1 overflow-y-auto",onScroll:A},[t("div",{style:q({height:`${y(D).getTotalSize()}px`,position:"relative"})},[(l(!0),u(N,null,Z(B.value,f=>(l(),u("div",{key:String(f.key),style:q({position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${f.start}px)`})},[t("div",{class:te(["px-3 py-2 cursor-pointer border-b border-gray-100 dark:border-gray-700 transition-colors",w.value===f.index?"bg-primary-50 dark:bg-primary-900/30 border-l-2 border-l-primary-500":"hover:bg-gray-50 dark:hover:bg-gray-700/50"]),onClick:i=>g(f.index)},[t("div",zt,[t("span",Dt," #"+n(f.index+1),1),(k(f.index)?.hitCount??0)>0?(l(),u("span",Lt," 含 "+n(k(f.index)?.hitCount)+" 个结果 ",1)):H("",!0)]),t("div",Bt,n(U(k(f.index)?.startTs??0)),1),t("div",Ft,[t("span",null,n(k(f.index)?.messages.length??0)+" 条",1),e[2]||(e[2]=t("span",null,"·",-1)),t("span",null,n(c(k(f.index)?.startTs??0,k(f.index)?.endTs??0)),1)])],10,Mt)],4))),128))],4),v.result.pagination?.hasMore?(l(),u("div",Ut,[v.isLoadingMore?(l(),u(N,{key:0},[I(d,{name:"i-heroicons-arrow-path",class:"w-4 h-4 animate-spin inline mr-1"}),T(" "+n(y(M)("common.loading")),1)],64)):(l(),u("button",{key:1,class:"text-primary-500 hover:text-primary-600",onClick:e[0]||(e[0]=f=>m("load-more"))},n(y(M)("analysis.filter.loadMore")),1))])):v.result.pagination&&v.result.blocks.length>=v.result.pagination.totalBlocks?(l(),u("div",Rt,n(y(M)("analysis.filter.allLoaded")),1)):H("",!0)],544)]),t("div",Pt,[F.value.length>0?(l(),Y(me,{key:0,ref_key:"messageListRef",ref:r,query:E,"external-messages":F.value,"hit-message-ids":j.value,class:"h-full",onReachBottom:o,onReachTop:a},null,8,["external-messages","hit-message-ids"])):(l(),u("div",Vt,n(y(M)("analysis.filter.noResults")),1))])],64)):(l(),u("div",_t,[t("div",wt,[I(d,{name:"i-heroicons-funnel",class:"w-12 h-12 mb-3 mx-auto"}),t("p",null,n(y(M)("analysis.filter.emptyHint")),1)])]))])])}}}),jt={class:"flex items-center justify-between"},Et={class:"text-lg font-semibold"},Nt={class:"max-h-96 overflow-y-auto"},At={key:0,class:"py-8 text-center text-gray-500"},Kt={key:1,class:"divide-y divide-gray-200 dark:divide-gray-700"},Yt={class:"flex items-start justify-between gap-2"},Wt={class:"flex-1 min-w-0"},Ot={key:0,class:"flex items-center gap-2 mb-1"},Gt={key:1,class:"flex items-center gap-2 mb-1"},Qt={class:"font-medium text-gray-900 dark:text-white"},Zt=["onClick"],qt={class:"text-sm text-gray-600 dark:text-gray-400 truncate"},Jt={class:"text-xs text-gray-400 mt-1"},Xt={class:"flex items-center gap-1"},es=X({__name:"FilterHistory",props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:we(["load"],["update:open"]),setup(v,{expose:C,emit:M}){const{t:h}=J(),m=ne(),w=xe(),z=Q(v,"open"),L=M,r=$([]);let p=[];const k=$(null),x=$("");async function D(){try{p=(await w.getPreferences()).filterHistory??[],r.value=p.filter(a=>a.sessionId===m.currentSessionId)}catch(o){console.error("Failed to load filter history:",o)}}function B(){p=[...p.filter(a=>a.sessionId!==m.currentSessionId),...r.value],w.savePreferences({filterHistory:p}).catch(a=>{console.error("Failed to save filter history:",a)})}function F(o){r.value=r.value.filter(a=>a.id!==o),B()}function j(o){L("load",{mode:o.mode,conditionFilter:o.conditionFilter,selectedSessionIds:o.selectedSessionIds})}function E(o){k.value=o.id,x.value=o.name}function V(o){o.name=x.value||o.name,k.value=null,B()}function U(){k.value=null}function c(o){return new Date(o).toLocaleString()}function g(o){if(o.mode==="condition"){const a=[];return o.conditionFilter?.keywords.length&&a.push(`关键词: ${o.conditionFilter.keywords.join(", ")}`),o.conditionFilter?.senderIds.length&&a.push(`${o.conditionFilter.senderIds.length} 位成员`),a.join(" | ")||"无条件"}else return`${o.selectedSessionIds?.length||0} 个会话`}return W(z,o=>{o&&D()}),re(()=>{D()}),C({saveCondition(o){const a={id:`filter_${Date.now()}`,sessionId:m.currentSessionId||"",createdAt:Date.now(),name:`筛选 ${r.value.length+1}`,...o};r.value.unshift(a),r.value=r.value.slice(0,20),B()}}),(o,a)=>{const b=le,A=de,s=ce,e=se,d=ge,f=ue;return l(),Y(f,{open:z.value,"onUpdate:open":a[2]||(a[2]=i=>z.value=i)},{content:R(()=>[I(d,null,{header:R(()=>[t("div",jt,[t("h3",Et,n(y(h)("analysis.filter.historyTitle")),1),I(b,{variant:"ghost",icon:"i-heroicons-x-mark",size:"sm",onClick:a[0]||(a[0]=i=>z.value=!1)})])]),default:R(()=>[t("div",Nt,[r.value.length===0?(l(),u("div",At,n(y(h)("analysis.filter.noHistory")),1)):(l(),u("div",Kt,[(l(!0),u(N,null,Z(r.value,i=>(l(),u("div",{key:i.id,class:"py-3 hover:bg-gray-50 dark:hover:bg-gray-800 px-2 rounded-md"},[t("div",Yt,[t("div",Wt,[k.value===i.id?(l(),u("div",Ot,[I(A,{modelValue:x.value,"onUpdate:modelValue":a[1]||(a[1]=S=>x.value=S),size:"sm",class:"flex-1",onKeydown:_e(S=>V(i),["enter"])},null,8,["modelValue","onKeydown"]),I(b,{size:"xs",onClick:S=>V(i)},{default:R(()=>[T(n(y(h)("common.save")),1)]),_:1},8,["onClick"]),I(b,{size:"xs",variant:"ghost",onClick:U},{default:R(()=>[T(n(y(h)("common.cancel")),1)]),_:1})])):(l(),u("div",Gt,[t("span",Qt,n(i.name),1),I(s,{color:i.mode==="condition"?"primary":"green",size:"xs"},{default:R(()=>[T(n(i.mode==="condition"?"条件":"会话"),1)]),_:2},1032,["color"]),t("button",{class:"text-gray-400 hover:text-gray-600",onClick:S=>E(i)},[I(e,{name:"i-heroicons-pencil",class:"w-3 h-3"})],8,Zt)])),t("p",qt,n(g(i)),1),t("p",Jt,n(c(i.createdAt)),1)]),t("div",Xt,[I(b,{size:"xs",variant:"soft",onClick:S=>j(i)},{default:R(()=>[T(n(y(h)("common.load")),1)]),_:1},8,["onClick"]),I(b,{size:"xs",variant:"ghost",color:"red",onClick:S=>F(i.id)},{default:R(()=>[I(e,{name:"i-heroicons-trash",class:"w-4 h-4"})]),_:1},8,["onClick"])])])]))),128))]))])]),_:1})]),_:1},8,["open"])}}}),ts={class:"flex h-[85vh] flex-col overflow-hidden bg-white dark:bg-gray-900"},ss={class:"flex flex-none items-center justify-between border-b border-gray-200 px-5 py-3 dark:border-gray-700"},ns={class:"flex items-center gap-4"},as={class:"text-lg font-semibold text-gray-900 dark:text-white"},os={class:"flex items-center gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},ls={class:"flex items-center gap-2"},rs={class:"flex flex-1 overflow-hidden"},is={class:"flex w-80 flex-none flex-col border-r border-gray-200 dark:border-gray-700"},ds={class:"min-h-0 flex-1 overflow-y-auto"},cs={class:"flex-none border-t border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-900"},us={class:"flex flex-1 flex-col overflow-hidden"},fs={key:0,class:"flex flex-none flex-col gap-2 border-t border-gray-200 bg-gray-50 px-4 py-3 dark:border-gray-700 dark:bg-gray-800"},gs={key:0,class:"w-full"},ys={class:"mb-1 flex items-center justify-between text-sm text-gray-600 dark:text-gray-400"},vs={class:"h-2 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},ms={class:"flex items-center justify-end gap-3"},ee=50,Cs=X({__name:"MessageExportModal",props:{modelValue:{type:Boolean}},emits:["update:modelValue"],setup(v,{emit:C}){const M=v,h=C,{t:m}=J(),w=he(),z=ne(),L=P({get:()=>M.modelValue,set:s=>h("update:modelValue",s)}),r=$("condition"),p=$({keywords:[],timeRange:null,senderIds:[],contextSize:10}),k=$([]),x=$(null),D=$(!1),B=$(!1),F=$(!1),j=P(()=>D.value?!1:r.value==="condition"?p.value.keywords.length>0||p.value.senderIds.length>0||p.value.timeRange!==null:k.value.length>0);async function E(){const s=z.currentSessionId;if(s){D.value=!0,x.value=null;try{if(r.value==="condition"){const e=G(p.value),d=e.keywords.length>0?[...e.keywords]:void 0,f=e.timeRange?{startTs:e.timeRange.start,endTs:e.timeRange.end}:void 0,i=e.senderIds.length>0?[...e.senderIds]:void 0,S=e.contextSize,_=await O().filterMessagesWithContext(s,d,f,i,S,1,ee);x.value=_}else{if(k.value.length===0)return;const e=[...G(k.value)],d=await O().getMultipleSessionsMessages(s,e,1,ee);x.value=d}}catch(e){console.error("筛选失败:",e)}finally{D.value=!1}}}async function V(){const s=z.currentSessionId;if(!s||!x.value||!x.value.pagination.hasMore||B.value)return;B.value=!0;const e=x.value.pagination.page+1;try{let d;if(r.value==="condition"){const f=G(p.value),i=f.keywords.length>0?[...f.keywords]:void 0,S=f.timeRange?{startTs:f.timeRange.start,endTs:f.timeRange.end}:void 0,_=f.senderIds.length>0?[...f.senderIds]:void 0,K=f.contextSize;d=await O().filterMessagesWithContext(s,i,S,_,K,e,ee)}else{const f=[...G(k.value)];d=await O().getMultipleSessionsMessages(s,f,e,ee)}d&&d.blocks.length>0&&(x.value={blocks:[...x.value.blocks,...d.blocks],stats:x.value.stats,pagination:d.pagination})}catch(d){console.error("加载更多失败:",d)}finally{B.value=!1}}const U=$(!1),c=$(null);let g=null;function o(){g=O().onExportProgress(s=>{c.value={percentage:s.percentage,message:s.message},(s.stage==="done"||s.stage==="error")&&(c.value=null)})}function a(){g&&(g(),g=null),c.value=null}async function b(){if(!x.value||x.value.blocks.length===0)return;const s=z.currentSessionId;if(!s)return;const d=z.currentSession?.name||"未知会话",f=await pe().showOpenDialog({title:"选择保存目录",properties:["openDirectory","createDirectory"]});if(f.canceled||!f.filePaths[0])return;const i=f.filePaths[0];U.value=!0,c.value={percentage:0,message:m("analysis.filter.exportPreparing")},o();try{const S=G(p.value),_={sessionId:s,sessionName:d,outputDir:i,filterMode:r.value,keywords:S.keywords.length>0?[...S.keywords]:void 0,timeFilter:S.timeRange?{startTs:S.timeRange.start,endTs:S.timeRange.end}:void 0,senderIds:S.senderIds.length>0?[...S.senderIds]:void 0,contextSize:S.contextSize,chatSessionIds:r.value==="session"?[...G(k.value)]:void 0},K=await O().exportFilterResultToFile(_);K.success&&K.filePath?w.success(m("analysis.filter.exportSuccess"),{description:K.filePath}):w.fail(m("analysis.filter.exportFailed"),{description:K.error||m("common.error.unknown")})}catch(S){console.error("导出失败:",S),w.fail(m("analysis.filter.exportFailed"),{description:String(S)})}finally{a(),U.value=!1}}W(r,()=>{x.value=null}),W(L,s=>{s||(x.value=null,a())});function A(s){r.value=s.mode,s.mode==="condition"&&s.conditionFilter?p.value={...s.conditionFilter}:s.mode==="session"&&s.selectedSessionIds&&(k.value=[...s.selectedSessionIds]),F.value=!1}return(s,e)=>{const d=le,f=ue;return l(),Y(f,{open:L.value,"onUpdate:open":e[10]||(e[10]=i=>L.value=i),ui:{content:"sm:max-w-[95vw]"}},{content:R(()=>[t("div",ts,[t("div",ss,[t("div",ns,[t("h2",as,n(y(m)("analysis.messageExport.title")),1),t("div",os,[t("button",{class:te(["rounded-md px-3 py-1.5 text-sm font-medium transition-colors",r.value==="condition"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"]),onClick:e[0]||(e[0]=i=>r.value="condition")},n(y(m)("analysis.filter.conditionMode")),3),t("button",{class:te(["rounded-md px-3 py-1.5 text-sm font-medium transition-colors",r.value==="session"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"]),onClick:e[1]||(e[1]=i=>r.value="session")},n(y(m)("analysis.filter.sessionMode")),3)])]),t("div",ls,[I(d,{variant:"ghost",icon:"i-heroicons-clock",size:"sm",onClick:e[2]||(e[2]=i=>F.value=!0)},{default:R(()=>[T(n(y(m)("analysis.filter.history")),1)]),_:1}),I(d,{variant:"ghost",icon:"i-heroicons-x-mark",size:"sm",onClick:e[3]||(e[3]=i=>L.value=!1)})])]),t("div",rs,[t("div",is,[t("div",ds,[r.value==="condition"?(l(),Y(We,{key:0,keywords:p.value.keywords,"onUpdate:keywords":e[4]||(e[4]=i=>p.value.keywords=i),"time-range":p.value.timeRange,"onUpdate:timeRange":e[5]||(e[5]=i=>p.value.timeRange=i),"sender-ids":p.value.senderIds,"onUpdate:senderIds":e[6]||(e[6]=i=>p.value.senderIds=i),"context-size":p.value.contextSize,"onUpdate:contextSize":e[7]||(e[7]=i=>p.value.contextSize=i)},null,8,["keywords","time-range","sender-ids","context-size"])):(l(),Y(it,{key:1,"selected-ids":k.value,"onUpdate:selectedIds":e[8]||(e[8]=i=>k.value=i)},null,8,["selected-ids"]))]),t("div",cs,[I(d,{block:"",color:"primary",loading:D.value,disabled:!j.value,onClick:E},{default:R(()=>[T(n(y(m)("analysis.filter.execute")),1)]),_:1},8,["loading","disabled"])])]),t("div",us,[I(Ht,{result:x.value,"is-loading":D.value,"is-loading-more":B.value,onLoadMore:V},null,8,["result","is-loading","is-loading-more"]),x.value&&x.value.blocks.length>0?(l(),u("div",fs,[U.value&&c.value?(l(),u("div",gs,[t("div",ys,[t("span",null,n(c.value.message),1),t("span",null,n(c.value.percentage)+"%",1)]),t("div",vs,[t("div",{class:"h-full bg-primary-500 transition-all duration-300",style:q({width:`${c.value.percentage}%`})},null,4)])])):H("",!0),t("div",ms,[I(d,{variant:"outline",icon:"i-heroicons-document-arrow-down",loading:U.value,disabled:U.value,onClick:b},{default:R(()=>[T(n(y(m)("analysis.filter.export")),1)]),_:1},8,["loading","disabled"])])])):H("",!0)])]),I(es,{open:F.value,"onUpdate:open":e[9]||(e[9]=i=>F.value=i),onLoad:A},null,8,["open"])])]),_:1},8,["open"])}}});export{Cs as default};
|
|
1
|
+
import{e as de,b as le,j as ce,a as se,g as ue,r as ge}from"./vendor-nuxt-ui-3XQAyMd0.js";import{u as J,d as ne,T as ye,h as ie,f as ve,H as me,b as xe,x as he,w as O,j as pe}from"./index-CD5Fz-JY.js";import{p as X,J as Q,w as W,d as re,G as l,P as u,a5 as t,R as T,T as n,u as y,L as I,K as R,Z as N,a3 as Z,H as Y,U as H,bA as ae,bB as oe,b as $,h as P,bE as fe,a0 as q,a9 as ke,Q as te,n as be,by as _e,W as we,bp as G}from"./vendor-reka-ui-BrTYuIfH.js";import{c as $e}from"./DebugToolsPanel.vue_vue_type_script_setup_true_lang-DXxg55kL.js";import"./vendor-snapdom-XnBoh1gd.js";import"./index-C2439065.js";import"./model-catalog-DUuKjIVU.js";import"./vendor-echarts-wordcloud-CZ9gsX8l.js";import"./vendor-echarts-C5u62NnM.js";import"./vendor-zrender-DFl4U2Oe.js";const Se={class:"p-4 space-y-6"},Ie={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ce={class:"text-gray-500 text-xs ml-1"},Te={class:"flex gap-2 mb-2"},Me={key:0,class:"flex flex-wrap gap-2"},ze=["onClick"],De={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Le={class:"space-y-2"},Be={key:0,class:"flex gap-2 items-center"},Fe={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ue={class:"text-gray-500 text-xs ml-1"},Re={class:"max-h-60 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-md"},Pe={key:0,class:"p-4 text-center text-gray-500"},Ve={key:1,class:"p-4 text-center text-gray-500 text-sm"},He={key:2,class:"divide-y divide-gray-100 dark:divide-gray-700"},je=["checked","onChange"],Ee={class:"text-sm text-gray-700 dark:text-gray-300 truncate"},Ne={class:"text-xs text-gray-400 ml-auto"},Ae={key:0,class:"mt-2 text-xs text-gray-500"},Ke={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ye={class:"text-gray-500 text-xs ml-1"},We=X({__name:"ConditionPanel",props:{keywords:{default:()=>[]},keywordsModifiers:{},timeRange:{default:null},timeRangeModifiers:{},senderIds:{default:()=>[]},senderIdsModifiers:{},contextSize:{default:10},contextSizeModifiers:{}},emits:["update:keywords","update:timeRange","update:senderIds","update:contextSize"],setup(v){const{t:C}=J(),M=ne(),h=Q(v,"keywords"),m=Q(v,"timeRange"),w=Q(v,"senderIds"),z=Q(v,"contextSize"),L=$(""),r=$([]),p=$(!1),k=$("all"),x=$(""),D=$(""),B=[{id:"all",label:"analysis.filter.allTime"},{id:"today",label:"analysis.filter.today"},{id:"week",label:"analysis.filter.lastWeek"},{id:"month",label:"analysis.filter.lastMonth"},{id:"3months",label:"analysis.filter.last3Months"},{id:"year",label:"analysis.filter.lastYear"},{id:"custom",label:"analysis.filter.customTime"}],F=P(()=>B.map(s=>({label:C(s.label),value:s.id})));W(k,()=>{a()});const j=$(null);async function E(){const s=M.currentSessionId;if(s){p.value=!0;try{r.value=await ie().getMembers(s)}catch(e){console.error("加载成员失败:",e)}finally{p.value=!1}}}async function V(){const s=M.currentSessionId;if(s)try{const e=await ie().getTimeRange(s);e&&(j.value=e)}catch(e){console.error("加载时间范围失败:",e)}}function U(){const s=L.value.trim();s&&!h.value.includes(s)&&(h.value=[...h.value,s],L.value="")}function c(s){h.value=h.value.filter(e=>e!==s)}function g(s){s.key==="Enter"&&(s.preventDefault(),U())}function o(s){w.value.includes(s)?w.value=w.value.filter(e=>e!==s):w.value=[...w.value,s]}function a(){const s=Math.floor(Date.now()/1e3),e=new Date;e.setHours(0,0,0,0);const d=Math.floor(e.getTime()/1e3);switch(k.value){case"all":m.value=null;break;case"today":m.value={start:d,end:s};break;case"week":m.value={start:s-10080*60,end:s};break;case"month":m.value={start:s-720*60*60,end:s};break;case"3months":m.value={start:s-2160*60*60,end:s};break;case"year":m.value={start:s-365*24*60*60,end:s};break;case"custom":if(x.value&&D.value){const f=new Date(x.value).getTime()/1e3,i=new Date(D.value).getTime()/1e3+86399;m.value={start:f,end:i}}break}}const b=$(""),A=P(()=>{if(!b.value)return r.value;const s=b.value.toLowerCase();return r.value.filter(e=>e.accountName?.toLowerCase().includes(s)||e.groupNickname?.toLowerCase().includes(s)||e.platformId.toLowerCase().includes(s)||e.aliases.some(d=>d.toLowerCase().includes(s)))});return re(()=>{E(),V()}),(s,e)=>{const d=de,f=le,i=se,S=ce;return l(),u("div",Se,[t("div",null,[t("label",Ie,[T(n(y(C)("analysis.filter.keywords"))+" ",1),t("span",Ce,"("+n(y(C)("analysis.filter.keywordsHint"))+")",1)]),t("div",Te,[I(d,{modelValue:L.value,"onUpdate:modelValue":e[0]||(e[0]=_=>L.value=_),placeholder:y(C)("analysis.filter.keywordPlaceholder"),class:"flex-1",onKeydown:g},null,8,["modelValue","placeholder"]),I(f,{size:"sm",onClick:U},{default:R(()=>[T(n(y(C)("common.add")),1)]),_:1})]),h.value.length>0?(l(),u("div",Me,[(l(!0),u(N,null,Z(h.value,_=>(l(),Y(S,{key:_,color:"primary",variant:"subtle",class:"gap-1"},{default:R(()=>[T(n(_)+" ",1),t("button",{class:"ml-1 hover:text-red-500",onClick:K=>c(_)},[I(i,{name:"i-heroicons-x-mark",class:"w-3 h-3"})],8,ze)]),_:2},1024))),128))])):H("",!0)]),t("div",null,[t("label",De,n(y(C)("analysis.filter.timeRange")),1),t("div",Le,[I(ye,{modelValue:k.value,"onUpdate:modelValue":e[1]||(e[1]=_=>k.value=_),items:F.value,size:"sm"},null,8,["modelValue","items"]),k.value==="custom"?(l(),u("div",Be,[ae(t("input",{"onUpdate:modelValue":e[2]||(e[2]=_=>x.value=_),type:"date",class:"flex-1 px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800",onChange:a},null,544),[[oe,x.value]]),e[6]||(e[6]=t("span",{class:"text-gray-500"},"~",-1)),ae(t("input",{"onUpdate:modelValue":e[3]||(e[3]=_=>D.value=_),type:"date",class:"flex-1 px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800",onChange:a},null,544),[[oe,D.value]])])):H("",!0)])]),t("div",null,[t("label",Fe,[T(n(y(C)("analysis.filter.senders"))+" ",1),t("span",Ue,"("+n(y(C)("analysis.filter.sendersHint"))+")",1)]),I(d,{modelValue:b.value,"onUpdate:modelValue":e[4]||(e[4]=_=>b.value=_),placeholder:y(C)("analysis.filter.searchMember"),icon:"i-heroicons-magnifying-glass",size:"sm",class:"mb-2"},null,8,["modelValue","placeholder"]),t("div",Re,[p.value?(l(),u("div",Pe,[I(i,{name:"i-heroicons-arrow-path",class:"w-5 h-5 animate-spin"})])):A.value.length===0?(l(),u("div",Ve,n(y(C)("analysis.filter.noMembers")),1)):(l(),u("div",He,[(l(!0),u(N,null,Z(A.value,_=>(l(),u("label",{key:_.id,class:"flex items-center gap-2 px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer"},[t("input",{type:"checkbox",checked:w.value.includes(_.id),class:"text-primary-500 rounded",onChange:K=>o(_.id)},null,40,je),t("span",Ee,n(_.groupNickname||_.accountName||_.platformId),1),t("span",Ne,"("+n(_.messageCount)+")",1)]))),128))]))]),w.value.length>0?(l(),u("div",Ae,n(y(C)("analysis.filter.selectedCount",{count:w.value.length})),1)):H("",!0)]),t("div",null,[t("label",Ke,[T(n(y(C)("analysis.filter.contextSize"))+" ",1),t("span",Ye,"±"+n(z.value)+" "+n(y(C)("analysis.filter.messages")),1)]),ae(t("input",{"onUpdate:modelValue":e[5]||(e[5]=_=>z.value=_),type:"range",min:"0",max:"50",step:"5",class:"w-full h-2 bg-gray-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer"},null,512),[[oe,z.value,void 0,{number:!0}]]),e[7]||(e[7]=t("div",{class:"flex justify-between text-xs text-gray-400 mt-1"},[t("span",null,"0"),t("span",null,"25"),t("span",null,"50")],-1))])])}}}),Oe={class:"p-4 flex flex-col h-full min-h-0"},Ge={key:0,class:"flex-none mb-2 text-sm text-primary-500"},Qe={class:"flex-1 min-h-0"},Ze={key:0,class:"flex items-center justify-center h-full"},qe={key:1,class:"flex items-center justify-center h-full text-gray-500 text-sm"},Je=["onClick"],Xe={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},et={class:"flex items-center gap-2"},tt={class:"text-xs text-gray-500"},st=["checked","onChange"],nt=["checked","onChange"],at={class:"flex-1 min-w-0"},ot={class:"flex items-center gap-2"},lt={class:"text-sm text-gray-700 dark:text-gray-300"},rt={class:"flex items-center gap-2 text-xs text-gray-500"},it=X({__name:"SessionPanel",props:{selectedIds:{default:()=>[]},selectedIdsModifiers:{}},emits:["update:selectedIds"],setup(v){const{t:C}=J(),M=ne(),h=Q(v,"selectedIds"),m=$(new Set);W(h,c=>{m.value=new Set(c)},{immediate:!0});const w=$([]),z=$(!1),L=$(null),r=P(()=>{const c={};for(const a of w.value){const b=new Date(a.startTs*1e3).toLocaleDateString();c[b]||(c[b]=[]),c[b].push(a)}const g=Object.keys(c).sort((a,b)=>new Date(b).getTime()-new Date(a).getTime()),o=[];for(const a of g){o.push({type:"date",date:a,sessionCount:c[a].length});for(const b of c[a])o.push({type:"session",session:b,date:a})}return o}),p=fe(P(()=>({count:r.value.length,getScrollElement:()=>L.value,estimateSize:c=>r.value[c]?.type==="date"?36:56,overscan:10}))),k=P(()=>p.value.getVirtualItems());async function x(){const c=M.currentSessionId;if(c){z.value=!0;try{w.value=await ve().getSessions(c)}catch(g){console.error("加载会话失败:",g)}finally{z.value=!1}}}function D(c){return m.value.has(c)}function B(c){const g=new Set(m.value);g.has(c)?g.delete(c):g.add(c),m.value=g,h.value=Array.from(g)}function F(c){return r.value.filter(g=>g.type==="session"&&g.date===c).map(g=>g.session.id)}function j(c){const g=F(c),o=g.every(b=>m.value.has(b)),a=new Set(m.value);if(o)for(const b of g)a.delete(b);else for(const b of g)a.add(b);m.value=a,h.value=Array.from(a)}function E(c){const g=F(c);return g.length>0&&g.every(o=>m.value.has(o))}function V(c){return new Date(c*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})}function U(c,g){const o=g-c;return o<60?`${o}秒`:o<3600?`${Math.floor(o/60)}分钟`:`${Math.floor(o/3600)}小时${Math.floor(o%3600/60)}分钟`}return re(()=>{x()}),(c,g)=>{const o=se;return l(),u("div",Oe,[h.value.length>0?(l(),u("div",Ge,n(y(C)("analysis.filter.selectedSessions",{count:h.value.length})),1)):H("",!0),t("div",Qe,[z.value?(l(),u("div",Ze,[I(o,{name:"i-heroicons-arrow-path",class:"w-6 h-6 animate-spin text-gray-400"})])):w.value.length===0?(l(),u("div",qe,n(y(C)("analysis.filter.noSessions")),1)):(l(),u("div",{key:2,ref_key:"scrollContainerRef",ref:L,class:"h-full overflow-y-auto"},[t("div",{style:q({height:`${y(p).getTotalSize()}px`,position:"relative"})},[(l(!0),u(N,null,Z(k.value,a=>(l(),u("div",{key:String(a.key),style:q({position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${a.start}px)`})},[r.value[a.index].type==="date"?(l(),u("div",{key:0,class:"flex items-center justify-between px-2 py-1.5 bg-gray-100 dark:bg-gray-800 rounded-md cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-700",onClick:b=>j(r.value[a.index].date)},[t("span",Xe,n(r.value[a.index].date),1),t("div",et,[t("span",tt,n(r.value[a.index].sessionCount)+" 个会话",1),t("input",{type:"checkbox",checked:E(r.value[a.index].date),class:"text-primary-500 rounded",onClick:g[0]||(g[0]=ke(()=>{},["stop"])),onChange:b=>j(r.value[a.index].date)},null,40,st)])],8,Je)):(l(),u("label",{key:1,class:te(["flex items-center gap-3 px-3 py-2 ml-2 rounded-md hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer border border-transparent",{"border-primary-300 bg-primary-50 dark:border-primary-600 dark:bg-primary-900/20":D(r.value[a.index].session.id)}])},[t("input",{type:"checkbox",checked:D(r.value[a.index].session.id),class:"text-primary-500 rounded",onChange:b=>B(r.value[a.index].session.id)},null,40,nt),t("div",at,[t("div",ot,[t("span",lt,n(V(r.value[a.index].session.startTs))+" - "+n(V(r.value[a.index].session.endTs)),1)]),t("div",rt,[t("span",null,n(r.value[a.index].session.messageCount)+" 条消息",1),g[1]||(g[1]=t("span",null,"·",-1)),t("span",null,n(U(r.value[a.index].session.startTs,r.value[a.index].session.endTs)),1)])])],2))],4))),128))],4)],512))])])}}}),dt={class:"flex-1 flex flex-col overflow-hidden bg-gray-50 dark:bg-gray-900"},ct={key:0,class:"flex-none px-4 py-3 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"},ut={class:"flex items-center justify-between mb-2"},ft={class:"flex items-center gap-6 text-sm"},gt={class:"text-gray-600 dark:text-gray-400"},yt={class:"font-medium text-gray-900 dark:text-white"},vt={class:"text-gray-600 dark:text-gray-400"},mt={class:"font-medium text-gray-900 dark:text-white"},xt={class:"text-gray-600 dark:text-gray-400"},ht={class:"font-medium text-primary-500"},pt={class:"text-gray-600 dark:text-gray-400"},kt={class:"font-medium text-gray-900 dark:text-white"},bt={class:"flex-1 min-h-0 flex overflow-hidden"},_t={key:1,class:"w-full h-full flex items-center justify-center"},wt={class:"text-center text-gray-400"},$t={key:2,class:"flex-1 flex items-center justify-center"},St={class:"text-center text-gray-400"},It={class:"w-64 flex-none border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 flex flex-col"},Ct={class:"flex-none px-3 py-2 border-b border-gray-200 dark:border-gray-700"},Tt={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Mt=["onClick"],zt={class:"flex items-center justify-between mb-1"},Dt={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Lt={key:0,class:"text-xs text-primary-500"},Bt={class:"text-xs text-gray-500"},Ft={class:"flex items-center gap-2 text-xs text-gray-400 mt-1"},Ut={key:0,class:"py-3 text-center text-sm text-gray-500 dark:text-gray-400 border-t border-gray-100 dark:border-gray-700"},Rt={key:1,class:"py-3 text-center text-xs text-gray-400 dark:text-gray-500"},Pt={class:"flex-1 overflow-hidden"},Vt={key:1,class:"flex items-center justify-center h-full text-gray-400"},Ht=X({__name:"PreviewPanel",props:{result:{},isLoading:{type:Boolean},isLoadingMore:{type:Boolean}},emits:["load-more"],setup(v,{emit:C}){const{t:M}=J(),h=v,m=C,w=$(0);let z=!1;const L=$(null),r=$(null),p=$(null);function k(s){if(!h.result)return null;const e=h.result.blocks.length-1-s;return h.result.blocks[e]}const x=P(()=>h.result?.blocks.length??0),D=fe(P(()=>({count:x.value,getScrollElement:()=>p.value,estimateSize:()=>72,overscan:5}))),B=P(()=>D.value.getVirtualItems()),F=P(()=>{if(x.value===0)return[];const s=k(w.value);return s?s.messages.map(e=>({id:e.id,senderName:e.senderName,senderPlatformId:e.senderPlatformId,senderAliases:e.senderAliases,senderAvatar:e.senderAvatar,content:e.content,timestamp:e.timestamp,type:e.type,replyToMessageId:e.replyToMessageId,replyToContent:e.replyToContent,replyToSenderName:e.replyToSenderName})):[]}),j=P(()=>{if(x.value===0)return[];const s=k(w.value);return s?s.messages.filter(e=>e.isHit).map(e=>e.id):[]}),E={startTs:0,endTs:0},V=P(()=>{if(!h.result||h.result.blocks.length===0)return!1;const s=h.result.blocks,e=new Date(s[0].startTs*1e3).getFullYear(),d=new Date(s[s.length-1].endTs*1e3).getFullYear();return e!==d});function U(s){const e={month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};return V.value&&(e.year="numeric"),new Date(s*1e3).toLocaleString("zh-CN",e)}function c(s,e){const d=e-s;return d<60?`${d}秒`:d<3600?`${Math.floor(d/60)}分钟`:`${Math.floor(d/3600)}h${Math.floor(d%3600/60)}m`}function g(s){w.value=s;const e=k(s);if(e){const d=e.messages.find(f=>f.isHit);d&&(L.value=d.id)}}function o(){z||x.value!==0&&w.value<x.value-1&&(z=!0,w.value++,b(w.value),setTimeout(()=>{z=!1},300))}function a(){}function b(s){D.value.scrollToIndex(s,{align:"center"})}W(()=>h.result,()=>{w.value=0,L.value=null}),W(L,async s=>{s!==null&&(await be(),setTimeout(()=>{r.value?.scrollToMessage(s),L.value=null},100))});function A(s){const e=s.target;if(!e||!h.result?.pagination?.hasMore||h.isLoadingMore)return;const d=100,{scrollTop:f,scrollHeight:i,clientHeight:S}=e;i-f-S<d&&m("load-more")}return(s,e)=>{const d=se;return l(),u("div",dt,[v.result&&v.result.blocks.length>0?(l(),u("div",ct,[t("div",ut,[t("div",ft,[t("span",gt,[T(n(y(M)("analysis.filter.stats.blocks"))+": ",1),t("span",yt,[T(n(v.result.blocks.length)+" ",1),v.result.pagination&&v.result.pagination.totalBlocks>v.result.blocks.length?(l(),u(N,{key:0},[T(" / "+n(v.result.pagination.totalBlocks),1)],64)):H("",!0)])]),t("span",vt,[T(n(y(M)("analysis.filter.stats.messages"))+": ",1),t("span",mt,n(v.result.stats.totalMessages),1)]),t("span",xt,[T(n(y(M)("analysis.filter.stats.hits"))+": ",1),t("span",ht,n(v.result.pagination?.totalHits??v.result.stats.hitMessages),1)]),t("span",pt,[T(n(y(M)("analysis.filter.stats.chars"))+": ",1),t("span",kt,n(v.result.stats.totalChars.toLocaleString()),1)])])])])):H("",!0),t("div",bt,[v.isLoading?(l(),Y($e,{key:0,variant:"page",text:y(M)("analysis.filter.filtering")},null,8,["text"])):v.result?v.result.blocks.length===0?(l(),u("div",$t,[t("div",St,[I(d,{name:"i-heroicons-magnifying-glass",class:"w-12 h-12 mb-3 mx-auto"}),t("p",null,n(y(M)("analysis.filter.noResults")),1)])])):(l(),u(N,{key:3},[t("div",It,[t("div",Ct,[t("span",Tt,[T(n(y(M)("analysis.filter.stats.blocks"))+" ("+n(v.result.blocks.length)+" ",1),v.result.pagination&&v.result.pagination.totalBlocks>v.result.blocks.length?(l(),u(N,{key:0},[T(" /"+n(v.result.pagination.totalBlocks),1)],64)):H("",!0),e[1]||(e[1]=T(" ) ",-1))])]),t("div",{ref_key:"blockListRef",ref:p,class:"flex-1 overflow-y-auto",onScroll:A},[t("div",{style:q({height:`${y(D).getTotalSize()}px`,position:"relative"})},[(l(!0),u(N,null,Z(B.value,f=>(l(),u("div",{key:String(f.key),style:q({position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${f.start}px)`})},[t("div",{class:te(["px-3 py-2 cursor-pointer border-b border-gray-100 dark:border-gray-700 transition-colors",w.value===f.index?"bg-primary-50 dark:bg-primary-900/30 border-l-2 border-l-primary-500":"hover:bg-gray-50 dark:hover:bg-gray-700/50"]),onClick:i=>g(f.index)},[t("div",zt,[t("span",Dt," #"+n(f.index+1),1),(k(f.index)?.hitCount??0)>0?(l(),u("span",Lt," 含 "+n(k(f.index)?.hitCount)+" 个结果 ",1)):H("",!0)]),t("div",Bt,n(U(k(f.index)?.startTs??0)),1),t("div",Ft,[t("span",null,n(k(f.index)?.messages.length??0)+" 条",1),e[2]||(e[2]=t("span",null,"·",-1)),t("span",null,n(c(k(f.index)?.startTs??0,k(f.index)?.endTs??0)),1)])],10,Mt)],4))),128))],4),v.result.pagination?.hasMore?(l(),u("div",Ut,[v.isLoadingMore?(l(),u(N,{key:0},[I(d,{name:"i-heroicons-arrow-path",class:"w-4 h-4 animate-spin inline mr-1"}),T(" "+n(y(M)("common.loading")),1)],64)):(l(),u("button",{key:1,class:"text-primary-500 hover:text-primary-600",onClick:e[0]||(e[0]=f=>m("load-more"))},n(y(M)("analysis.filter.loadMore")),1))])):v.result.pagination&&v.result.blocks.length>=v.result.pagination.totalBlocks?(l(),u("div",Rt,n(y(M)("analysis.filter.allLoaded")),1)):H("",!0)],544)]),t("div",Pt,[F.value.length>0?(l(),Y(me,{key:0,ref_key:"messageListRef",ref:r,query:E,"external-messages":F.value,"hit-message-ids":j.value,class:"h-full",onReachBottom:o,onReachTop:a},null,8,["external-messages","hit-message-ids"])):(l(),u("div",Vt,n(y(M)("analysis.filter.noResults")),1))])],64)):(l(),u("div",_t,[t("div",wt,[I(d,{name:"i-heroicons-funnel",class:"w-12 h-12 mb-3 mx-auto"}),t("p",null,n(y(M)("analysis.filter.emptyHint")),1)])]))])])}}}),jt={class:"flex items-center justify-between"},Et={class:"text-lg font-semibold"},Nt={class:"max-h-96 overflow-y-auto"},At={key:0,class:"py-8 text-center text-gray-500"},Kt={key:1,class:"divide-y divide-gray-200 dark:divide-gray-700"},Yt={class:"flex items-start justify-between gap-2"},Wt={class:"flex-1 min-w-0"},Ot={key:0,class:"flex items-center gap-2 mb-1"},Gt={key:1,class:"flex items-center gap-2 mb-1"},Qt={class:"font-medium text-gray-900 dark:text-white"},Zt=["onClick"],qt={class:"text-sm text-gray-600 dark:text-gray-400 truncate"},Jt={class:"text-xs text-gray-400 mt-1"},Xt={class:"flex items-center gap-1"},es=X({__name:"FilterHistory",props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:we(["load"],["update:open"]),setup(v,{expose:C,emit:M}){const{t:h}=J(),m=ne(),w=xe(),z=Q(v,"open"),L=M,r=$([]);let p=[];const k=$(null),x=$("");async function D(){try{p=(await w.getPreferences()).filterHistory??[],r.value=p.filter(a=>a.sessionId===m.currentSessionId)}catch(o){console.error("Failed to load filter history:",o)}}function B(){p=[...p.filter(a=>a.sessionId!==m.currentSessionId),...r.value],w.savePreferences({filterHistory:p}).catch(a=>{console.error("Failed to save filter history:",a)})}function F(o){r.value=r.value.filter(a=>a.id!==o),B()}function j(o){L("load",{mode:o.mode,conditionFilter:o.conditionFilter,selectedSessionIds:o.selectedSessionIds})}function E(o){k.value=o.id,x.value=o.name}function V(o){o.name=x.value||o.name,k.value=null,B()}function U(){k.value=null}function c(o){return new Date(o).toLocaleString()}function g(o){if(o.mode==="condition"){const a=[];return o.conditionFilter?.keywords.length&&a.push(`关键词: ${o.conditionFilter.keywords.join(", ")}`),o.conditionFilter?.senderIds.length&&a.push(`${o.conditionFilter.senderIds.length} 位成员`),a.join(" | ")||"无条件"}else return`${o.selectedSessionIds?.length||0} 个会话`}return W(z,o=>{o&&D()}),re(()=>{D()}),C({saveCondition(o){const a={id:`filter_${Date.now()}`,sessionId:m.currentSessionId||"",createdAt:Date.now(),name:`筛选 ${r.value.length+1}`,...o};r.value.unshift(a),r.value=r.value.slice(0,20),B()}}),(o,a)=>{const b=le,A=de,s=ce,e=se,d=ge,f=ue;return l(),Y(f,{open:z.value,"onUpdate:open":a[2]||(a[2]=i=>z.value=i)},{content:R(()=>[I(d,null,{header:R(()=>[t("div",jt,[t("h3",Et,n(y(h)("analysis.filter.historyTitle")),1),I(b,{variant:"ghost",icon:"i-heroicons-x-mark",size:"sm",onClick:a[0]||(a[0]=i=>z.value=!1)})])]),default:R(()=>[t("div",Nt,[r.value.length===0?(l(),u("div",At,n(y(h)("analysis.filter.noHistory")),1)):(l(),u("div",Kt,[(l(!0),u(N,null,Z(r.value,i=>(l(),u("div",{key:i.id,class:"py-3 hover:bg-gray-50 dark:hover:bg-gray-800 px-2 rounded-md"},[t("div",Yt,[t("div",Wt,[k.value===i.id?(l(),u("div",Ot,[I(A,{modelValue:x.value,"onUpdate:modelValue":a[1]||(a[1]=S=>x.value=S),size:"sm",class:"flex-1",onKeydown:_e(S=>V(i),["enter"])},null,8,["modelValue","onKeydown"]),I(b,{size:"xs",onClick:S=>V(i)},{default:R(()=>[T(n(y(h)("common.save")),1)]),_:1},8,["onClick"]),I(b,{size:"xs",variant:"ghost",onClick:U},{default:R(()=>[T(n(y(h)("common.cancel")),1)]),_:1})])):(l(),u("div",Gt,[t("span",Qt,n(i.name),1),I(s,{color:i.mode==="condition"?"primary":"green",size:"xs"},{default:R(()=>[T(n(i.mode==="condition"?"条件":"会话"),1)]),_:2},1032,["color"]),t("button",{class:"text-gray-400 hover:text-gray-600",onClick:S=>E(i)},[I(e,{name:"i-heroicons-pencil",class:"w-3 h-3"})],8,Zt)])),t("p",qt,n(g(i)),1),t("p",Jt,n(c(i.createdAt)),1)]),t("div",Xt,[I(b,{size:"xs",variant:"soft",onClick:S=>j(i)},{default:R(()=>[T(n(y(h)("common.load")),1)]),_:1},8,["onClick"]),I(b,{size:"xs",variant:"ghost",color:"red",onClick:S=>F(i.id)},{default:R(()=>[I(e,{name:"i-heroicons-trash",class:"w-4 h-4"})]),_:1},8,["onClick"])])])]))),128))]))])]),_:1})]),_:1},8,["open"])}}}),ts={class:"flex h-[85vh] flex-col overflow-hidden bg-white dark:bg-gray-900"},ss={class:"flex flex-none items-center justify-between border-b border-gray-200 px-5 py-3 dark:border-gray-700"},ns={class:"flex items-center gap-4"},as={class:"text-lg font-semibold text-gray-900 dark:text-white"},os={class:"flex items-center gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},ls={class:"flex items-center gap-2"},rs={class:"flex flex-1 overflow-hidden"},is={class:"flex w-80 flex-none flex-col border-r border-gray-200 dark:border-gray-700"},ds={class:"min-h-0 flex-1 overflow-y-auto"},cs={class:"flex-none border-t border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-900"},us={class:"flex flex-1 flex-col overflow-hidden"},fs={key:0,class:"flex flex-none flex-col gap-2 border-t border-gray-200 bg-gray-50 px-4 py-3 dark:border-gray-700 dark:bg-gray-800"},gs={key:0,class:"w-full"},ys={class:"mb-1 flex items-center justify-between text-sm text-gray-600 dark:text-gray-400"},vs={class:"h-2 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},ms={class:"flex items-center justify-end gap-3"},ee=50,Cs=X({__name:"MessageExportModal",props:{modelValue:{type:Boolean}},emits:["update:modelValue"],setup(v,{emit:C}){const M=v,h=C,{t:m}=J(),w=he(),z=ne(),L=P({get:()=>M.modelValue,set:s=>h("update:modelValue",s)}),r=$("condition"),p=$({keywords:[],timeRange:null,senderIds:[],contextSize:10}),k=$([]),x=$(null),D=$(!1),B=$(!1),F=$(!1),j=P(()=>D.value?!1:r.value==="condition"?p.value.keywords.length>0||p.value.senderIds.length>0||p.value.timeRange!==null:k.value.length>0);async function E(){const s=z.currentSessionId;if(s){D.value=!0,x.value=null;try{if(r.value==="condition"){const e=G(p.value),d=e.keywords.length>0?[...e.keywords]:void 0,f=e.timeRange?{startTs:e.timeRange.start,endTs:e.timeRange.end}:void 0,i=e.senderIds.length>0?[...e.senderIds]:void 0,S=e.contextSize,_=await O().filterMessagesWithContext(s,d,f,i,S,1,ee);x.value=_}else{if(k.value.length===0)return;const e=[...G(k.value)],d=await O().getMultipleSessionsMessages(s,e,1,ee);x.value=d}}catch(e){console.error("筛选失败:",e)}finally{D.value=!1}}}async function V(){const s=z.currentSessionId;if(!s||!x.value||!x.value.pagination.hasMore||B.value)return;B.value=!0;const e=x.value.pagination.page+1;try{let d;if(r.value==="condition"){const f=G(p.value),i=f.keywords.length>0?[...f.keywords]:void 0,S=f.timeRange?{startTs:f.timeRange.start,endTs:f.timeRange.end}:void 0,_=f.senderIds.length>0?[...f.senderIds]:void 0,K=f.contextSize;d=await O().filterMessagesWithContext(s,i,S,_,K,e,ee)}else{const f=[...G(k.value)];d=await O().getMultipleSessionsMessages(s,f,e,ee)}d&&d.blocks.length>0&&(x.value={blocks:[...x.value.blocks,...d.blocks],stats:x.value.stats,pagination:d.pagination})}catch(d){console.error("加载更多失败:",d)}finally{B.value=!1}}const U=$(!1),c=$(null);let g=null;function o(){g=O().onExportProgress(s=>{c.value={percentage:s.percentage,message:s.message},(s.stage==="done"||s.stage==="error")&&(c.value=null)})}function a(){g&&(g(),g=null),c.value=null}async function b(){if(!x.value||x.value.blocks.length===0)return;const s=z.currentSessionId;if(!s)return;const d=z.currentSession?.name||"未知会话",f=await pe().showOpenDialog({title:"选择保存目录",properties:["openDirectory","createDirectory"]});if(f.canceled||!f.filePaths[0])return;const i=f.filePaths[0];U.value=!0,c.value={percentage:0,message:m("analysis.filter.exportPreparing")},o();try{const S=G(p.value),_={sessionId:s,sessionName:d,outputDir:i,filterMode:r.value,keywords:S.keywords.length>0?[...S.keywords]:void 0,timeFilter:S.timeRange?{startTs:S.timeRange.start,endTs:S.timeRange.end}:void 0,senderIds:S.senderIds.length>0?[...S.senderIds]:void 0,contextSize:S.contextSize,chatSessionIds:r.value==="session"?[...G(k.value)]:void 0},K=await O().exportFilterResultToFile(_);K.success&&K.filePath?w.success(m("analysis.filter.exportSuccess"),{description:K.filePath}):w.fail(m("analysis.filter.exportFailed"),{description:K.error||m("common.error.unknown")})}catch(S){console.error("导出失败:",S),w.fail(m("analysis.filter.exportFailed"),{description:String(S)})}finally{a(),U.value=!1}}W(r,()=>{x.value=null}),W(L,s=>{s||(x.value=null,a())});function A(s){r.value=s.mode,s.mode==="condition"&&s.conditionFilter?p.value={...s.conditionFilter}:s.mode==="session"&&s.selectedSessionIds&&(k.value=[...s.selectedSessionIds]),F.value=!1}return(s,e)=>{const d=le,f=ue;return l(),Y(f,{open:L.value,"onUpdate:open":e[10]||(e[10]=i=>L.value=i),ui:{content:"sm:max-w-[95vw]"}},{content:R(()=>[t("div",ts,[t("div",ss,[t("div",ns,[t("h2",as,n(y(m)("analysis.messageExport.title")),1),t("div",os,[t("button",{class:te(["rounded-md px-3 py-1.5 text-sm font-medium transition-colors",r.value==="condition"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"]),onClick:e[0]||(e[0]=i=>r.value="condition")},n(y(m)("analysis.filter.conditionMode")),3),t("button",{class:te(["rounded-md px-3 py-1.5 text-sm font-medium transition-colors",r.value==="session"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"]),onClick:e[1]||(e[1]=i=>r.value="session")},n(y(m)("analysis.filter.sessionMode")),3)])]),t("div",ls,[I(d,{variant:"ghost",icon:"i-heroicons-clock",size:"sm",onClick:e[2]||(e[2]=i=>F.value=!0)},{default:R(()=>[T(n(y(m)("analysis.filter.history")),1)]),_:1}),I(d,{variant:"ghost",icon:"i-heroicons-x-mark",size:"sm",onClick:e[3]||(e[3]=i=>L.value=!1)})])]),t("div",rs,[t("div",is,[t("div",ds,[r.value==="condition"?(l(),Y(We,{key:0,keywords:p.value.keywords,"onUpdate:keywords":e[4]||(e[4]=i=>p.value.keywords=i),"time-range":p.value.timeRange,"onUpdate:timeRange":e[5]||(e[5]=i=>p.value.timeRange=i),"sender-ids":p.value.senderIds,"onUpdate:senderIds":e[6]||(e[6]=i=>p.value.senderIds=i),"context-size":p.value.contextSize,"onUpdate:contextSize":e[7]||(e[7]=i=>p.value.contextSize=i)},null,8,["keywords","time-range","sender-ids","context-size"])):(l(),Y(it,{key:1,"selected-ids":k.value,"onUpdate:selectedIds":e[8]||(e[8]=i=>k.value=i)},null,8,["selected-ids"]))]),t("div",cs,[I(d,{block:"",color:"primary",loading:D.value,disabled:!j.value,onClick:E},{default:R(()=>[T(n(y(m)("analysis.filter.execute")),1)]),_:1},8,["loading","disabled"])])]),t("div",us,[I(Ht,{result:x.value,"is-loading":D.value,"is-loading-more":B.value,onLoadMore:V},null,8,["result","is-loading","is-loading-more"]),x.value&&x.value.blocks.length>0?(l(),u("div",fs,[U.value&&c.value?(l(),u("div",gs,[t("div",ys,[t("span",null,n(c.value.message),1),t("span",null,n(c.value.percentage)+"%",1)]),t("div",vs,[t("div",{class:"h-full bg-primary-500 transition-all duration-300",style:q({width:`${c.value.percentage}%`})},null,4)])])):H("",!0),t("div",ms,[I(d,{variant:"outline",icon:"i-heroicons-document-arrow-down",loading:U.value,disabled:U.value,onClick:b},{default:R(()=>[T(n(y(m)("analysis.filter.export")),1)]),_:1},8,["loading","disabled"])])])):H("",!0)])]),I(es,{open:F.value,"onUpdate:open":e[9]||(e[9]=i=>F.value=i),onLoad:A},null,8,["open"])])]),_:1},8,["open"])}}});export{Cs as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as c}from"./index-
|
|
1
|
+
import{G as c}from"./index-CD5Fz-JY.js";import"./vendor-reka-ui-BrTYuIfH.js";import"./vendor-nuxt-ui-3XQAyMd0.js";import"./vendor-snapdom-XnBoh1gd.js";function i(){return c("data")}class l{async generate(s,t=1800){const e=await fetch(`/_web/sessions/${s}/generate-index`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gapThreshold:t})});if(!e.ok)throw new Error(`Failed to generate session index: ${e.status}`);return(await e.json()).sessionCount}async generateIncremental(s,t=1800){const e=await fetch(`/_web/sessions/${s}/generate-incremental-index`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gapThreshold:t})});if(!e.ok)throw new Error(`Failed to generate incremental session index: ${e.status}`);return(await e.json()).sessionCount}async hasIndex(s){return(await this.getStats(s)).hasIndex}async getStats(s){try{const e=(await i().pluginQuery(s,"SELECT COUNT(*) as cnt FROM chat_session",[]))[0]?.cnt??0;return{hasIndex:e>0,sessionCount:e,gapThreshold:1800}}catch{return{hasIndex:!1,sessionCount:0,gapThreshold:1800}}}async getAllIndexStats(){const s=await fetch("/_web/sessions/index-stats");return s.ok?await s.json():[]}async clear(s){return await fetch(`/_web/sessions/${s}/clear-index`,{method:"POST"}),!0}async updateGapThreshold(s,t){return!0}async getSessions(s){return i().pluginQuery(s,"SELECT id, start_ts as startTs, end_ts as endTs, message_count as messageCount, summary FROM chat_session ORDER BY start_ts ASC",[])}async getByTimeRange(s,t,e){return i().pluginQuery(s,"SELECT id, start_ts as startTs, end_ts as endTs, message_count as messageCount, summary FROM chat_session WHERE start_ts >= ? AND end_ts <= ? ORDER BY start_ts ASC",[t,e])}async getRecent(s,t){return i().pluginQuery(s,"SELECT id, start_ts as startTs, end_ts as endTs, message_count as messageCount, summary FROM chat_session ORDER BY start_ts DESC LIMIT ?",[t])}async generateSummary(s,t,e,a,r){try{const n=await fetch(`/_web/sessions/${s}/summaries/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatSessionId:t,locale:e,forceRegenerate:a,strategy:r})}),o=await n.json();return n.ok?o:{success:!1,error:o.error||`HTTP ${n.status}`}}catch(n){return{success:!1,error:n instanceof Error?n.message:String(n)}}}async generateSummaries(s,t,e){let a=0,r=0;const n=0;for(const o of t)try{(await this.generateSummary(s,o,e)).success?a++:r++}catch{r++}return{success:a,failed:r,skipped:n}}async checkCanGenerateSummary(s,t){try{const e=await fetch(`/_web/sessions/${s}/summaries/check-can-generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatSessionIds:t})});return e.ok?await e.json():{}}catch{return{}}}}export{l as FetchSessionIndexAdapter};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./model-catalog-DUuKjIVU.js";import{G as _}from"./index-
|
|
1
|
+
import"./model-catalog-DUuKjIVU.js";import{G as _}from"./index-CD5Fz-JY.js";import"./vendor-reka-ui-BrTYuIfH.js";import"./vendor-nuxt-ui-3XQAyMd0.js";import"./vendor-snapdom-XnBoh1gd.js";const T=`
|
|
2
2
|
msg.id,
|
|
3
3
|
m.id as senderId,
|
|
4
4
|
COALESCE(m.group_nickname, m.account_name, m.platform_id) as senderName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.fade-enter-active[data-v-90e47115],.fade-leave-active[data-v-90e47115]{transition:opacity .15s ease}.fade-enter-from[data-v-90e47115],.fade-leave-to[data-v-90e47115]{opacity:0}.fade-enter-active[data-v-abeebf4d],.fade-leave-active[data-v-abeebf4d]{transition:opacity .15s ease}.fade-enter-from[data-v-abeebf4d],.fade-leave-to[data-v-abeebf4d]{opacity:0}.tab-slide-enter-active[data-v-
|
|
1
|
+
.fade-enter-active[data-v-90e47115],.fade-leave-active[data-v-90e47115]{transition:opacity .15s ease}.fade-enter-from[data-v-90e47115],.fade-leave-to[data-v-90e47115]{opacity:0}.fade-enter-active[data-v-abeebf4d],.fade-leave-active[data-v-abeebf4d]{transition:opacity .15s ease}.fade-enter-from[data-v-abeebf4d],.fade-leave-to[data-v-abeebf4d]{opacity:0}.tab-slide-enter-active[data-v-88f7d279],.tab-slide-leave-active[data-v-88f7d279]{transition:opacity .2s ease,transform .2s ease}.tab-slide-enter-from[data-v-88f7d279]{opacity:0;transform:translateY(10px)}.tab-slide-leave-to[data-v-88f7d279]{opacity:0;transform:translateY(-10px)}
|