@gientech/modual 2.3.22 → 2.3.24
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 +761 -761
- package/assets/{GientechStreamReader-DXwJoB4O.js → GientechStreamReader-CnAI3q38.js} +12 -17
- package/assets/ReviewSetting-C3B98Nq2.js +415 -0
- package/assets/chevron-right-CrkLSPrQ.js +6 -0
- package/assets/database.svg +11 -11
- package/assets/database_add.svg +53 -53
- package/assets/database_connect.svg +66 -66
- package/assets/database_upload.svg +29 -29
- package/assets/databse.svg +6 -6
- package/assets/defaultWeLogo.svg +14 -14
- package/assets/empty2.png +0 -0
- package/assets/graph.svg +4 -4
- package/assets/{index-w3uoyJPy.js → index-C1CXeTnS.js} +2 -2
- package/assets/{index-CBoQAuTU.js → index-C9Vc57_N.js} +33 -33
- package/assets/knowledge.svg +4 -4
- package/assets/mysql.svg +14 -14
- package/assets/sensitive.svg +5 -5
- package/assets/style-BzPoYUHb.js +191 -0
- package/assets/style10.css +1 -0
- package/assets/style2.css +1 -1
- package/assets/style3.css +1 -1
- package/assets/style4.css +1 -1
- package/assets/style5.css +1 -1
- package/assets/style6.css +1 -1
- package/assets/style7.css +1 -1
- package/assets/style8.css +1 -1
- package/assets/style9.css +1 -1
- package/assistantConfig.js +1 -1
- package/chat.js +1 -1
- package/chatCompare.js +1 -1
- package/database.js +2 -2
- package/databaseId.js +1 -1
- package/graphBase.js +1 -1
- package/index.js +1 -1
- package/modelManage.js +1 -1
- package/package.json +16 -6
- package/reviewManage.d.ts +26 -0
- package/reviewManage.js +184 -0
- package/reviewSetting.d.ts +80 -0
- package/reviewSetting.js +1 -0
- package/streamFilesReader.js +1 -1
- package/worker/pdf.worker.min.js +21 -21
- package/assets/Empty2.png +0 -0
- package/assets/ReviewManage-D7aZe-m0.js +0 -690
- package/assets/allUser.png +0 -0
- package/assets/group.png +0 -0
- package/assets/iconAi.svg +0 -9
- /package/assets/{index-CJfOfBmA.js → index-CxKRvyc8.js} +0 -0
|
@@ -1,44 +1,39 @@
|
|
|
1
|
-
import{jsxs as p,jsx as c,Fragment as
|
|
1
|
+
import{jsxs as p,jsx as c,Fragment as gu}from"react/jsx-runtime";import zu,{useState as k,useRef as S,useEffect as eu,useCallback as d,useMemo as Tu}from"react";import M from"styled-components";import du from"axios";import{parseFile as mu,Fviewer as iu}from"@mxmweb/fviewer";import{c as H}from"./createLucideIcon-Bj5DlX2s.js";import{C as ue}from"./chevron-right-CrkLSPrQ.js";import{X as ee}from"./x-CdZQbi--.js";/**
|
|
2
2
|
* @license lucide-react v0.456.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const oe=H("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
|
7
7
|
* @license lucide-react v0.456.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const te=H("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
12
12
|
* @license lucide-react v0.456.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const ne=H("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
|
|
17
17
|
* @license lucide-react v0.456.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const re=H("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
|
|
22
22
|
* @license lucide-react v0.456.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const ae=H("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
|
|
27
27
|
* @license lucide-react v0.456.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const ce=H("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
|
|
32
32
|
* @license lucide-react v0.456.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
37
|
-
* @license lucide-react v0.456.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const se=K("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),le=M.div`
|
|
36
|
+
*/const se=H("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),le=M.div`
|
|
42
37
|
display: flex;
|
|
43
38
|
align-items: center;
|
|
44
39
|
padding: 0px 12px;
|
|
@@ -90,12 +85,12 @@ import{jsxs as p,jsx as c,Fragment as Du}from"react/jsx-runtime";import zu,{useS
|
|
|
90
85
|
opacity: 0.5;
|
|
91
86
|
cursor: not-allowed;
|
|
92
87
|
}
|
|
93
|
-
`,
|
|
88
|
+
`,De=M.div`
|
|
94
89
|
font-size: 12px;
|
|
95
90
|
color: ${t=>t.$theme.colors.disabledText};
|
|
96
91
|
min-width: 40px;
|
|
97
92
|
text-align: center;
|
|
98
|
-
`,
|
|
93
|
+
`,ge={colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080"},space:{sidebar:"md",size:"md",radius:"md",padding:"md",margin:"md",shadow:"md",lineHeight:"md"}},Lu=zu.memo(({fileName:t="\u672A\u77E5\u6587\u4EF6",currentPage:l=1,totalPage:o=0,tools:g={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!0},styles:A,onPrevPage:ou,onNextPage:D,onZoomIn:U,onZoomOut:m,onAnnotationToggle:P,onDownload:h,onRotateLeft:s,onRotateRight:N,onClose:$,scale:B=1,isAnnotating:W=!1,className:tu})=>{const i=(A==null?void 0:A.theme)||ge;return console.log("Header\u7EC4\u4EF6\u6E32\u67D3 - currentPage:",l,"totalPage:",o),p(le,{$theme:i,className:tu,children:[c(de,{$theme:i,children:c(ie,{$theme:i,children:t})}),p(he,{$theme:i,children:[g.navigation&&p(gu,{children:[c(j,{$theme:i,onClick:ou,disabled:l<=1,title:"\u4E0A\u4E00\u9875",children:c(oe,{size:16})}),o>0&&p(Fe,{$theme:i,children:[l," / ",o]}),c(j,{$theme:i,onClick:D,disabled:!o||l>=o,title:"\u4E0B\u4E00\u9875",children:c(ue,{size:16})})]}),g.zoom&&p(gu,{children:[c(j,{$theme:i,onClick:m,disabled:B<=.3,title:"\u7F29\u5C0F",children:c(se,{size:16})}),p(De,{$theme:i,children:[Math.round(B*100),"%"]}),c(j,{$theme:i,onClick:U,disabled:B>=3,title:"\u653E\u5927",children:c(ce,{size:16})})]}),g.annotation&&c(j,{$theme:i,$active:W,onClick:P,title:W?"\u9000\u51FA\u6807\u6CE8":"\u5F00\u59CB\u6807\u6CE8",children:c(ne,{size:16})}),g.download&&c(j,{$theme:i,onClick:h,title:"\u4E0B\u8F7D",children:c(te,{size:16})}),g.rotate&&p(gu,{children:[c(j,{$theme:i,onClick:s,title:"\u5411\u5DE6\u65CB\u8F6C",children:c(re,{size:16})}),c(j,{$theme:i,onClick:N,title:"\u5411\u53F3\u65CB\u8F6C",children:c(ae,{size:16})})]}),g.close&&c(j,{$theme:i,onClick:$,title:"\u5173\u95ED",children:c(ee,{size:16})})]})]})}),fu=M.div`
|
|
99
94
|
display: flex;
|
|
100
95
|
flex-direction: column;
|
|
101
96
|
height: 100%;
|
|
@@ -148,7 +143,7 @@ import{jsxs as p,jsx as c,Fragment as Du}from"react/jsx-runtime";import zu,{useS
|
|
|
148
143
|
color: ${t=>t.$theme.colors.error};
|
|
149
144
|
text-align: center;
|
|
150
145
|
padding: 20px;
|
|
151
|
-
`,Ce="http://10.15.12.13:9005/proxy/index/knowledgeBase/file/stream",b=300*1e3,Be={colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080"},space:{sidebar:"12px",size:"12px",radius:"4px",padding:"8px 12px",margin:"4px",shadow:"0 2px 4px rgba(0,0,0,0.1)",lineHeight:"1.5"}};function Su(t){const l=new TextDecoder("utf-8",{fatal:!1}).decode(t),o=(l.match(/\uFFFD/g)||[]).length;if(o===0||l.length<20)return l;try{const D=new TextDecoder("gb18030",{fatal:!1}).decode(t);return(D.match(/\uFFFD/g)||[]).length<o?D:l}catch{return l}}const Re=({convertedFilePath:t,fileName:l,fileType:o,csrfToken:D,initialPage:A=1,initialZoom:ou=1,totalPages:g,annotations:U=[],pageSize:m=5,streamApiUrl:P=Ce,authorization:h,eventsEmit:s=()=>{},tools:N,styles:$,customComponents:B,className:W,headerClass:tu,contentClass:i})=>{const[nu,f]=x(!0),[Cu,C]=x("\u6B63\u5728\u52A0\u8F7D\u6587\u6863..."),[ru,I]=x(null),[R,X]=x(A),[w,Y]=x(g||0),[y,Bu]=x(ou),[z,Fu]=x(0),[Ku,wu]=x(null),[Eu,ku]=x(null),[q,xu]=x(""),[pu,au]=x(null),[$u,bu]=x(null),[hu,cu]=x({}),J=S(!1),T=S(!1),Q=S({}),_=S({}),V=S(null),Xu=S(null),Z=S(A),Au=S(0);Au.current+=1,console.log("[GientechStreamReader] render count:",Au.current),console.log("[GientechStreamReader] props snapshot (early):",{fileType:o,currentPage:R,totalPages:w,hasMarkdown:!!q,hasImage:!!Eu,hasText:!!pu,hasHtml:!!$u,isLoading:nu,error:ru});const G=($==null?void 0:$.theme)||Be;eu(()=>{J.current=!1,T.current=!1},[o,t]);const H=d(()=>{const u={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!1};let e;switch(o){case"pdf":case"pdf_slides":e={...u,annotation:!1,download:!1,navigation:!0,rotate:!1};break;case"image":e={...u,annotation:!1,download:!1,navigation:!1,rotate:!0,zoom:!0};break;case"markdown":case"markdown_table":e={...u,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;case"text":case"html":case"unknown":e={...u,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;default:e=u}return N?{...e,...N}:e},[o,N])(),L=d((u,e)=>{const r=Math.floor((u-1)/e)*e+1;return`${r}-${r+e-1}`},[]),Pu=d(async u=>{var E;if(!(o==="pdf"||o==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7\u7F13\u5B58\u68C0\u67E5`),null;console.log(`\u68C0\u67E5\u9875\u9762 ${u} \u662F\u5426\u5728\u7F13\u5B58\u4E2D`);const r=Q.current[u];if(r&&Date.now()-r.timestamp<b)return console.log(`\u4F7F\u7528\u5355\u4E2A\u9875\u9762\u7F13\u5B58: ${u}`),r.pdfDocument?(console.log(`\u76F4\u63A5\u8FD4\u56DE\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),r.pdfDocument):null;const n=L(u,m),a=_.current[n];if(console.log(`\u68C0\u67E5chunk\u7F13\u5B58: ${n}, \u5B58\u5728: ${!!a}, \u5305\u542B\u9875\u9762: ${((E=a==null?void 0:a.pages)==null?void 0:E.join(", "))||"\u65E0"}`),a&&Date.now()-a.timestamp<b){if(a.pages.includes(u))return console.log(`\u4F7F\u7528chunk\u7F13\u5B58: ${u} (chunk: ${n})`),a.pdfDocument?(console.log(`\u76F4\u63A5\u8FD4\u56DE\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),a.pdfDocument):null;console.log(`\u9875\u9762 ${u} \u4E0D\u5728chunk ${n} \u4E2D\uFF0Cchunk\u5305\u542B: ${a.pages.join(", ")}`)}return console.log(`\u9875\u9762 ${u} \u4E0D\u5728\u4EFB\u4F55\u7F13\u5B58\u4E2D\uFF0C\u9700\u8981\u91CD\u65B0\u8BF7\u6C42`),null},[m,L,o]),Ru=d(async u=>{var e;try{if(!(o==="pdf"||o==="pdf_slides"))throw console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u9700\u8981\u5206\u9875\u53C2\u6570\uFF0C\u83B7\u53D6\u5B8C\u6574\u5185\u5BB9`),new Error(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u5206\u9875\u52A0\u8F7D`);const n=Math.floor((u-1)/m)*m+1,a=L(u,m);console.log(`\u8BF7\u6C42PDF chunk\u6570\u636E: ${n} (\u5305\u542B\u9875\u9762 ${n}-${n+m-1})`);const E={"Content-Type":"application/json"};h&&(E.Authorization=h),D&&(E["X-CSRF-TOKEN-IN"]=D);const k={convertedFilePath:t,pageNo:n,pageSize:m},F=await du.post(P,k,{headers:E,responseType:"arraybuffer"}),O=F.headers["x-csrf-token-out"]||F.headers["X-CSRF-TOKEN-OUT"];O&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",O),s("request_finish",O));const uu=Array.from({length:m},(Ee,Nu)=>n+Nu);return _.current[a]={data:F.data,pages:uu,timestamp:Date.now(),totalPages:g},console.log(`\u7F13\u5B58PDF chunk\u6570\u636E: ${a}, \u5305\u542B\u9875\u9762: ${uu.join(", ")}, \u8BF7\u6C42\u7684\u9875\u9762: ${u}`),console.log("\u5F53\u524D\u6240\u6709\u7F13\u5B58:",Object.keys(_.current)),F.data}catch(r){throw console.error("\u83B7\u53D6PDF stream\u6570\u636E\u5931\u8D25:",r),new Error(`PDF\u8BF7\u6C42\u5931\u8D25: ${((e=r.response)==null?void 0:e.status)||"\u7F51\u7EDC\u9519\u8BEF"}`)}},[P,t,m,h,L,g,w,o,s]),gu=d(async(u,e=!1)=>{var n;if(!u)return;if(!(o==="pdf"||o==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7PDF\u52A0\u8F7D\u903B\u8F91`),null;try{e?(f(!0),C("\u6B63\u5728\u52A0\u8F7DPDF\u6587\u6863...")):(f(!0),C(`\u6B63\u5728\u52A0\u8F7D\u7B2C ${u} \u9875...`)),I(null),console.log(`\u5F00\u59CB\u52A0\u8F7DPDF\u9875\u9762: ${u}, \u521D\u59CB\u52A0\u8F7D: ${e}`);const a=await Pu(u);if(a)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),wu(a),f(!1),C(""),console.log(`\u9875\u9762 ${u} \u52A0\u8F7D\u5B8C\u6210\uFF08\u4F7F\u7528\u7F13\u5B58\uFF09`),a;const E=await Ru(u),k=await mu(E,{fileName:l||"Stream\u6587\u6863",fileType:"pdf",token:h});if(k.error)throw new Error(k.error);if(k.type!=="pdf"||!((n=k.content)!=null&&n.document))throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684PDF\u6587\u6863");const F=k.content.document;console.log("\u8BBE\u7F6EPDF\u6587\u6863:",F),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof F),console.log("PDF\u6587\u6863\u65B9\u6CD5:",F?Object.getOwnPropertyNames(Object.getPrototypeOf(F)):"\u65E0\u6587\u6863"),console.log("PDF\u6587\u6863\u9875\u6570:",F?F.numPages:"\u65E0\u9875\u6570"),console.log("\u5F53\u524D\u8BF7\u6C42\u7684\u9875\u9762:",u),console.log("PDF\u6587\u6863\u5305\u542B\u7684\u9875\u9762\u8303\u56F4:",F?`1-${F.numPages}`:"\u65E0\u9875\u6570"),wu(F);const O=L(u,m);if(_.current[O]&&(_.current[O].pdfDocument=F,console.log(`\u7F13\u5B58PDF\u6587\u6863\u5230chunk: ${O}`)),g)console.log(`\u4F7F\u7528\u7528\u6237\u4F20\u5165\u7684\u603B\u9875\u6570: ${g}`),Y(g);else if(F&&F.numPages){const uu=F.numPages;console.log(`\u7528\u6237\u672A\u4F20\u5165\u603B\u9875\u6570\uFF0C\u4ECEPDF\u6587\u6863\u83B7\u53D6\u5B9E\u9645\u603B\u9875\u6570: ${uu}`),Y(uu)}return f(!1),C(""),console.log(`\u9875\u9762 ${u} \u52A0\u8F7D\u5B8C\u6210`),F}catch(a){throw console.error("PDF\u52A0\u8F7D\u5931\u8D25:",a),I(a.message||"PDF\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),a}},[Ru,l,h,w,Pu,L,m,o]),yu=d(u=>{if(!(o==="pdf"||o==="pdf_slides"))return!1;const r=Q.current[u];if(r&&Date.now()-r.timestamp<b)return!!r.pdfDocument;const n=L(u,m),a=_.current[n];return a&&Date.now()-a.timestamp<b?a.pages.includes(u)&&!!a.pdfDocument:!1},[m,L,o]),_u=d(()=>{console.log("\u68C0\u67E5markdown\u5185\u5BB9\u662F\u5426\u5728\u7F13\u5B58\u4E2D");const u=V.current;return u&&Date.now()-u.timestamp<b?(console.log("\u4F7F\u7528markdown\u5185\u5BB9\u7F13\u5B58"),u.data):(console.log("markdown\u5185\u5BB9\u4E0D\u5728\u7F13\u5B58\u4E2D\uFF0C\u9700\u8981\u91CD\u65B0\u8BF7\u6C42"),null)},[]),vu=d(async()=>{var u;try{console.log("\u8BF7\u6C42\u5B8C\u6574markdown\u6570\u636E");const e={"Content-Type":"application/json"};h&&(e.Authorization=h),D&&(e["X-CSRF-TOKEN-IN"]=D);const r={convertedFilePath:t};console.log("\u53D1\u9001markdown\u8BF7\u6C42:",r);const n=await du.post(P,r,{headers:e,responseType:"text"}),a=n.headers["x-csrf-token-out"]||n.headers["X-CSRF-TOKEN-OUT"];return a&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",a),s("request_finish",a)),console.log("markdown\u54CD\u5E94\u72B6\u6001:",n.status),console.log("markdown\u54CD\u5E94\u6570\u636E\u957F\u5EA6:",((u=n.data)==null?void 0:u.length)||0),n.data}catch(e){throw console.error("\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25:",e),new Error(`\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25: ${e.message}`)}},[t,h,P,s]),qu=d(async()=>{try{f(!0),C("\u6B63\u5728\u52A0\u8F7Dmarkdown\u6587\u6863..."),I(null),console.log("\u5F00\u59CB\u52A0\u8F7D\u5B8C\u6574markdown\u6587\u6863");const u=_u();if(u)return console.log("\u4F7F\u7528\u7F13\u5B58\u7684markdown\u5185\u5BB9"),xu(u),f(!1),C(""),u;const e=await vu();return V.current={data:e,timestamp:Date.now()},xu(e),f(!1),C(""),console.log("\u5B8C\u6574markdown\u6587\u6863\u52A0\u8F7D\u5B8C\u6210"),e}catch(u){throw console.error("markdown\u52A0\u8F7D\u5931\u8D25:",u),I(u.message||"markdown\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),u}},[vu,_u]),Iu=d(async()=>{try{const u={"Content-Type":"application/json"};h&&(u.Authorization=h),D&&(u["X-CSRF-TOKEN-IN"]=D);const e={convertedFilePath:t},r=await du.post(P,e,{headers:u,responseType:"arraybuffer"}),n=r.headers["x-csrf-token-out"]||r.headers["X-CSRF-TOKEN-OUT"];return n&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",n),s("request_finish",n)),r.data}catch(u){throw console.error("\u83B7\u53D6\u56FE\u7247\u6570\u636E\u5931\u8D25:",u),new Error(`\u83B7\u53D6\u56FE\u7247\u6570\u636E\u5931\u8D25: ${u.message}`)}},[t,h,P,s]),Zu=d(async()=>{try{f(!0),C("\u6B63\u5728\u52A0\u8F7D\u56FE\u7247..."),I(null);const u=await Iu(),e=await mu(u,{fileName:l||"\u56FE\u7247",fileType:"image",token:h});if(e.error)throw new Error(e.error);if(e.type!=="image"||!e.content)throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684\u56FE\u7247");return ku(e.content),f(!1),C(""),e.content}catch(u){throw console.error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25:",u),I(u.message||"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),u}},[h,l,Iu]),Ou=d(async()=>{var u;try{console.log(`\u8BF7\u6C42\u901A\u7528\u6587\u4EF6\u6570\u636E\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);const e={"Content-Type":"application/json"};h&&(e.Authorization=h),D&&(e["X-CSRF-TOKEN-IN"]=D);const r={convertedFilePath:t};console.log("\u53D1\u9001\u901A\u7528\u6587\u4EF6\u8BF7\u6C42:",r);const n=await du.post(P,r,{headers:e,responseType:"arraybuffer"}),a=n.headers["x-csrf-token-out"]||n.headers["X-CSRF-TOKEN-OUT"];return a&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",a),s("request_finish",a)),console.log("\u901A\u7528\u6587\u4EF6\u54CD\u5E94\u72B6\u6001:",n.status),console.log("\u901A\u7528\u6587\u4EF6\u54CD\u5E94\u6570\u636E\u957F\u5EA6:",((u=n.data)==null?void 0:u.byteLength)||0),n.data}catch(e){throw console.error("\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25:",e),new Error(`\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25: ${e.message}`)}},[t,h,P,s]),Gu=d(async()=>{try{if(console.log("=== loadGenericDocument \u88AB\u8C03\u7528 ==="),console.log("\u8C03\u7528\u6808:",new Error().stack),console.log("\u5F53\u524D\u65F6\u95F4:",new Date().toISOString()),J.current){console.log(`\u901A\u7528\u6587\u6863\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u5FFD\u7565\u91CD\u590D\u8BF7\u6C42\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);return}if(T.current){console.log(`\u901A\u7528\u6587\u6863\u5DF2\u7ECF\u52A0\u8F7D\u8FC7\uFF0C\u5FFD\u7565\u91CD\u590D\u8BF7\u6C42\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);return}const u=`${o}_${t}`,e=hu[u];if(console.log(`\u68C0\u67E5\u901A\u7528\u6587\u6863\u7F13\u5B58\uFF0Ckey: ${u}, \u7F13\u5B58\u5B58\u5728: ${!!e}, \u7F13\u5B58\u65F6\u95F4: ${e?Date.now()-e.timestamp:"N/A"}ms`),e&&Date.now()-e.timestamp<b)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684\u901A\u7528\u6587\u6863\u5185\u5BB9\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`),o==="text"&&e.content?au(e.content):o==="html"&&e.content&&bu(e.content),X(1),Y(g||1),f(!1),C(""),e.content;J.current=!0,f(!0),C(`\u6B63\u5728\u52A0\u8F7D${o}\u6587\u6863...`),I(null),console.log(`\u5F00\u59CB\u52A0\u8F7D\u901A\u7528\u6587\u6863\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);const r=await Ou();if(o==="text"){const k={type:"text",content:Su(r)};au(k);const F=`text_${t}`;return cu(O=>({...O,[F]:{content:k,timestamp:Date.now()}})),f(!1),C(""),J.current=!1,T.current=!0,console.log(`\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5B8C\u6210\uFF08text \u76F4\u89E3\uFF09\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`),k}const n=await mu(r,{fileName:l||`${o}\u6587\u6863`,fileType:o,token:h});if(n.error)throw new Error(n.error);let a=null;if(n.type==="text"&&n.content)au(n.content),a=n.content;else if(n.type==="html"&&n.content)bu(n.content),a=n.content;else if(n.type==="image"&&n.content)ku(n.content),a=n.content;else{const E=Su(r);au({type:"text",content:E}),a={type:"text",content:E}}if(a){const E=`${o}_${t}`,k={...hu,[E]:{content:a,timestamp:Date.now()}};cu(k),console.log(`\u901A\u7528\u6587\u6863\u5185\u5BB9\u5DF2\u7F13\u5B58\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}, \u7F13\u5B58\u952E: ${E}`),console.log("\u5F53\u524D\u7F13\u5B58\u72B6\u6001:",k)}return f(!1),C(""),J.current=!1,T.current=!0,console.log(`\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5B8C\u6210\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`),n}catch(u){throw console.error("\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25:",u),I(u.message||"\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),J.current=!1,T.current=!0,u}},[Ou,l,h,o,t,hu,g]),su=d(async u=>{if(u===Z.current)return;if(nu){console.log("\u9875\u9762\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42");return}if(!(o==="pdf"||o==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}console.log("PDF\u9875\u9762\u53D8\u5316:",u,"\u5F53\u524D\u9875:",Z.current),console.log(`\u9875\u9762 ${u} \u662F\u5426\u5728\u7F13\u5B58\u4E2D:`,yu(u)),Z.current=u,X(u);try{await gu(u,!1),s("pageChange",{pageNumber:u,totalPages:g||w})}catch(r){console.error("PDF\u9875\u9762\u52A0\u8F7D\u5931\u8D25:",r);const n=Z.current;X(n)}},[gu,w,s,yu,nu,o]);eu(()=>{Z.current=R,console.log("\u5F53\u524D\u9875\u72B6\u6001\u66F4\u65B0:",R)},[R]);const lu=d(u=>{Bu(u),s("zoomChange",{scale:u})},[s]),ju=d(()=>{s("viewer:close")},[s]),Hu=d(()=>{const u=Math.min(3,y+.1);lu(u)},[y,lu]),Uu=d(()=>{const u=Math.max(.3,y-.1);lu(u)},[y,lu]),Wu=d(()=>{const u=(z-90+360)%360;Fu(u),s("rotateChange",{rotation:u})},[z,s]),Yu=d(()=>{const u=(z+90)%360;Fu(u),s("rotateChange",{rotation:u})},[z,s]),Ju=d(()=>{if(!(o==="pdf"||o==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const e=Z.current-1;e>=1&&su(e)},[su,o]),Qu=d(()=>{if(!(o==="pdf"||o==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const e=Z.current+1,r=g||w;r&&e<=r&&su(e)},[w,su,o]),Mu=d(()=>{const u=Date.now();Object.keys(Q.current).forEach(e=>{const r=Q.current[parseInt(e)];u-r.timestamp>b&&(delete Q.current[parseInt(e)],console.log(`\u6E05\u7406\u8FC7\u671F\u9875\u9762\u7F13\u5B58: ${e}`))}),Object.keys(_.current).forEach(e=>{const r=_.current[e];u-r.timestamp>b&&(delete _.current[e],console.log(`\u6E05\u7406\u8FC7\u671Fchunk\u7F13\u5B58: ${e}`))}),V.current&&u-V.current.timestamp>b&&(V.current=null,console.log("\u6E05\u7406\u8FC7\u671Fmarkdown\u5185\u5BB9\u7F13\u5B58")),cu(e=>{const r={...e};return Object.keys(r).forEach(n=>{u-r[n].timestamp>b&&(delete r[n],console.log(`\u6E05\u7406\u8FC7\u671F\u901A\u7528\u6587\u4EF6\u7F13\u5B58: ${n}`))}),r})},[]),v=d(()=>{if(l)return l;try{const u=new URL(t);return decodeURIComponent(u.pathname.split("/").pop()||"")||"Stream\u6587\u6863"}catch{const u=t.split("/");return decodeURIComponent(u[u.length-1])||"Stream\u6587\u6863"}},[t,l]);eu(()=>{const u=setInterval(Mu,b);return()=>clearInterval(u)},[Mu]),eu(()=>()=>{Q.current={},_.current={},V.current=null,cu({}),console.log("\u7EC4\u4EF6\u5378\u8F7D\uFF0C\u6E05\u7406\u6240\u6709\u7F13\u5B58")},[]),eu(()=>{console.log("=== useEffect \u88AB\u89E6\u53D1 ==="),console.log("\u89E6\u53D1\u65F6\u95F4:",new Date().toISOString()),console.log("\u89E6\u53D1\u539F\u56E0:",{initialPage:A,fileType:o}),(async()=>{try{const e=o==="pdf"||o==="pdf_slides",r=e&&A||1;console.log("\u5F00\u59CB\u521D\u59CB\u52A0\u8F7D\uFF0C\u6587\u4EF6\u7C7B\u578B:",o,"\u6709\u6548\u9875\u7801:",r,"\u662F\u5426PDF:",e),o==="markdown"||o==="markdown_table"?(await qu(),X(1),Y(g||1),s("pageChange",{pageNumber:1,totalPages:g||1})):o==="image"?(await Zu(),X(1),Y(g||1),Fu(0),s("pageChange",{pageNumber:1,totalPages:g||1})):e?(await gu(r,!0),X(r),setTimeout(()=>{s("pageChange",{pageNumber:r,totalPages:g||w})},0)):(console.log("=== \u521D\u59CB\u52A0\u8F7D\uFF1A\u4F7F\u7528\u901A\u7528\u52A0\u8F7D\u51FD\u6570\u5904\u7406\u6587\u4EF6\u7C7B\u578B ===",o),await Gu(),X(1),Y(g||1),s("pageChange",{pageNumber:1,totalPages:g||1}))}catch(e){console.error("\u521D\u59CB\u52A0\u8F7D\u5931\u8D25:",e),I((e==null?void 0:e.message)||"\u6587\u4EF6\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C("")}})()},[A,o,t]);const Vu=Tu(()=>Math.floor((R-1)/m)*m+1,[R,m]);return ru?c(fu,{$theme:G,className:W,children:B!=null&&B.ErrorComponent?c(B.ErrorComponent,{error:ru,theme:G}):p(fe,{$theme:G,children:[c("div",{children:"\u52A0\u8F7D\u5931\u8D25"}),c("div",{style:{fontSize:"12px",marginTop:"8px"},children:ru})]})}):nu?p(fu,{$theme:G,className:W,children:[c(Lu,{fileName:v(),currentPage:R,totalPage:w,scale:y,isAnnotating:!1,tools:H,styles:$,onPrevPage:()=>{},onNextPage:()=>{},onZoomIn:()=>{},onZoomOut:()=>{},onAnnotationToggle:()=>{},onDownload:()=>{},onClose:ju,className:tu}),B!=null&&B.LoadingComponent?c(B.LoadingComponent,{status:Cu,theme:G}):c(me,{status:Cu,theme:G})]}):p(fu,{$theme:G,className:W,children:[c(Lu,{fileName:v(),currentPage:R,totalPage:w,scale:y,isAnnotating:!1,tools:{...H,navigation:o==="pdf"||o==="pdf_slides"?H.navigation:!1,rotate:o==="image"},styles:$,onPrevPage:Ju,onNextPage:Qu,onZoomIn:Hu,onZoomOut:Uu,onRotateLeft:o==="image"?Wu:void 0,onRotateRight:o==="image"?Yu:void 0,onAnnotationToggle:()=>{},onDownload:()=>{},onClose:ju,className:tu}),o==="markdown"||o==="markdown_table"?p("div",{ref:Xu,style:{flex:1,overflow:"auto",position:"relative"},className:["gientech-stream-reader-content",i].filter(Boolean).join(" "),children:[c("style",{children:`
|
|
146
|
+
`,Ce="http://10.15.12.13:9005/proxy/index/knowledgeBase/file/stream",b=300*1e3,Be={colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080"},space:{sidebar:"12px",size:"12px",radius:"4px",padding:"8px 12px",margin:"4px",shadow:"0 2px 4px rgba(0,0,0,0.1)",lineHeight:"1.5"}};function Su(t){const l=new TextDecoder("utf-8",{fatal:!1}).decode(t),o=(l.match(/\uFFFD/g)||[]).length;if(o===0||l.length<20)return l;try{const g=new TextDecoder("gb18030",{fatal:!1}).decode(t);return(g.match(/\uFFFD/g)||[]).length<o?g:l}catch{return l}}const ye=({convertedFilePath:t,fileName:l,fileType:o,csrfToken:g,initialPage:A=1,initialZoom:ou=1,totalPages:D,annotations:U=[],pageSize:m=5,streamApiUrl:P=Ce,authorization:h,eventsEmit:s=()=>{},tools:N,styles:$,customComponents:B,className:W,headerClass:tu,contentClass:i})=>{const[nu,f]=k(!0),[Cu,C]=k("\u6B63\u5728\u52A0\u8F7D\u6587\u6863..."),[ru,I]=k(null),[R,K]=k(A),[w,Y]=k(D||0),[y,Bu]=k(ou),[z,Fu]=k(0),[Ku,wu]=k(null),[Eu,xu]=k(null),[X,ku]=k(""),[pu,au]=k(null),[$u,bu]=k(null),[hu,cu]=k({}),J=S(!1),T=S(!1),Q=S({}),_=S({}),V=S(null),Xu=S(null),q=S(A),Au=S(0);Au.current+=1,console.log("[GientechStreamReader] render count:",Au.current),console.log("[GientechStreamReader] props snapshot (early):",{fileType:o,currentPage:R,totalPages:w,hasMarkdown:!!X,hasImage:!!Eu,hasText:!!pu,hasHtml:!!$u,isLoading:nu,error:ru});const Z=($==null?void 0:$.theme)||Be;eu(()=>{J.current=!1,T.current=!1},[o,t]);const G=d(()=>{const u={annotation:!0,download:!0,zoom:!0,close:!0,navigation:!0,rotate:!1};let e;switch(o){case"pdf":case"pdf_slides":e={...u,annotation:!1,download:!1,navigation:!0,rotate:!1};break;case"image":e={...u,annotation:!1,download:!1,navigation:!1,rotate:!0,zoom:!0};break;case"markdown":case"markdown_table":e={...u,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;case"text":case"html":case"unknown":e={...u,annotation:!1,download:!1,navigation:!1,rotate:!1,zoom:!1};break;default:e=u}return N?{...e,...N}:e},[o,N])(),L=d((u,e)=>{const r=Math.floor((u-1)/e)*e+1;return`${r}-${r+e-1}`},[]),Pu=d(async u=>{var E;if(!(o==="pdf"||o==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7\u7F13\u5B58\u68C0\u67E5`),null;console.log(`\u68C0\u67E5\u9875\u9762 ${u} \u662F\u5426\u5728\u7F13\u5B58\u4E2D`);const r=Q.current[u];if(r&&Date.now()-r.timestamp<b)return console.log(`\u4F7F\u7528\u5355\u4E2A\u9875\u9762\u7F13\u5B58: ${u}`),r.pdfDocument?(console.log(`\u76F4\u63A5\u8FD4\u56DE\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),r.pdfDocument):null;const n=L(u,m),a=_.current[n];if(console.log(`\u68C0\u67E5chunk\u7F13\u5B58: ${n}, \u5B58\u5728: ${!!a}, \u5305\u542B\u9875\u9762: ${((E=a==null?void 0:a.pages)==null?void 0:E.join(", "))||"\u65E0"}`),a&&Date.now()-a.timestamp<b){if(a.pages.includes(u))return console.log(`\u4F7F\u7528chunk\u7F13\u5B58: ${u} (chunk: ${n})`),a.pdfDocument?(console.log(`\u76F4\u63A5\u8FD4\u56DE\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),a.pdfDocument):null;console.log(`\u9875\u9762 ${u} \u4E0D\u5728chunk ${n} \u4E2D\uFF0Cchunk\u5305\u542B: ${a.pages.join(", ")}`)}return console.log(`\u9875\u9762 ${u} \u4E0D\u5728\u4EFB\u4F55\u7F13\u5B58\u4E2D\uFF0C\u9700\u8981\u91CD\u65B0\u8BF7\u6C42`),null},[m,L,o]),Ru=d(async u=>{var e;try{if(!(o==="pdf"||o==="pdf_slides"))throw console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u9700\u8981\u5206\u9875\u53C2\u6570\uFF0C\u83B7\u53D6\u5B8C\u6574\u5185\u5BB9`),new Error(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u5206\u9875\u52A0\u8F7D`);const n=Math.floor((u-1)/m)*m+1,a=L(u,m);console.log(`\u8BF7\u6C42PDF chunk\u6570\u636E: ${n} (\u5305\u542B\u9875\u9762 ${n}-${n+m-1})`);const E={"Content-Type":"application/json"};h&&(E.Authorization=h),g&&(E["X-CSRF-TOKEN-IN"]=g);const x={convertedFilePath:t,pageNo:n,pageSize:m},F=await du.post(P,x,{headers:E,responseType:"arraybuffer"}),O=F.headers["x-csrf-token-out"]||F.headers["X-CSRF-TOKEN-OUT"];O&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",O),s("request_finish",O));const uu=Array.from({length:m},(Ee,Nu)=>n+Nu);return _.current[a]={data:F.data,pages:uu,timestamp:Date.now(),totalPages:D},console.log(`\u7F13\u5B58PDF chunk\u6570\u636E: ${a}, \u5305\u542B\u9875\u9762: ${uu.join(", ")}, \u8BF7\u6C42\u7684\u9875\u9762: ${u}`),console.log("\u5F53\u524D\u6240\u6709\u7F13\u5B58:",Object.keys(_.current)),F.data}catch(r){throw console.error("\u83B7\u53D6PDF stream\u6570\u636E\u5931\u8D25:",r),new Error(`PDF\u8BF7\u6C42\u5931\u8D25: ${((e=r.response)==null?void 0:e.status)||"\u7F51\u7EDC\u9519\u8BEF"}`)}},[P,t,m,h,L,D,w,o,s]),Du=d(async(u,e=!1)=>{var n;if(!u)return;if(!(o==="pdf"||o==="pdf_slides"))return console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u662FPDF\uFF0C\u8DF3\u8FC7PDF\u52A0\u8F7D\u903B\u8F91`),null;try{e?(f(!0),C("\u6B63\u5728\u52A0\u8F7DPDF\u6587\u6863...")):(f(!0),C(`\u6B63\u5728\u52A0\u8F7D\u7B2C ${u} \u9875...`)),I(null),console.log(`\u5F00\u59CB\u52A0\u8F7DPDF\u9875\u9762: ${u}, \u521D\u59CB\u52A0\u8F7D: ${e}`);const a=await Pu(u);if(a)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684PDF\u6587\u6863: ${u}`),wu(a),f(!1),C(""),console.log(`\u9875\u9762 ${u} \u52A0\u8F7D\u5B8C\u6210\uFF08\u4F7F\u7528\u7F13\u5B58\uFF09`),a;const E=await Ru(u),x=await mu(E,{fileName:l||"Stream\u6587\u6863",fileType:"pdf",token:h});if(x.error)throw new Error(x.error);if(x.type!=="pdf"||!((n=x.content)!=null&&n.document))throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684PDF\u6587\u6863");const F=x.content.document;console.log("\u8BBE\u7F6EPDF\u6587\u6863:",F),console.log("PDF\u6587\u6863\u7C7B\u578B:",typeof F),console.log("PDF\u6587\u6863\u65B9\u6CD5:",F?Object.getOwnPropertyNames(Object.getPrototypeOf(F)):"\u65E0\u6587\u6863"),console.log("PDF\u6587\u6863\u9875\u6570:",F?F.numPages:"\u65E0\u9875\u6570"),console.log("\u5F53\u524D\u8BF7\u6C42\u7684\u9875\u9762:",u),console.log("PDF\u6587\u6863\u5305\u542B\u7684\u9875\u9762\u8303\u56F4:",F?`1-${F.numPages}`:"\u65E0\u9875\u6570"),wu(F);const O=L(u,m);if(_.current[O]&&(_.current[O].pdfDocument=F,console.log(`\u7F13\u5B58PDF\u6587\u6863\u5230chunk: ${O}`)),D)console.log(`\u4F7F\u7528\u7528\u6237\u4F20\u5165\u7684\u603B\u9875\u6570: ${D}`),Y(D);else if(F&&F.numPages){const uu=F.numPages;console.log(`\u7528\u6237\u672A\u4F20\u5165\u603B\u9875\u6570\uFF0C\u4ECEPDF\u6587\u6863\u83B7\u53D6\u5B9E\u9645\u603B\u9875\u6570: ${uu}`),Y(uu)}return f(!1),C(""),console.log(`\u9875\u9762 ${u} \u52A0\u8F7D\u5B8C\u6210`),F}catch(a){throw console.error("PDF\u52A0\u8F7D\u5931\u8D25:",a),I(a.message||"PDF\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),a}},[Ru,l,h,w,Pu,L,m,o]),yu=d(u=>{if(!(o==="pdf"||o==="pdf_slides"))return!1;const r=Q.current[u];if(r&&Date.now()-r.timestamp<b)return!!r.pdfDocument;const n=L(u,m),a=_.current[n];return a&&Date.now()-a.timestamp<b?a.pages.includes(u)&&!!a.pdfDocument:!1},[m,L,o]),_u=d(()=>{console.log("\u68C0\u67E5markdown\u5185\u5BB9\u662F\u5426\u5728\u7F13\u5B58\u4E2D");const u=V.current;return u&&Date.now()-u.timestamp<b?(console.log("\u4F7F\u7528markdown\u5185\u5BB9\u7F13\u5B58"),u.data):(console.log("markdown\u5185\u5BB9\u4E0D\u5728\u7F13\u5B58\u4E2D\uFF0C\u9700\u8981\u91CD\u65B0\u8BF7\u6C42"),null)},[]),vu=d(async()=>{var u;try{console.log("\u8BF7\u6C42\u5B8C\u6574markdown\u6570\u636E");const e={"Content-Type":"application/json"};h&&(e.Authorization=h),g&&(e["X-CSRF-TOKEN-IN"]=g);const r={convertedFilePath:t};console.log("\u53D1\u9001markdown\u8BF7\u6C42:",r);const n=await du.post(P,r,{headers:e,responseType:"text"}),a=n.headers["x-csrf-token-out"]||n.headers["X-CSRF-TOKEN-OUT"];return a&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",a),s("request_finish",a)),console.log("markdown\u54CD\u5E94\u72B6\u6001:",n.status),console.log("markdown\u54CD\u5E94\u6570\u636E\u957F\u5EA6:",((u=n.data)==null?void 0:u.length)||0),n.data}catch(e){throw console.error("\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25:",e),new Error(`\u83B7\u53D6markdown\u6570\u636E\u5931\u8D25: ${e.message}`)}},[t,h,P,s]),qu=d(async()=>{try{f(!0),C("\u6B63\u5728\u52A0\u8F7Dmarkdown\u6587\u6863..."),I(null),console.log("\u5F00\u59CB\u52A0\u8F7D\u5B8C\u6574markdown\u6587\u6863");const u=_u();if(u)return console.log("\u4F7F\u7528\u7F13\u5B58\u7684markdown\u5185\u5BB9"),ku(u),f(!1),C(""),u;const e=await vu();return V.current={data:e,timestamp:Date.now()},ku(e),f(!1),C(""),console.log("\u5B8C\u6574markdown\u6587\u6863\u52A0\u8F7D\u5B8C\u6210"),e}catch(u){throw console.error("markdown\u52A0\u8F7D\u5931\u8D25:",u),I(u.message||"markdown\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),u}},[vu,_u]),Iu=d(async()=>{try{const u={"Content-Type":"application/json"};h&&(u.Authorization=h),g&&(u["X-CSRF-TOKEN-IN"]=g);const e={convertedFilePath:t},r=await du.post(P,e,{headers:u,responseType:"arraybuffer"}),n=r.headers["x-csrf-token-out"]||r.headers["X-CSRF-TOKEN-OUT"];return n&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",n),s("request_finish",n)),r.data}catch(u){throw console.error("\u83B7\u53D6\u56FE\u7247\u6570\u636E\u5931\u8D25:",u),new Error(`\u83B7\u53D6\u56FE\u7247\u6570\u636E\u5931\u8D25: ${u.message}`)}},[t,h,P,s]),Zu=d(async()=>{try{f(!0),C("\u6B63\u5728\u52A0\u8F7D\u56FE\u7247..."),I(null);const u=await Iu(),e=await mu(u,{fileName:l||"\u56FE\u7247",fileType:"image",token:h});if(e.error)throw new Error(e.error);if(e.type!=="image"||!e.content)throw new Error("\u89E3\u6790\u7ED3\u679C\u4E0D\u662F\u6709\u6548\u7684\u56FE\u7247");return xu(e.content),f(!1),C(""),e.content}catch(u){throw console.error("\u56FE\u7247\u52A0\u8F7D\u5931\u8D25:",u),I(u.message||"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),u}},[h,l,Iu]),Ou=d(async()=>{var u;try{console.log(`\u8BF7\u6C42\u901A\u7528\u6587\u4EF6\u6570\u636E\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);const e={"Content-Type":"application/json"};h&&(e.Authorization=h),g&&(e["X-CSRF-TOKEN-IN"]=g);const r={convertedFilePath:t};console.log("\u53D1\u9001\u901A\u7528\u6587\u4EF6\u8BF7\u6C42:",r);const n=await du.post(P,r,{headers:e,responseType:"arraybuffer"}),a=n.headers["x-csrf-token-out"]||n.headers["X-CSRF-TOKEN-OUT"];return a&&(console.log("\u83B7\u53D6\u5230\u54CD\u5E94\u5934\u4E2D\u7684CSRF Token:",a),s("request_finish",a)),console.log("\u901A\u7528\u6587\u4EF6\u54CD\u5E94\u72B6\u6001:",n.status),console.log("\u901A\u7528\u6587\u4EF6\u54CD\u5E94\u6570\u636E\u957F\u5EA6:",((u=n.data)==null?void 0:u.byteLength)||0),n.data}catch(e){throw console.error("\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25:",e),new Error(`\u83B7\u53D6\u901A\u7528\u6587\u4EF6\u6570\u636E\u5931\u8D25: ${e.message}`)}},[t,h,P,s]),Gu=d(async()=>{try{if(console.log("=== loadGenericDocument \u88AB\u8C03\u7528 ==="),console.log("\u8C03\u7528\u6808:",new Error().stack),console.log("\u5F53\u524D\u65F6\u95F4:",new Date().toISOString()),J.current){console.log(`\u901A\u7528\u6587\u6863\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u5FFD\u7565\u91CD\u590D\u8BF7\u6C42\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);return}if(T.current){console.log(`\u901A\u7528\u6587\u6863\u5DF2\u7ECF\u52A0\u8F7D\u8FC7\uFF0C\u5FFD\u7565\u91CD\u590D\u8BF7\u6C42\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);return}const u=`${o}_${t}`,e=hu[u];if(console.log(`\u68C0\u67E5\u901A\u7528\u6587\u6863\u7F13\u5B58\uFF0Ckey: ${u}, \u7F13\u5B58\u5B58\u5728: ${!!e}, \u7F13\u5B58\u65F6\u95F4: ${e?Date.now()-e.timestamp:"N/A"}ms`),e&&Date.now()-e.timestamp<b)return console.log(`\u4F7F\u7528\u7F13\u5B58\u7684\u901A\u7528\u6587\u6863\u5185\u5BB9\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`),o==="text"&&e.content?au(e.content):o==="html"&&e.content&&bu(e.content),K(1),Y(D||1),f(!1),C(""),e.content;J.current=!0,f(!0),C(`\u6B63\u5728\u52A0\u8F7D${o}\u6587\u6863...`),I(null),console.log(`\u5F00\u59CB\u52A0\u8F7D\u901A\u7528\u6587\u6863\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`);const r=await Ou();if(o==="text"){const x={type:"text",content:Su(r)};au(x);const F=`text_${t}`;return cu(O=>({...O,[F]:{content:x,timestamp:Date.now()}})),f(!1),C(""),J.current=!1,T.current=!0,console.log(`\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5B8C\u6210\uFF08text \u76F4\u89E3\uFF09\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`),x}const n=await mu(r,{fileName:l||`${o}\u6587\u6863`,fileType:o,token:h});if(n.error)throw new Error(n.error);let a=null;if(n.type==="text"&&n.content)au(n.content),a=n.content;else if(n.type==="html"&&n.content)bu(n.content),a=n.content;else if(n.type==="image"&&n.content)xu(n.content),a=n.content;else{const E=Su(r);au({type:"text",content:E}),a={type:"text",content:E}}if(a){const E=`${o}_${t}`,x={...hu,[E]:{content:a,timestamp:Date.now()}};cu(x),console.log(`\u901A\u7528\u6587\u6863\u5185\u5BB9\u5DF2\u7F13\u5B58\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}, \u7F13\u5B58\u952E: ${E}`),console.log("\u5F53\u524D\u7F13\u5B58\u72B6\u6001:",x)}return f(!1),C(""),J.current=!1,T.current=!0,console.log(`\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5B8C\u6210\uFF0C\u6587\u4EF6\u7C7B\u578B: ${o}`),n}catch(u){throw console.error("\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25:",u),I(u.message||"\u901A\u7528\u6587\u6863\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C(""),J.current=!1,T.current=!0,u}},[Ou,l,h,o,t,hu,D]),su=d(async u=>{if(u===q.current)return;if(nu){console.log("\u9875\u9762\u6B63\u5728\u52A0\u8F7D\u4E2D\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42");return}if(!(o==="pdf"||o==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}console.log("PDF\u9875\u9762\u53D8\u5316:",u,"\u5F53\u524D\u9875:",q.current),console.log(`\u9875\u9762 ${u} \u662F\u5426\u5728\u7F13\u5B58\u4E2D:`,yu(u)),q.current=u,K(u);try{await Du(u,!1),s("pageChange",{pageNumber:u,totalPages:D||w})}catch(r){console.error("PDF\u9875\u9762\u52A0\u8F7D\u5931\u8D25:",r);const n=q.current;K(n)}},[Du,w,s,yu,nu,o]);eu(()=>{q.current=R,console.log("\u5F53\u524D\u9875\u72B6\u6001\u66F4\u65B0:",R)},[R]);const lu=d(u=>{Bu(u),s("zoomChange",{scale:u})},[s]),ju=d(()=>{s("viewer:close")},[s]),Hu=d(()=>{const u=Math.min(3,y+.1);lu(u)},[y,lu]),Uu=d(()=>{const u=Math.max(.3,y-.1);lu(u)},[y,lu]),Wu=d(()=>{const u=(z-90+360)%360;Fu(u),s("rotateChange",{rotation:u})},[z,s]),Yu=d(()=>{const u=(z+90)%360;Fu(u),s("rotateChange",{rotation:u})},[z,s]),Ju=d(()=>{if(!(o==="pdf"||o==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const e=q.current-1;e>=1&&su(e)},[su,o]),Qu=d(()=>{if(!(o==="pdf"||o==="pdf_slides")){console.log(`\u6587\u4EF6\u7C7B\u578B ${o} \u4E0D\u652F\u6301\u7FFB\u9875\uFF0C\u5FFD\u7565\u7FFB\u9875\u8BF7\u6C42`);return}const e=q.current+1,r=D||w;r&&e<=r&&su(e)},[w,su,o]),Mu=d(()=>{const u=Date.now();Object.keys(Q.current).forEach(e=>{const r=Q.current[parseInt(e)];u-r.timestamp>b&&(delete Q.current[parseInt(e)],console.log(`\u6E05\u7406\u8FC7\u671F\u9875\u9762\u7F13\u5B58: ${e}`))}),Object.keys(_.current).forEach(e=>{const r=_.current[e];u-r.timestamp>b&&(delete _.current[e],console.log(`\u6E05\u7406\u8FC7\u671Fchunk\u7F13\u5B58: ${e}`))}),V.current&&u-V.current.timestamp>b&&(V.current=null,console.log("\u6E05\u7406\u8FC7\u671Fmarkdown\u5185\u5BB9\u7F13\u5B58")),cu(e=>{const r={...e};return Object.keys(r).forEach(n=>{u-r[n].timestamp>b&&(delete r[n],console.log(`\u6E05\u7406\u8FC7\u671F\u901A\u7528\u6587\u4EF6\u7F13\u5B58: ${n}`))}),r})},[]),v=d(()=>{if(l)return l;try{const u=new URL(t);return decodeURIComponent(u.pathname.split("/").pop()||"")||"Stream\u6587\u6863"}catch{const u=t.split("/");return decodeURIComponent(u[u.length-1])||"Stream\u6587\u6863"}},[t,l]);eu(()=>{const u=setInterval(Mu,b);return()=>clearInterval(u)},[Mu]),eu(()=>()=>{Q.current={},_.current={},V.current=null,cu({}),console.log("\u7EC4\u4EF6\u5378\u8F7D\uFF0C\u6E05\u7406\u6240\u6709\u7F13\u5B58")},[]),eu(()=>{console.log("=== useEffect \u88AB\u89E6\u53D1 ==="),console.log("\u89E6\u53D1\u65F6\u95F4:",new Date().toISOString()),console.log("\u89E6\u53D1\u539F\u56E0:",{initialPage:A,fileType:o}),(async()=>{try{const e=o==="pdf"||o==="pdf_slides",r=e&&A||1;console.log("\u5F00\u59CB\u521D\u59CB\u52A0\u8F7D\uFF0C\u6587\u4EF6\u7C7B\u578B:",o,"\u6709\u6548\u9875\u7801:",r,"\u662F\u5426PDF:",e),o==="markdown"||o==="markdown_table"?(await qu(),K(1),Y(D||1),s("pageChange",{pageNumber:1,totalPages:D||1})):o==="image"?(await Zu(),K(1),Y(D||1),Fu(0),s("pageChange",{pageNumber:1,totalPages:D||1})):e?(await Du(r,!0),K(r),setTimeout(()=>{s("pageChange",{pageNumber:r,totalPages:D||w})},0)):(console.log("=== \u521D\u59CB\u52A0\u8F7D\uFF1A\u4F7F\u7528\u901A\u7528\u52A0\u8F7D\u51FD\u6570\u5904\u7406\u6587\u4EF6\u7C7B\u578B ===",o),await Gu(),K(1),Y(D||1),s("pageChange",{pageNumber:1,totalPages:D||1}))}catch(e){console.error("\u521D\u59CB\u52A0\u8F7D\u5931\u8D25:",e),I((e==null?void 0:e.message)||"\u6587\u4EF6\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),f(!1),C("")}})()},[A,o,t]);const Vu=Tu(()=>Math.floor((R-1)/m)*m+1,[R,m]);return ru?c(fu,{$theme:Z,className:W,children:B!=null&&B.ErrorComponent?c(B.ErrorComponent,{error:ru,theme:Z}):p(fe,{$theme:Z,children:[c("div",{children:"\u52A0\u8F7D\u5931\u8D25"}),c("div",{style:{fontSize:"12px",marginTop:"8px"},children:ru})]})}):nu?p(fu,{$theme:Z,className:W,children:[c(Lu,{fileName:v(),currentPage:R,totalPage:w,scale:y,isAnnotating:!1,tools:G,styles:$,onPrevPage:()=>{},onNextPage:()=>{},onZoomIn:()=>{},onZoomOut:()=>{},onAnnotationToggle:()=>{},onDownload:()=>{},onClose:ju,className:tu}),B!=null&&B.LoadingComponent?c(B.LoadingComponent,{status:Cu,theme:Z}):c(me,{status:Cu,theme:Z})]}):p(fu,{$theme:Z,className:W,children:[c(Lu,{fileName:v(),currentPage:R,totalPage:w,scale:y,isAnnotating:!1,tools:{...G,navigation:o==="pdf"||o==="pdf_slides"?G.navigation:!1,rotate:o==="image"},styles:$,onPrevPage:Ju,onNextPage:Qu,onZoomIn:Hu,onZoomOut:Uu,onRotateLeft:o==="image"?Wu:void 0,onRotateRight:o==="image"?Yu:void 0,onAnnotationToggle:()=>{},onDownload:()=>{},onClose:ju,className:tu}),o==="markdown"||o==="markdown_table"?p("div",{ref:Xu,style:{flex:1,overflow:"auto",position:"relative"},className:["gientech-stream-reader-content",i].filter(Boolean).join(" "),children:[c("style",{children:`
|
|
152
147
|
.gientech-stream-reader-content {
|
|
153
148
|
-webkit-overflow-scrolling: touch;
|
|
154
149
|
overscroll-behavior: contain;
|
|
@@ -173,4 +168,4 @@ import{jsxs as p,jsx as c,Fragment as Du}from"react/jsx-runtime";import zu,{useS
|
|
|
173
168
|
overflow: hidden;
|
|
174
169
|
text-overflow: ellipsis;
|
|
175
170
|
}
|
|
176
|
-
`}),c(iu,{data:{content:
|
|
171
|
+
`}),c(iu,{data:{content:X,...v()&&{fileName:v()},...o&&{fileType:o},...w&&{totalPages:w}},annotationData:U,totalPage:w,currentPage:R,scale:y,eventsEmit:(u,e)=>{console.log("Fviewer\u4E8B\u4EF6:",u,e),s(u==="md_annotation_add"?"md_annotation_add":u==="table_annotation_add"?"table_annotation_add":u,e)},styles:$,tools:G,customComponents:B,contentClass:i}),(console.log("=== \u4F20\u9012\u7ED9Fviewer\u7684markdown\u5185\u5BB9 ==="),console.log("markdownContent:",X),console.log("markdownContent\u957F\u5EA6:",X.length),console.log("markdownContent\u524D100\u5B57\u7B26:",X.substring(0,100)),console.log("markdownContent\u540E100\u5B57\u7B26:",X.substring(X.length-100)),null)]}):o==="image"?c(iu,{data:{content:Eu,...v()&&{fileName:v()},...o&&{fileType:o}},annotationData:U,totalPage:1,currentPage:1,scale:y,rotation:z,eventsEmit:s,styles:$,tools:{...G,navigation:!1,rotate:!0},customComponents:B,contentClass:i}):o==="pdf"||o==="pdf_slides"?c(iu,{data:{content:{document:Ku},...v()&&{fileName:v()},...o&&{fileType:o},...w&&{totalPages:w},pdfStartPage:Vu},annotationData:U,totalPage:w,currentPage:R,scale:y,initialZoom:ou,eventsEmit:(u,e)=>{console.log("Fviewer\u4E8B\u4EF6:",u,e),u==="scaleChange"&&console.log("\u6536\u5230\u7F29\u653E\u53D8\u5316\u4E8B\u4EF6:",e),s(u,e)},styles:$,tools:G,customComponents:B,contentClass:i,setScale:Bu}):c(iu,{data:{content:pu||$u||{type:"text",content:"\u6587\u4EF6\u5185\u5BB9\u52A0\u8F7D\u4E2D..."},...v()&&{fileName:v()},...o&&{fileType:o}},annotationData:U,totalPage:1,currentPage:1,scale:y,eventsEmit:s,styles:$,tools:{...G,navigation:!1},customComponents:B,contentClass:i})]})};export{oe as C,ye as G};
|