openxiangda 1.0.148 → 1.0.149

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.
Files changed (26) hide show
  1. package/openxiangda-skills/references/pages/page-sdk.md +19 -0
  2. package/package.json +1 -1
  3. package/packages/sdk/dist/{ProcessPreview-BoblxCUt.d.mts → ProcessPreview-BOCARAvP.d.mts} +9 -1
  4. package/packages/sdk/dist/{ProcessPreview-BoblxCUt.d.ts → ProcessPreview-BOCARAvP.d.ts} +9 -1
  5. package/packages/sdk/dist/components/index.cjs +33 -21
  6. package/packages/sdk/dist/components/index.cjs.map +1 -1
  7. package/packages/sdk/dist/components/index.d.mts +4 -4
  8. package/packages/sdk/dist/components/index.d.ts +4 -4
  9. package/packages/sdk/dist/components/index.mjs +33 -21
  10. package/packages/sdk/dist/components/index.mjs.map +1 -1
  11. package/packages/sdk/dist/{dataManagementApi-BCzfV88G.d.mts → dataManagementApi-CLMqf79O.d.mts} +1 -1
  12. package/packages/sdk/dist/{dataManagementApi-_FFNPv2e.d.ts → dataManagementApi-DhpRKmlp.d.ts} +1 -1
  13. package/packages/sdk/dist/runtime/index.cjs +375 -30
  14. package/packages/sdk/dist/runtime/index.cjs.map +1 -1
  15. package/packages/sdk/dist/runtime/index.d.mts +3 -3
  16. package/packages/sdk/dist/runtime/index.d.ts +3 -3
  17. package/packages/sdk/dist/runtime/index.mjs +377 -32
  18. package/packages/sdk/dist/runtime/index.mjs.map +1 -1
  19. package/packages/sdk/dist/runtime/react.cjs +12 -0
  20. package/packages/sdk/dist/runtime/react.cjs.map +1 -1
  21. package/packages/sdk/dist/runtime/react.d.mts +24 -2
  22. package/packages/sdk/dist/runtime/react.d.ts +24 -2
  23. package/packages/sdk/dist/runtime/react.mjs +12 -0
  24. package/packages/sdk/dist/runtime/react.mjs.map +1 -1
  25. package/templates/openxiangda-react-spa/AGENTS.md +7 -0
  26. package/templates/openxiangda-react-spa/src/pages/defaults/FilePreviewRoutePage.tsx +18 -33
@@ -1,4 +1,4 @@
1
- import { F as FieldDefinition, a as FormRuntimeApi, R as RuntimeResponse, b as FormSchema } from './ProcessPreview-BoblxCUt.mjs';
1
+ import { F as FieldDefinition, a as FormRuntimeApi, R as RuntimeResponse, b as FormSchema } from './ProcessPreview-BOCARAvP.mjs';
2
2
 
3
3
  type DataManagementConfigScope = 'global' | 'personal';
4
4
  type DataManagementDensity = 'compact' | 'middle' | 'loose';
@@ -1,4 +1,4 @@
1
- import { F as FieldDefinition, a as FormRuntimeApi, R as RuntimeResponse, b as FormSchema } from './ProcessPreview-BoblxCUt.js';
1
+ import { F as FieldDefinition, a as FormRuntimeApi, R as RuntimeResponse, b as FormSchema } from './ProcessPreview-BOCARAvP.js';
2
2
 
3
3
  type DataManagementConfigScope = 'global' | 'personal';
4
4
  type DataManagementDensity = 'compact' | 'middle' | 'loose';
@@ -756,6 +756,17 @@ var createPageSdk = (context) => {
756
756
  throw toSdkError(error, payload);
757
757
  }
758
758
  };
