Files
wecom_it_smart_desk/frontend-admin/dist_bak3/assets/RagflowIngestion-BMe8bBWz.js
T

2 lines
5.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{d as A,b as u,c as g,e as t,f as o,w as i,p as x,a5 as B,h as z,r as v,i as p,j as E,au as G,g as m,t as d,V as L,W as h}from"./index-DY_T097o.js";import{_ as P}from"./_plugin-vue_export-helper-DlAUqK2U.js";const U={class:"ragflow-ingestion-page"},H={class:"ragflow-ingestion-page__upload-content"},K={class:"ragflow-ingestion-page__category-select"},O=["accept"],W={key:0,class:"ragflow-ingestion-page__result"},q={class:"ragflow-ingestion-page__result-info"},J={key:0,class:"ragflow-ingestion-page__suggestions"},Q={class:"ragflow-ingestion-page__suggestion-header"},X={class:"ragflow-ingestion-page__suggestion-category"},Y={class:"ragflow-ingestion-page__result-note"},Z={key:1,class:"ragflow-ingestion-page__logs"},ee={class:"ragflow-ingestion-page__log-time"},te=20*1024*1024,ne=A({__name:"RagflowIngestion",setup(oe){const D=[".docx",".pdf",".txt",".png",".jpg",".jpeg"],y=v(),w=v(!1),b=v(!1),k=v("其他"),r=v(null),F=v([]);function R(){var n;(n=y.value)==null||n.click()}function _(n,e){F.value.push({level:n,time:new Date().toLocaleTimeString(),message:e})}function I(n){var s;const a=(s=n.target.files)==null?void 0:s[0];a&&C(a)}function M(n){var a,s;w.value=!1;const e=(s=(a=n.dataTransfer)==null?void 0:a.files)==null?void 0:s[0];e&&C(e)}async function C(n){var a;const e="."+((a=n.name.split(".").pop())==null?void 0:a.toLowerCase());if(!D.includes(e)){_("error",`不支持的文件格式: ${e}`);return}if(n.size>te){_("error",`文件过大: ${(n.size/1024/1024).toFixed(1)}MB(最大 20MB`);return}b.value=!0,_("info",`开始上传: ${n.name}${(n.size/1024).toFixed(1)}KB`);try{const s=new FormData;s.append("file",n),s.append("category_hint",k.value),_("info","上传至 RAGFlow,等待 ETL 处理...");const c=await(await fetch("/api/ragflow/ingest",{method:"POST",body:s})).json();c.code===0&&c.data?(r.value=c.data,_("success",`处理完成!生成 ${c.data.suggestions_count} 条待审提案`)):_("error",`处理失败: ${c.message||"未知错误"}`)}catch(s){_("error",`上传异常: ${s.message}`)}finally{b.value=!1,y.value&&(y.value.value="")}}function S(n){return{completed:"处理完成",failed:"处理失败",pending:"处理中",disabled:"服务未启用",timeout:"处理超时"}[n]||n}return(n,e)=>{const a=p("el-alert"),s=p("el-icon"),f=p("el-option"),c=p("el-select"),T=p("el-button"),V=p("el-tag"),N=p("router-link"),j=p("el-card");return u(),g("div",U,[e[13]||(e[13]=t("div",{class:"ragflow-ingestion-page__header"},[t("h2",null,"📄 文档知识导入(RAGFlow 通道 C")],-1)),o(a,{title:"通过 RAGFlow 将非标准格式文档整理为结构化知识片段,生成待审提案进入审批队列。",type:"info",closable:!1,"show-icon":"",class:"ragflow-ingestion-page__alert"}),t("div",{class:B(["ragflow-ingestion-page__upload",{"ragflow-ingestion-page__upload--dragover":w.value}]),onDragenter:e[1]||(e[1]=x(l=>w.value=!0,["prevent"])),onDragover:e[2]||(e[2]=x(l=>w.value=!0,["prevent"])),onDragleave:e[3]||(e[3]=x(l=>w.value=!1,["prevent"])),onDrop:x(M,["prevent"])},[t("div",H,[o(s,{size:48,color:"#909399"},{default:i(()=>[o(E(G))]),_:1}),e[6]||(e[6]=t("p",{class:"ragflow-ingestion-page__upload-text"}," 拖拽文件到此处,或点击下方按钮选择 ",-1)),e[7]||(e[7]=t("p",{class:"ragflow-ingestion-page__upload-hint"}," 支持 .docx / .pdf / .txt / .png / .jpg,最大 20MB ",-1)),t("div",K,[e[4]||(e[4]=t("span",null,"分类提示:",-1)),o(c,{modelValue:k.value,"onUpdate:modelValue":e[0]||(e[0]=l=>k.value=l),size:"default",style:{width:"140px"}},{default:i(()=>[o(f,{label:"硬件",value:"硬件"}),o(f,{label:"软件",value:"软件"}),o(f,{label:"网络",value:"网络"}),o(f,{label:"安全",value:"安全"}),o(f,{label:"账号",value:"账号"}),o(f,{label:"其他",value:"其他"})]),_:1},8,["modelValue"])]),o(T,{type:"primary",icon:"Upload",size:"default",loading:b.value,class:"ragflow-ingestion-page__upload-btn",onClick:R},{default:i(()=>[...e[5]||(e[5]=[m(" 选择文件并上传 ",-1)])]),_:1},8,["loading"])]),t("input",{ref_key:"fileInput",ref:y,type:"file",accept:D.join(","),class:"ragflow-ingestion-page__file-input",onChange:I},null,40,O)],34),r.value?(u(),g("div",W,[o(j,null,{header:i(()=>[...e[8]||(e[8]=[t("span",null,"处理结果",-1)])]),default:i(()=>[t("div",q,[o(V,{type:r.value.status==="completed"?"success":"warning",size:"default"},{default:i(()=>[m(d(S(r.value.status)),1)]),_:1},8,["type"]),t("span",null,"文件: "+d(r.value.file_name),1),t("span",null,"生成提案: "+d(r.value.suggestions_count)+" 条",1)]),r.value.suggestions&&r.value.suggestions.length>0?(u(),g("div",J,[(u(!0),g(L,null,h(r.value.suggestions,(l,$)=>(u(),g("div",{key:$,class:"ragflow-ingestion-page__suggestion-item"},[t("div",Q,[t("span",null,d(l.title),1),o(V,{size:"small",type:"info"},{default:i(()=>[m("置信度 "+d(Math.round(l.confidence*100))+"%",1)]),_:2},1024)]),t("div",X," 分类: "+d(l.category),1)]))),128))])):z("",!0),t("div",Y,[e[10]||(e[10]=m(" ✅ 生成的提案已进入审批队列,请前往 ",-1)),o(N,{to:"/knowledge-iteration"},{default:i(()=>[...e[9]||(e[9]=[m("知识迭代管理",-1)])]),_:1}),e[11]||(e[11]=m(" 审批。 ",-1))])]),_:1})])):z("",!0),F.value.length>0?(u(),g("div",Z,[o(j,null,{header:i(()=>[...e[12]||(e[12]=[t("span",null,"处理日志",-1)])]),default:i(()=>[(u(!0),g(L,null,h(F.value,(l,$)=>(u(),g("div",{key:$,class:B(["ragflow-ingestion-page__log-item",`ragflow-ingestion-page__log-item--${l.level}`])},[t("span",ee,d(l.time),1),t("span",null,d(l.message),1)],2))),128))]),_:1})])):z("",!0)])}}}),ae=P(ne,[["__scopeId","data-v-9f315502"]]);export{ae as default};