759
+ const createFileAccessTicket = (bucketName, objectName, fileName, action = "preview", options = {}) => request({
760
+ path: "/file/access-ticket",
761
+ method: "post",
762
+ body: {
763
+ bucketName,
764
+ objectName,
765
+ fileName,
766
+ action,
767
+ appType: resolveAppType(context, options.appType)
768
+ }
769
+ });
759
770
  const logout = () => request({
760
771
  path: "/api/auth/logout",
761
772
  method: "post"
@@ -2041,6 +2052,7 @@ var createPageSdk = (context) => {
2041
2052
  context,
2042
2053
  request,
2043
2054
  download,
2055
+ createFileAccessTicket,
2044
2056
  transport: {
2045
2057
  request,
2046
2058
  download
@@ -7648,11 +7660,11 @@ function createFormRuntimeApi(config) {
7648
7660
  });
7649
7661
  return normalizeFileTicketResult(baseUrl, response.data || response.result);
7650
7662
  },
7651
- createFileAccessTicket: async (bucketName, objectName, fileName, purpose = "preview") => {
7663
+ createFileAccessTicket: async (bucketName, objectName, fileName, purpose = "preview", options = {}) => {
7652
7664
  const response = await request({
7653
7665
  url: "/file/access-ticket",
7654
7666
  method: "post",
7655
- data: { bucketName, objectName, fileName, purpose }
7667
+ data: { bucketName, objectName, fileName, purpose, appType: options.appType }
7656
7668
  });
7657
7669
  return normalizeFileTicketResult(baseUrl, response.data || response.result);
7658
7670
  },
@@ -10757,6 +10769,11 @@ function canPreview(item) {
10757
10769
  const ext = getFileExtension(item.name);
10758
10770
  return isImageFile(item.name, item.contentType) || ["mp4", "webm", "ogg", "mov", "m4v"].includes(ext) || PREVIEW_PAGE_EXTENSIONS.includes(ext);
10759
10771
  }
10772
+ function appendTicketIfMissing(url, ticket) {
10773
+ if (!url || !ticket || /[?&]ticket=/.test(url)) return url;
10774
+ const separator = url.includes("?") ? "&" : "?";
10775
+ return `${url}${separator}ticket=${encodeURIComponent(ticket)}`;
10776
+ }
10760
10777
  function AttachmentFieldPC({
10761
10778
  fieldId,
10762
10779
  behavior,
@@ -10872,16 +10889,15 @@ function AttachmentFieldPC({
10872
10889
  item.bucketName || bucketName,
10873
10890
  item.objectName,
10874
10891
  item.name,
10875
- "preview"
10892
+ "preview",
10893
+ { appType: item.appType || config.appType }
10876
10894
  );
10877
10895
  const ticketValue = typeof ticket === "string" ? { previewUrl: ticket } : ticket;
10878
- if (ticketValue?.previewPageUrl && ticketValue?.ticket) {
10879
- const separator = ticketValue.previewPageUrl.includes("?") ? "&" : "?";
10880
- return `${ticketValue.previewPageUrl}${separator}ticket=${encodeURIComponent(ticketValue.ticket)}`;
10896
+ if (ticketValue?.previewPageUrl) {
10897
+ return appendTicketIfMissing(ticketValue.previewPageUrl, ticketValue.ticket);
10881
10898
  }
10882
10899
  if (ticketValue?.ticket && PREVIEW_PAGE_EXTENSIONS.includes(getFileExtension(item.name))) {
10883
- const separator = previewPagePath.includes("?") ? "&" : "?";
10884
- return `${previewPagePath}${separator}ticket=${encodeURIComponent(ticketValue.ticket)}`;
10900
+ return appendTicketIfMissing(previewPagePath, ticketValue.ticket);
10885
10901
  }
10886
10902
  return ticketValue?.previewUrl || ticketValue?.url || "";
10887
10903
  }
@@ -11123,6 +11139,11 @@ function canPreview2(item) {
11123
11139
  const ext = getFileExtension(item.name);
11124
11140
  return isImageFile(item.name, item.contentType) || ["mp4", "webm", "ogg", "mov", "m4v"].includes(ext) || PREVIEW_PAGE_EXTENSIONS2.includes(ext);
11125
11141
  }
11142
+ function appendTicketIfMissing2(url, ticket) {
11143
+ if (!url || !ticket || /[?&]ticket=/.test(url)) return url;
11144
+ const separator = url.includes("?") ? "&" : "?";
11145
+ return `${url}${separator}ticket=${encodeURIComponent(ticket)}`;
11146
+ }
11126
11147
  function AttachmentFieldMobile({
11127
11148
  fieldId,
11128
11149
  behavior,
@@ -11271,16 +11292,15 @@ function AttachmentFieldMobile({
11271
11292
  item.bucketName || bucketName,
11272
11293
  item.objectName,
11273
11294
  item.name,
11274
- "preview"
11295
+ "preview",
11296
+ { appType: item.appType || config.appType }
11275
11297
  );
11276
11298
  const ticketValue = typeof ticket === "string" ? { previewUrl: ticket } : ticket;
11277
- if (ticketValue?.previewPageUrl && ticketValue?.ticket) {
11278
- const separator = ticketValue.previewPageUrl.includes("?") ? "&" : "?";
11279
- return `${ticketValue.previewPageUrl}${separator}ticket=${encodeURIComponent(ticketValue.ticket)}`;
11299
+ if (ticketValue?.previewPageUrl) {
11300
+ return appendTicketIfMissing2(ticketValue.previewPageUrl, ticketValue.ticket);
11280
11301
  }
11281
11302
  if (ticketValue?.ticket && PREVIEW_PAGE_EXTENSIONS2.includes(getFileExtension(item.name))) {
11282
- const separator = previewPagePath.includes("?") ? "&" : "?";
11283
- return `${previewPagePath}${separator}ticket=${encodeURIComponent(ticketValue.ticket)}`;
11303
+ return appendTicketIfMissing2(previewPagePath, ticketValue.ticket);
11284
11304
  }
11285
11305
  return ticketValue?.previewUrl || ticketValue?.url || "";
11286
11306
  }
@@ -11411,6 +11431,11 @@ function canPreview3(item) {
11411
11431
  const ext = getFileExtension(item.name);
11412
11432
  return isImageFile(item.name, item.contentType) || ["mp4", "webm", "ogg", "mov", "m4v"].includes(ext) || PREVIEW_PAGE_EXTENSIONS3.includes(ext);
11413
11433
  }
11434
+ function appendTicketIfMissing3(url, ticket) {
11435
+ if (!url || !ticket || /[?&]ticket=/.test(url)) return url;
11436
+ const separator = url.includes("?") ? "&" : "?";
11437
+ return `${url}${separator}ticket=${encodeURIComponent(ticket)}`;
11438
+ }
11414
11439
  function AttachmentFieldReadonly({
11415
11440
  fieldId,
11416
11441
  readonlyClassName,
@@ -11421,7 +11446,7 @@ function AttachmentFieldReadonly({
11421
11446
  showFileTypeBadge = false,
11422
11447
  previewPagePath = "/file-preview"
11423
11448
  }) {
11424
- const { formData, api } = useFormContext();
11449
+ const { formData, api, config } = useFormContext();
11425
11450
  const { isMobile } = useDeviceDetect();
11426
11451
  const value = formData[fieldId] ?? [];
11427
11452
  if (value.length === 0) {
@@ -11446,15 +11471,14 @@ function AttachmentFieldReadonly({
11446
11471
  item.bucketName || bucketName,
11447
11472
  item.objectName,
11448
11473
  item.name,
11449
- "preview"
11474
+ "preview",
11475
+ { appType: item.appType || config.appType }
11450
11476
  );
11451
11477
  const ticketValue = typeof ticket === "string" ? { previewUrl: ticket } : ticket;
11452
- if (ticketValue?.previewPageUrl && ticketValue?.ticket) {
11453
- const separator = ticketValue.previewPageUrl.includes("?") ? "&" : "?";
11454
- url = `${ticketValue.previewPageUrl}${separator}ticket=${encodeURIComponent(ticketValue.ticket)}`;
11478
+ if (ticketValue?.previewPageUrl) {
11479
+ url = appendTicketIfMissing3(ticketValue.previewPageUrl, ticketValue.ticket);
11455
11480
  } else if (ticketValue?.ticket && PREVIEW_PAGE_EXTENSIONS3.includes(getFileExtension(item.name))) {
11456
- const separator = previewPagePath.includes("?") ? "&" : "?";
11457
- url = `${previewPagePath}${separator}ticket=${encodeURIComponent(ticketValue.ticket)}`;
11481
+ url = appendTicketIfMissing3(previewPagePath, ticketValue.ticket);
11458
11482
  } else {
11459
11483
  url = getTicketUrl(ticketValue, url);
11460
11484
  }
@@ -24623,23 +24647,337 @@ var getDetailBasePath = (appType, formUuid, formType) => {
24623
24647
  const detailType = isProcessKind("data-manage-list", formType) ? "processDetail" : "formDetail";
24624
24648
  return `/view/${appType}/${detailType}/${formUuid}`;
24625
24649
  };
24650
+ var unwrapRuntimePayload4 = (payload) => payload?.data ?? payload?.result ?? payload;
24651
+ var formatFileSize2 = (size) => {
24652
+ const value = Number(size || 0);
24653
+ if (!value) return "0 B";
24654
+ const units = ["B", "KB", "MB", "GB"];
24655
+ const index = Math.min(
24656
+ units.length - 1,
24657
+ Math.floor(Math.log(value) / Math.log(1024))
24658
+ );
24659
+ return `${(value / Math.pow(1024, index)).toFixed(index === 0 ? 0 : 1)} ${units[index]}`;
24660
+ };
24661
+ var toColumnName = (index) => {
24662
+ let value = index + 1;
24663
+ let name = "";
24664
+ while (value > 0) {
24665
+ const mod = (value - 1) % 26;
24666
+ name = String.fromCharCode(65 + mod) + name;
24667
+ value = Math.floor((value - mod) / 26);
24668
+ }
24669
+ return name;
24670
+ };
24671
+ var buildRowsTable = (rows = []) => {
24672
+ const maxColumns = rows.reduce(
24673
+ (count, row) => Math.max(count, Array.isArray(row) ? row.length : 0),
24674
+ 0
24675
+ );
24676
+ const columns = Array.from({ length: maxColumns }).map((_, index) => ({
24677
+ title: toColumnName(index),
24678
+ dataIndex: `col_${index}`,
24679
+ key: `col_${index}`,
24680
+ width: 160,
24681
+ render: (value) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Typography.Text, { ellipsis: { tooltip: String(value ?? "") }, children: String(value ?? "") })
24682
+ }));
24683
+ const dataSource = rows.map((row, rowIndex) => {
24684
+ const record = { key: rowIndex };
24685
+ (Array.isArray(row) ? row : []).forEach((value, colIndex) => {
24686
+ record[`col_${colIndex}`] = value;
24687
+ });
24688
+ return record;
24689
+ });
24690
+ return { columns, dataSource };
24691
+ };
24692
+ var loadScriptOnce = (src) => new Promise((resolve, reject) => {
24693
+ if (!src || typeof document === "undefined") {
24694
+ reject(new Error("ONLYOFFICE \u811A\u672C\u5730\u5740\u4E0D\u53EF\u7528"));
24695
+ return;
24696
+ }
24697
+ const existed = document.querySelector(`script[src="${src}"]`);
24698
+ if (existed) {
24699
+ resolve();
24700
+ return;
24701
+ }
24702
+ const script = document.createElement("script");
24703
+ script.src = src;
24704
+ script.async = true;
24705
+ script.onload = () => resolve();
24706
+ script.onerror = () => reject(new Error("ONLYOFFICE \u811A\u672C\u52A0\u8F7D\u5931\u8D25"));
24707
+ document.body.appendChild(script);
24708
+ });
24709
+ var OnlyOfficePreview = ({
24710
+ configUrl,
24711
+ request,
24712
+ servicePrefix,
24713
+ ticket
24714
+ }) => {
24715
+ const editorId = (0, import_react83.useMemo)(
24716
+ () => `openxiangda-onlyoffice-${ticket.replace(/[^a-zA-Z0-9_-]/g, "") || "editor"}`,
24717
+ [ticket]
24718
+ );
24719
+ const [loading, setLoading] = (0, import_react83.useState)(false);
24720
+ const [error, setError] = (0, import_react83.useState)("");
24721
+ (0, import_react83.useEffect)(() => {
24722
+ let disposed = false;
24723
+ const load = async () => {
24724
+ setLoading(true);
24725
+ setError("");
24726
+ try {
24727
+ const response = await request({
24728
+ url: configUrl || `/file/onlyoffice/config/${encodeURIComponent(ticket)}`,
24729
+ method: "get"
24730
+ });
24731
+ const payload = unwrapRuntimePayload4(response);
24732
+ const scriptUrl = `${String(payload.documentServerUrl || "").replace(
24733
+ /\/+$/,
24734
+ ""
24735
+ )}/web-apps/apps/api/documents/api.js`;
24736
+ await loadScriptOnce(joinServicePath2(servicePrefix, scriptUrl));
24737
+ if (!disposed && typeof window !== "undefined" && window.DocsAPI?.DocEditor) {
24738
+ new window.DocsAPI.DocEditor(editorId, payload.config);
24739
+ }
24740
+ } catch (currentError) {
24741
+ if (!disposed) {
24742
+ setError(currentError?.message || "ONLYOFFICE \u9884\u89C8\u52A0\u8F7D\u5931\u8D25");
24743
+ }
24744
+ } finally {
24745
+ if (!disposed) {
24746
+ setLoading(false);
24747
+ }
24748
+ }
24749
+ };
24750
+ void load();
24751
+ return () => {
24752
+ disposed = true;
24753
+ };
24754
+ }, [configUrl, editorId, request, servicePrefix, ticket]);
24755
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { style: { minHeight: "calc(100vh - 180px)" }, children: [
24756
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Spin, { tip: "\u6B63\u5728\u52A0\u8F7D ONLYOFFICE..." }) : null,
24757
+ error ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Alert, { type: "warning", showIcon: true, message: error }) : null,
24758
+ /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { id: editorId, style: { height: "calc(100vh - 180px)", minHeight: 520 } })
24759
+ ] });
24760
+ };
24626
24761
  var BuiltinFilePreview = ({
24762
+ request,
24627
24763
  route,
24628
24764
  servicePrefix
24629
24765
  }) => {
24630
24766
  const ticket = pickRouteValue(route, "ticket");
24767
+ const [metadata, setMetadata] = (0, import_react83.useState)(null);
24768
+ const [payload, setPayload] = (0, import_react83.useState)(null);
24769
+ const [loading, setLoading] = (0, import_react83.useState)(false);
24770
+ const [payloadLoading, setPayloadLoading] = (0, import_react83.useState)(false);
24771
+ const [error, setError] = (0, import_react83.useState)("");
24772
+ const [reloadKey, setReloadKey] = (0, import_react83.useState)(0);
24773
+ (0, import_react83.useEffect)(() => {
24774
+ let disposed = false;
24775
+ setMetadata(null);
24776
+ setPayload(null);
24777
+ setError("");
24778
+ if (!ticket) return () => {
24779
+ disposed = true;
24780
+ };
24781
+ const loadMetadata = async () => {
24782
+ setLoading(true);
24783
+ try {
24784
+ const response = await request({
24785
+ url: `/file/access-ticket/${encodeURIComponent(ticket)}`,
24786
+ method: "get"
24787
+ });
24788
+ if (!disposed) {
24789
+ setMetadata(unwrapRuntimePayload4(response));
24790
+ }
24791
+ } catch (currentError) {
24792
+ if (!disposed) {
24793
+ setError(currentError?.message || "\u6587\u4EF6\u9884\u89C8\u4FE1\u606F\u52A0\u8F7D\u5931\u8D25");
24794
+ }
24795
+ } finally {
24796
+ if (!disposed) {
24797
+ setLoading(false);
24798
+ }
24799
+ }
24800
+ };
24801
+ void loadMetadata();
24802
+ return () => {
24803
+ disposed = true;
24804
+ };
24805
+ }, [request, reloadKey, ticket]);
24806
+ const resolvePreviewUrl = (url) => joinServicePath2(
24807
+ servicePrefix,
24808
+ url || `/file/preview-by-ticket/${encodeURIComponent(ticket)}`
24809
+ );
24810
+ const downloadUrl = metadata?.downloadUrl ? joinServicePath2(servicePrefix, metadata.downloadUrl) : "";
24811
+ (0, import_react83.useEffect)(() => {
24812
+ let disposed = false;
24813
+ setPayload(null);
24814
+ if (!metadata?.renderMode || ["pdfjs", "inline", "download", "onlyoffice"].includes(metadata.renderMode)) {
24815
+ setPayloadLoading(false);
24816
+ return () => {
24817
+ disposed = true;
24818
+ };
24819
+ }
24820
+ const url = metadata.renderMode === "excel-basic" ? metadata.excelPreviewUrl : metadata.renderMode === "office-text" ? metadata.officeTextPreviewUrl : metadata.textPreviewUrl;
24821
+ if (!url) return () => {
24822
+ disposed = true;
24823
+ };
24824
+ const loadPayload = async () => {
24825
+ setPayloadLoading(true);
24826
+ try {
24827
+ const response = await request({ url, method: "get" });
24828
+ if (!disposed) {
24829
+ setPayload(unwrapRuntimePayload4(response));
24830
+ }
24831
+ } catch (currentError) {
24832
+ if (!disposed) {
24833
+ setError(currentError?.message || "\u6587\u4EF6\u9884\u89C8\u5185\u5BB9\u52A0\u8F7D\u5931\u8D25");
24834
+ }
24835
+ } finally {
24836
+ if (!disposed) {
24837
+ setPayloadLoading(false);
24838
+ }
24839
+ }
24840
+ };
24841
+ void loadPayload();
24842
+ return () => {
24843
+ disposed = true;
24844
+ };
24845
+ }, [metadata, request]);
24631
24846
  if (!ticket) {
24632
24847
  return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Card, { style: { margin: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Empty, { description: "\u7F3A\u5C11\u6587\u4EF6\u8BBF\u95EE\u7968\u636E" }) });
24633
24848
  }
24634
- const src = joinServicePath2(servicePrefix, `/file/preview-by-ticket/${encodeURIComponent(ticket)}`);
24635
- return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { style: { minHeight: "calc(100vh - 74px)", background: "#fff" }, children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24636
- "iframe",
24637
- {
24638
- title: "\u6587\u4EF6\u9884\u89C8",
24639
- src,
24640
- style: { width: "100%", minHeight: "calc(100vh - 74px)", border: 0 }
24849
+ const renderContent = () => {
24850
+ if (loading && !metadata) return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Spin, { tip: "\u6B63\u5728\u52A0\u8F7D\u6587\u4EF6\u4FE1\u606F..." });
24851
+ if (error) {
24852
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24853
+ import_antd40.Alert,
24854
+ {
24855
+ type: "error",
24856
+ showIcon: true,
24857
+ message: error,
24858
+ action: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Button, { onClick: () => setReloadKey((value) => value + 1), children: "\u91CD\u8BD5" })
24859
+ }
24860
+ );
24641
24861
  }
24642
- ) });
24862
+ if (!metadata) return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Empty, { description: "\u672A\u83B7\u53D6\u5230\u6587\u4EF6\u4FE1\u606F" });
24863
+ if (metadata.renderMode === "pdfjs") {
24864
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24865
+ "iframe",
24866
+ {
24867
+ title: "PDF \u9884\u89C8",
24868
+ src: resolvePreviewUrl(metadata.previewUrl),
24869
+ style: { width: "100%", minHeight: "calc(100vh - 180px)", border: 0 }
24870
+ }
24871
+ );
24872
+ }
24873
+ if (metadata.renderMode === "inline" && metadata.previewType === "image") {
24874
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { style: { textAlign: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24875
+ "img",
24876
+ {
24877
+ alt: metadata.fileName || "\u9644\u4EF6\u9884\u89C8",
24878
+ src: resolvePreviewUrl(metadata.previewUrl),
24879
+ style: { maxWidth: "100%", maxHeight: "calc(100vh - 190px)" }
24880
+ }
24881
+ ) });
24882
+ }
24883
+ if (metadata.renderMode === "inline" && metadata.previewType === "video") {
24884
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24885
+ "video",
24886
+ {
24887
+ controls: true,
24888
+ playsInline: true,
24889
+ preload: "metadata",
24890
+ src: resolvePreviewUrl(metadata.previewUrl),
24891
+ style: { width: "100%", maxHeight: "calc(100vh - 190px)" }
24892
+ }
24893
+ );
24894
+ }
24895
+ if (metadata.renderMode === "excel-basic") {
24896
+ if (payloadLoading) return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Spin, { tip: "\u6B63\u5728\u89E3\u6790 Excel..." });
24897
+ const sheets = Array.isArray(payload?.sheets) ? payload.sheets : [];
24898
+ if (!sheets.length) return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Empty, { description: "\u6682\u65E0\u53EF\u9884\u89C8\u7684\u5DE5\u4F5C\u8868" });
24899
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24900
+ import_antd40.Tabs,
24901
+ {
24902
+ items: sheets.map((sheet) => {
24903
+ const table = buildRowsTable(sheet.rows || []);
24904
+ return {
24905
+ key: String(sheet.id || sheet.name),
24906
+ label: sheet.name || "Sheet",
24907
+ children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24908
+ import_antd40.Table,
24909
+ {
24910
+ bordered: true,
24911
+ size: "small",
24912
+ pagination: false,
24913
+ scroll: { x: true, y: "calc(100vh - 250px)" },
24914
+ columns: table.columns,
24915
+ dataSource: table.dataSource
24916
+ }
24917
+ )
24918
+ };
24919
+ })
24920
+ }
24921
+ );
24922
+ }
24923
+ if (metadata.renderMode === "text" || metadata.renderMode === "office-text") {
24924
+ if (payloadLoading) return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Spin, { tip: "\u6B63\u5728\u8BFB\u53D6\u6587\u672C..." });
24925
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("pre", { style: { whiteSpace: "pre-wrap", wordBreak: "break-word", margin: 0 }, children: [
24926
+ payload?.text || "\u6682\u65E0\u6587\u672C\u5185\u5BB9",
24927
+ payload?.truncated ? "\n\n... \u6587\u4EF6\u8F83\u5927\uFF0C\u4EC5\u5C55\u793A\u524D\u90E8\u5185\u5BB9\u3002" : ""
24928
+ ] });
24929
+ }
24930
+ if (metadata.renderMode === "onlyoffice") {
24931
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24932
+ OnlyOfficePreview,
24933
+ {
24934
+ configUrl: metadata.onlyofficeConfigUrl,
24935
+ request,
24936
+ servicePrefix,
24937
+ ticket
24938
+ }
24939
+ );
24940
+ }
24941
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24942
+ import_antd40.Empty,
24943
+ {
24944
+ description: "\u5F53\u524D\u6587\u4EF6\u7C7B\u578B\u6682\u4E0D\u652F\u6301\u9884\u89C8",
24945
+ image: import_antd40.Empty.PRESENTED_IMAGE_SIMPLE,
24946
+ children: downloadUrl ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Button, { type: "primary", onClick: () => window.location.assign(downloadUrl), children: "\u4E0B\u8F7D\u6587\u4EF6" }) : null
24947
+ }
24948
+ );
24949
+ };
24950
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { style: { minHeight: "calc(100vh - 74px)", background: "#fff", padding: 16 }, children: [
24951
+ /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(
24952
+ import_antd40.Card,
24953
+ {
24954
+ size: "small",
24955
+ style: { marginBottom: 16 },
24956
+ extra: /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
24957
+ /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Button, { size: "small", onClick: () => setReloadKey((value) => value + 1), children: "\u5237\u65B0" }),
24958
+ downloadUrl ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24959
+ import_antd40.Button,
24960
+ {
24961
+ size: "small",
24962
+ type: "primary",
24963
+ style: { marginLeft: 8 },
24964
+ onClick: () => window.location.assign(downloadUrl),
24965
+ children: "\u4E0B\u8F7D"
24966
+ }
24967
+ ) : null
24968
+ ] }),
24969
+ children: [
24970
+ /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Typography.Text, { strong: true, children: metadata?.fileName || "\u9644\u4EF6\u9884\u89C8" }),
24971
+ metadata ? /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_antd40.Typography.Text, { type: "secondary", style: { marginLeft: 12 }, children: [
24972
+ (metadata.extension || "FILE").toUpperCase(),
24973
+ " \xB7 ",
24974
+ formatFileSize2(metadata.size)
24975
+ ] }) : null
24976
+ ]
24977
+ }
24978
+ ),
24979
+ renderContent()
24980
+ ] });
24643
24981
  };
24644
24982
  var BuiltinRouteError = ({
24645
24983
  error,
@@ -24766,7 +25104,14 @@ function BuiltinRouteRenderer({
24766
25104
  }
24767
25105
  let defaultNode;
24768
25106
  if (route.kind === "file-preview") {
24769
- defaultNode = /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(BuiltinFilePreview, { route, servicePrefix: normalizedServicePrefix });
25107
+ defaultNode = /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
25108
+ BuiltinFilePreview,
25109
+ {
25110
+ request,
25111
+ route,
25112
+ servicePrefix: normalizedServicePrefix
25113
+ }
25114
+ );
24770
25115
  } else if (route.kind === "data-manage-list") {
24771
25116
  if (!appType || !formUuid) {
24772
25117
  defaultNode = /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Card, { style: { margin: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_antd40.Empty, { description: "\u6570\u636E\u7BA1\u7406\u9875\u7F3A\u5C11 formUuid\uFF0C\u8BF7\u5728 URL \u6216 resolver params \u4E2D\u63D0\u4F9B formUuid" }) });