openxiangda 1.0.152 → 1.0.154
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 +13 -1
- package/openxiangda-skills/SKILL.md +1 -1
- package/openxiangda-skills/references/component-guide.md +10 -1
- package/openxiangda-skills/references/pages/page-sdk.md +35 -2
- package/openxiangda-skills/references/troubleshooting.md +18 -5
- package/package.json +1 -1
- package/packages/sdk/dist/{ProcessPreview-B_HqjU7v.d.mts → ProcessPreview-DMkzccq4.d.mts} +55 -1
- package/packages/sdk/dist/{ProcessPreview-B_HqjU7v.d.ts → ProcessPreview-DMkzccq4.d.ts} +55 -1
- package/packages/sdk/dist/components/index.cjs +73 -12
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.d.mts +7 -59
- package/packages/sdk/dist/components/index.d.ts +7 -59
- package/packages/sdk/dist/components/index.mjs +73 -12
- package/packages/sdk/dist/components/index.mjs.map +1 -1
- package/packages/sdk/dist/{dataManagementApi-CEDsA3tT.d.ts → dataManagementApi-C9O-Bb0j.d.ts} +1 -1
- package/packages/sdk/dist/{dataManagementApi-quq3Zhgo.d.mts → dataManagementApi-gpZkgRDM.d.mts} +1 -1
- package/packages/sdk/dist/runtime/index.cjs +10528 -10211
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.d.mts +3 -3
- package/packages/sdk/dist/runtime/index.d.ts +3 -3
- package/packages/sdk/dist/runtime/index.mjs +9892 -9575
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.cjs +2936 -451
- package/packages/sdk/dist/runtime/react.cjs.map +1 -1
- package/packages/sdk/dist/runtime/react.d.mts +57 -3
- package/packages/sdk/dist/runtime/react.d.ts +57 -3
- package/packages/sdk/dist/runtime/react.mjs +2945 -437
- package/packages/sdk/dist/runtime/react.mjs.map +1 -1
- package/templates/openxiangda-react-spa/.cursor/rules/openxiangda.mdc +1 -0
- package/templates/openxiangda-react-spa/.qoder/rules/openxiangda.md +1 -0
- package/templates/openxiangda-react-spa/AGENTS.md +4 -2
|
@@ -2619,21 +2619,2588 @@ var usePageRoute = () => {
|
|
|
2619
2619
|
return usePageContext().route;
|
|
2620
2620
|
};
|
|
2621
2621
|
|
|
2622
|
+
// packages/sdk/src/runtime/react/filePreview.tsx
|
|
2623
|
+
import React6, { useMemo as useMemo6, useState as useState6 } from "react";
|
|
2624
|
+
import { Empty as Empty3 } from "antd";
|
|
2625
|
+
|
|
2626
|
+
// packages/sdk/src/components/core/imageCompression.ts
|
|
2627
|
+
var DEFAULT_THUMB = {
|
|
2628
|
+
maxWidth: 320,
|
|
2629
|
+
maxHeight: 320,
|
|
2630
|
+
quality: 0.72,
|
|
2631
|
+
format: "source"
|
|
2632
|
+
};
|
|
2633
|
+
var DEFAULT_PREVIEW = {
|
|
2634
|
+
maxWidth: 1280,
|
|
2635
|
+
maxHeight: 1280,
|
|
2636
|
+
quality: 0.82,
|
|
2637
|
+
format: "source"
|
|
2638
|
+
};
|
|
2639
|
+
var COMPRESSIBLE_EXTENSIONS = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "webp", "bmp"]);
|
|
2640
|
+
function shouldCreateImageVariants(file, config) {
|
|
2641
|
+
if (!config || config.enabled === false) return false;
|
|
2642
|
+
if (!isCompressibleImageFile(file)) return false;
|
|
2643
|
+
if (config.skipBelowBytes && file.size <= config.skipBelowBytes) return false;
|
|
2644
|
+
return true;
|
|
2645
|
+
}
|
|
2646
|
+
async function createCompressedImageVariants(file, config) {
|
|
2647
|
+
if (!shouldCreateImageVariants(file, config)) return [];
|
|
2648
|
+
const variantConfigs = [];
|
|
2649
|
+
if (config?.thumb !== false) {
|
|
2650
|
+
variantConfigs.push(["thumb", { ...DEFAULT_THUMB, ...config?.thumb || {} }]);
|
|
2651
|
+
}
|
|
2652
|
+
if (config?.preview !== false) {
|
|
2653
|
+
variantConfigs.push(["preview", { ...DEFAULT_PREVIEW, ...config?.preview || {} }]);
|
|
2654
|
+
}
|
|
2655
|
+
if (variantConfigs.length === 0) return [];
|
|
2656
|
+
const source = await loadImageSource(file);
|
|
2657
|
+
if (!source) return [];
|
|
2658
|
+
try {
|
|
2659
|
+
const sourceWidth = Math.max(1, source.naturalWidth || source.width || 0);
|
|
2660
|
+
const sourceHeight = Math.max(1, source.naturalHeight || source.height || 0);
|
|
2661
|
+
if (!sourceWidth || !sourceHeight) return [];
|
|
2662
|
+
const results = [];
|
|
2663
|
+
for (const [kind, variantConfig] of variantConfigs) {
|
|
2664
|
+
const normalized = normalizeVariantConfig(kind, variantConfig);
|
|
2665
|
+
const target = getTargetSize(sourceWidth, sourceHeight, normalized);
|
|
2666
|
+
const mimeType = resolveOutputMimeType(file, normalized.format);
|
|
2667
|
+
const blob = await drawCompressedBlob(
|
|
2668
|
+
source,
|
|
2669
|
+
target.width,
|
|
2670
|
+
target.height,
|
|
2671
|
+
mimeType,
|
|
2672
|
+
normalized.quality
|
|
2673
|
+
);
|
|
2674
|
+
if (!blob || blob.size >= file.size) continue;
|
|
2675
|
+
const outputFile = new File([blob], buildVariantFileName(file.name, kind, mimeType), {
|
|
2676
|
+
type: blob.type || mimeType,
|
|
2677
|
+
lastModified: Date.now()
|
|
2678
|
+
});
|
|
2679
|
+
results.push({
|
|
2680
|
+
kind,
|
|
2681
|
+
file: outputFile,
|
|
2682
|
+
width: target.width,
|
|
2683
|
+
height: target.height,
|
|
2684
|
+
contentType: outputFile.type || mimeType,
|
|
2685
|
+
quality: normalized.quality
|
|
2686
|
+
});
|
|
2687
|
+
}
|
|
2688
|
+
return results;
|
|
2689
|
+
} finally {
|
|
2690
|
+
source.close?.();
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
function isCompressibleImageFile(file) {
|
|
2694
|
+
const contentType = String(file.type || "").toLowerCase();
|
|
2695
|
+
if (contentType === "image/svg+xml" || contentType === "image/gif") return false;
|
|
2696
|
+
if (contentType.startsWith("image/")) {
|
|
2697
|
+
return ["image/jpeg", "image/png", "image/webp", "image/bmp"].includes(contentType);
|
|
2698
|
+
}
|
|
2699
|
+
const extension = getExtension(file.name);
|
|
2700
|
+
return COMPRESSIBLE_EXTENSIONS.has(extension);
|
|
2701
|
+
}
|
|
2702
|
+
async function loadImageSource(file) {
|
|
2703
|
+
if (typeof createImageBitmap === "function") {
|
|
2704
|
+
try {
|
|
2705
|
+
return await createImageBitmap(file);
|
|
2706
|
+
} catch {
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
if (typeof Image === "undefined" || typeof URL === "undefined") return null;
|
|
2710
|
+
const objectUrl = URL.createObjectURL(file);
|
|
2711
|
+
try {
|
|
2712
|
+
const image = new Image();
|
|
2713
|
+
image.decoding = "async";
|
|
2714
|
+
image.src = objectUrl;
|
|
2715
|
+
if (typeof image.decode === "function") {
|
|
2716
|
+
await image.decode();
|
|
2717
|
+
} else {
|
|
2718
|
+
await new Promise((resolve, reject) => {
|
|
2719
|
+
image.onload = () => resolve();
|
|
2720
|
+
image.onerror = () => reject(new Error("\u56FE\u7247\u89E3\u7801\u5931\u8D25"));
|
|
2721
|
+
});
|
|
2722
|
+
}
|
|
2723
|
+
return image;
|
|
2724
|
+
} catch {
|
|
2725
|
+
return null;
|
|
2726
|
+
} finally {
|
|
2727
|
+
URL.revokeObjectURL(objectUrl);
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
function normalizeVariantConfig(kind, config) {
|
|
2731
|
+
const fallback = kind === "thumb" ? DEFAULT_THUMB : DEFAULT_PREVIEW;
|
|
2732
|
+
const maxWidth = Number(config.maxWidth || fallback.maxWidth);
|
|
2733
|
+
const maxHeight = Number(config.maxHeight || fallback.maxHeight);
|
|
2734
|
+
const quality = Number(config.quality ?? fallback.quality);
|
|
2735
|
+
return {
|
|
2736
|
+
maxWidth: Number.isFinite(maxWidth) && maxWidth > 0 ? maxWidth : fallback.maxWidth,
|
|
2737
|
+
maxHeight: Number.isFinite(maxHeight) && maxHeight > 0 ? maxHeight : fallback.maxHeight,
|
|
2738
|
+
quality: Number.isFinite(quality) && quality > 0 && quality <= 1 ? quality : fallback.quality,
|
|
2739
|
+
format: config.format || fallback.format
|
|
2740
|
+
};
|
|
2741
|
+
}
|
|
2742
|
+
function getTargetSize(sourceWidth, sourceHeight, config) {
|
|
2743
|
+
const scale = Math.min(1, config.maxWidth / sourceWidth, config.maxHeight / sourceHeight);
|
|
2744
|
+
return {
|
|
2745
|
+
width: Math.max(1, Math.round(sourceWidth * scale)),
|
|
2746
|
+
height: Math.max(1, Math.round(sourceHeight * scale))
|
|
2747
|
+
};
|
|
2748
|
+
}
|
|
2749
|
+
function drawCompressedBlob(source, width, height, mimeType, quality) {
|
|
2750
|
+
if (typeof document === "undefined") return Promise.resolve(null);
|
|
2751
|
+
const canvas = document.createElement("canvas");
|
|
2752
|
+
canvas.width = width;
|
|
2753
|
+
canvas.height = height;
|
|
2754
|
+
const context = canvas.getContext("2d");
|
|
2755
|
+
if (!context || typeof canvas.toBlob !== "function") return Promise.resolve(null);
|
|
2756
|
+
context.drawImage(source, 0, 0, width, height);
|
|
2757
|
+
return new Promise((resolve) => {
|
|
2758
|
+
canvas.toBlob(resolve, mimeType, mimeType === "image/png" ? void 0 : quality);
|
|
2759
|
+
});
|
|
2760
|
+
}
|
|
2761
|
+
function resolveOutputMimeType(file, format) {
|
|
2762
|
+
if (format && format !== "source") {
|
|
2763
|
+
return format === "jpeg" ? "image/jpeg" : `image/${format}`;
|
|
2764
|
+
}
|
|
2765
|
+
const sourceType = String(file.type || "").toLowerCase();
|
|
2766
|
+
if (["image/jpeg", "image/png", "image/webp"].includes(sourceType)) return sourceType;
|
|
2767
|
+
const extension = getExtension(file.name);
|
|
2768
|
+
if (extension === "png") return "image/png";
|
|
2769
|
+
if (extension === "webp") return "image/webp";
|
|
2770
|
+
return "image/jpeg";
|
|
2771
|
+
}
|
|
2772
|
+
function buildVariantFileName(fileName, kind, mimeType) {
|
|
2773
|
+
const extension = extensionFromMimeType(mimeType);
|
|
2774
|
+
const baseName = String(fileName || "image").replace(/\.[^.]*$/, "").replace(/[^\w.-]+/g, "_").replace(/^_+|_+$/g, "");
|
|
2775
|
+
return `${baseName || "image"}.${kind}.${extension}`;
|
|
2776
|
+
}
|
|
2777
|
+
function extensionFromMimeType(mimeType) {
|
|
2778
|
+
if (mimeType === "image/png") return "png";
|
|
2779
|
+
if (mimeType === "image/webp") return "webp";
|
|
2780
|
+
return "jpg";
|
|
2781
|
+
}
|
|
2782
|
+
function getExtension(fileName) {
|
|
2783
|
+
return String(fileName || "").split(".").pop()?.toLowerCase() || "";
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
// packages/sdk/src/components/core/runtimeApi.ts
|
|
2787
|
+
var DEFAULT_CHUNK_SIZE = 5 * 1024 * 1024;
|
|
2788
|
+
var CHUNK_UPLOAD_THRESHOLD = 10 * 1024 * 1024;
|
|
2789
|
+
var DEFAULT_PUBLIC_FILE_BUCKET = "public-assets";
|
|
2790
|
+
var trimTrailingSlash = (value) => String(value || "").replace(/\/$/, "");
|
|
2791
|
+
var getDefaultBaseUrl = () => {
|
|
2792
|
+
const globalEnv = globalThis.process?.env;
|
|
2793
|
+
const envBaseUrl = globalEnv?.FORM_API_BASE_URL || globalEnv?.BASE_API_URL;
|
|
2794
|
+
if (envBaseUrl) return trimTrailingSlash(envBaseUrl);
|
|
2795
|
+
const browserGlobal = typeof window !== "undefined" ? window : void 0;
|
|
2796
|
+
const windowBaseUrl = browserGlobal?.FORM_API_BASE_URL || browserGlobal?.BASE_API_URL || browserGlobal?.__FORM_API_BASE_URL__ || browserGlobal?.__LOWCODE_API_BASE_URL__;
|
|
2797
|
+
if (windowBaseUrl) return trimTrailingSlash(windowBaseUrl);
|
|
2798
|
+
return typeof window !== "undefined" ? "/service" : "";
|
|
2799
|
+
};
|
|
2800
|
+
var appendQuery = (url, params) => {
|
|
2801
|
+
if (!params) return url;
|
|
2802
|
+
const search = new URLSearchParams();
|
|
2803
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
2804
|
+
if (value === void 0 || value === null || value === "") return;
|
|
2805
|
+
if (Array.isArray(value)) {
|
|
2806
|
+
value.forEach((item) => search.append(key, String(item)));
|
|
2807
|
+
return;
|
|
2808
|
+
}
|
|
2809
|
+
search.append(key, String(value));
|
|
2810
|
+
});
|
|
2811
|
+
const query = search.toString();
|
|
2812
|
+
if (!query) return url;
|
|
2813
|
+
return `${url}${url.includes("?") ? "&" : "?"}${query}`;
|
|
2814
|
+
};
|
|
2815
|
+
var joinUrl = (baseUrl, url) => {
|
|
2816
|
+
if (/^https?:\/\//i.test(url)) return url;
|
|
2817
|
+
const normalizedBaseUrl = trimTrailingSlash(baseUrl);
|
|
2818
|
+
if (normalizedBaseUrl && (url === normalizedBaseUrl || url.startsWith(`${normalizedBaseUrl}/`))) {
|
|
2819
|
+
return url;
|
|
2820
|
+
}
|
|
2821
|
+
return `${normalizedBaseUrl}${url.startsWith("/") ? url : `/${url}`}`;
|
|
2822
|
+
};
|
|
2823
|
+
var isSuccessCode2 = (value) => {
|
|
2824
|
+
if (value === void 0 || value === null || value === "") return true;
|
|
2825
|
+
const code = Number(value);
|
|
2826
|
+
return Number.isFinite(code) ? code === 0 || code >= 200 && code < 300 : false;
|
|
2827
|
+
};
|
|
2828
|
+
var normalizeRuntimeFileUrl = (baseUrl, value) => {
|
|
2829
|
+
if (typeof value !== "string" || !value) return value;
|
|
2830
|
+
if (/^(https?:)?\/\//i.test(value) || /^(blob|data):/i.test(value)) return value;
|
|
2831
|
+
if (!value.startsWith("/file/")) return value;
|
|
2832
|
+
return joinUrl(baseUrl, value);
|
|
2833
|
+
};
|
|
2834
|
+
var normalizeFilePayloadUrls = (baseUrl, payload) => {
|
|
2835
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return payload;
|
|
2836
|
+
return {
|
|
2837
|
+
...payload,
|
|
2838
|
+
url: normalizeRuntimeFileUrl(baseUrl, payload.url),
|
|
2839
|
+
downloadUrl: normalizeRuntimeFileUrl(baseUrl, payload.downloadUrl),
|
|
2840
|
+
publicUrl: normalizeRuntimeFileUrl(baseUrl, payload.publicUrl),
|
|
2841
|
+
relayUrl: normalizeRuntimeFileUrl(baseUrl, payload.relayUrl),
|
|
2842
|
+
previewUrl: normalizeRuntimeFileUrl(baseUrl, payload.previewUrl),
|
|
2843
|
+
metadataUrl: normalizeRuntimeFileUrl(baseUrl, payload.metadataUrl),
|
|
2844
|
+
previewPageUrl: payload.previewPageUrl
|
|
2845
|
+
};
|
|
2846
|
+
};
|
|
2847
|
+
var normalizeImageVariants = (baseUrl, variants) => {
|
|
2848
|
+
if (!variants || typeof variants !== "object" || Array.isArray(variants)) return void 0;
|
|
2849
|
+
const normalized = {};
|
|
2850
|
+
["thumb", "preview"].forEach((kind) => {
|
|
2851
|
+
const item = variants[kind];
|
|
2852
|
+
if (!item || typeof item !== "object") return;
|
|
2853
|
+
normalized[kind] = {
|
|
2854
|
+
...item,
|
|
2855
|
+
url: normalizeRuntimeFileUrl(baseUrl, item.url)
|
|
2856
|
+
};
|
|
2857
|
+
});
|
|
2858
|
+
return normalized.thumb || normalized.preview ? normalized : void 0;
|
|
2859
|
+
};
|
|
2860
|
+
var normalizeFileTicketResult = (baseUrl, payload) => typeof payload === "string" ? normalizeRuntimeFileUrl(baseUrl, payload) : normalizeFilePayloadUrls(baseUrl, payload);
|
|
2861
|
+
var parseResponse = async (response) => {
|
|
2862
|
+
const contentType = response.headers.get("content-type") || "";
|
|
2863
|
+
const payload = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
2864
|
+
if (!response.ok) {
|
|
2865
|
+
const message3 = typeof payload === "object" && payload ? payload.message || payload.error || response.statusText : response.statusText;
|
|
2866
|
+
throw new Error(message3 || "\u8BF7\u6C42\u5931\u8D25");
|
|
2867
|
+
}
|
|
2868
|
+
if (typeof payload === "object" && payload) {
|
|
2869
|
+
const hasCode = Object.prototype.hasOwnProperty.call(payload, "code");
|
|
2870
|
+
if (payload.success === false || hasCode && !isSuccessCode2(payload.code)) {
|
|
2871
|
+
throw new Error(payload.message || payload.error || "\u8BF7\u6C42\u5931\u8D25");
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
if (typeof payload === "object" && payload) {
|
|
2875
|
+
return payload;
|
|
2876
|
+
}
|
|
2877
|
+
return {
|
|
2878
|
+
code: response.status,
|
|
2879
|
+
success: response.ok,
|
|
2880
|
+
data: payload,
|
|
2881
|
+
result: payload,
|
|
2882
|
+
message: response.statusText
|
|
2883
|
+
};
|
|
2884
|
+
};
|
|
2885
|
+
var applyAuthHeaders = (headers, getAuthHeaders) => {
|
|
2886
|
+
const authHeaders = getAuthHeaders?.();
|
|
2887
|
+
if (authHeaders) {
|
|
2888
|
+
new Headers(authHeaders).forEach((value, key) => {
|
|
2889
|
+
if (!headers.has(key)) headers.set(key, value);
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
|
|
2893
|
+
if (token && !headers.has("authorization")) {
|
|
2894
|
+
headers.set("authorization", token);
|
|
2895
|
+
}
|
|
2896
|
+
};
|
|
2897
|
+
var applyXhrAuthHeaders = (xhr, getAuthHeaders) => {
|
|
2898
|
+
let hasAuthorization = false;
|
|
2899
|
+
const authHeaders = getAuthHeaders?.();
|
|
2900
|
+
if (authHeaders) {
|
|
2901
|
+
new Headers(authHeaders).forEach((value, key) => {
|
|
2902
|
+
if (key.toLowerCase() === "authorization") hasAuthorization = true;
|
|
2903
|
+
xhr.setRequestHeader(key, value);
|
|
2904
|
+
});
|
|
2905
|
+
}
|
|
2906
|
+
const token = typeof window !== "undefined" ? window.localStorage?.getItem("token") : void 0;
|
|
2907
|
+
if (token && !hasAuthorization) xhr.setRequestHeader("authorization", token);
|
|
2908
|
+
};
|
|
2909
|
+
var createDefaultRequest = (baseUrl, fetchImpl = fetch, getAuthHeaders) => async (config) => {
|
|
2910
|
+
const method = config.method ?? "get";
|
|
2911
|
+
const url = appendQuery(joinUrl(baseUrl, config.url), config.params);
|
|
2912
|
+
const headers = new Headers(config.headers);
|
|
2913
|
+
let body;
|
|
2914
|
+
if (config.data !== void 0) {
|
|
2915
|
+
if (config.data instanceof FormData) {
|
|
2916
|
+
body = config.data;
|
|
2917
|
+
} else {
|
|
2918
|
+
headers.set("Content-Type", headers.get("Content-Type") || "application/json");
|
|
2919
|
+
body = JSON.stringify(config.data);
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
applyAuthHeaders(headers, getAuthHeaders);
|
|
2923
|
+
const response = await fetchImpl(url, {
|
|
2924
|
+
method,
|
|
2925
|
+
headers,
|
|
2926
|
+
body,
|
|
2927
|
+
credentials: "include"
|
|
2928
|
+
});
|
|
2929
|
+
if (config.responseType === "blob") {
|
|
2930
|
+
if (!response.ok) throw new Error(response.statusText || "\u8BF7\u6C42\u5931\u8D25");
|
|
2931
|
+
return response.blob();
|
|
2932
|
+
}
|
|
2933
|
+
return parseResponse(response);
|
|
2934
|
+
};
|
|
2935
|
+
var generateUid = () => `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`;
|
|
2936
|
+
var normalizeFormInstancePayload = (payload) => {
|
|
2937
|
+
const { formInstanceId, ...rest } = payload || {};
|
|
2938
|
+
return {
|
|
2939
|
+
...rest,
|
|
2940
|
+
formInstId: payload?.formInstId || formInstanceId
|
|
2941
|
+
};
|
|
2942
|
+
};
|
|
2943
|
+
var unwrapBusinessResponse = (response) => {
|
|
2944
|
+
const isFailureCode = (value) => {
|
|
2945
|
+
if (value === void 0 || value === null || value === "") return false;
|
|
2946
|
+
const code = Number(value);
|
|
2947
|
+
return Number.isFinite(code) && code !== 0 && code !== 200;
|
|
2948
|
+
};
|
|
2949
|
+
if (response?.success === false || isFailureCode(response?.code)) {
|
|
2950
|
+
throw new Error(response.message || response.error || "\u8BF7\u6C42\u5931\u8D25");
|
|
2951
|
+
}
|
|
2952
|
+
const result = response?.data ?? response?.result ?? response;
|
|
2953
|
+
if (result?.success === false || isFailureCode(result?.code)) {
|
|
2954
|
+
throw new Error(result.message || response?.message || "\u8BF7\u6C42\u5931\u8D25");
|
|
2955
|
+
}
|
|
2956
|
+
return result;
|
|
2957
|
+
};
|
|
2958
|
+
var normalizeUploadData = (data, file, bucketName, baseUrl = "") => {
|
|
2959
|
+
const item = Array.isArray(data) ? data[0] : data;
|
|
2960
|
+
const objectName = item?.objectName || item?.objectKey || item?.key;
|
|
2961
|
+
const resolvedBucketName = item?.bucketName || bucketName;
|
|
2962
|
+
const variants = normalizeImageVariants(baseUrl, item?.variants);
|
|
2963
|
+
return {
|
|
2964
|
+
id: item?.id || item?.uid || objectName || generateUid(),
|
|
2965
|
+
uid: item?.uid || item?.id || objectName || generateUid(),
|
|
2966
|
+
name: item?.originalName || item?.name || file.name,
|
|
2967
|
+
originalName: item?.originalName || file.name,
|
|
2968
|
+
url: normalizeRuntimeFileUrl(baseUrl, item?.url) || "",
|
|
2969
|
+
downloadUrl: normalizeRuntimeFileUrl(baseUrl, item?.downloadUrl),
|
|
2970
|
+
previewUrl: normalizeRuntimeFileUrl(baseUrl, item?.previewUrl),
|
|
2971
|
+
publicUrl: normalizeRuntimeFileUrl(baseUrl, item?.publicUrl),
|
|
2972
|
+
thumbUrl: normalizeRuntimeFileUrl(baseUrl, item?.thumbUrl) || variants?.thumb?.url,
|
|
2973
|
+
visibility: item?.visibility,
|
|
2974
|
+
provider: item?.provider,
|
|
2975
|
+
uploadProvider: item?.uploadProvider,
|
|
2976
|
+
storageScope: item?.storageScope,
|
|
2977
|
+
storageCode: item?.storageCode,
|
|
2978
|
+
appType: item?.appType,
|
|
2979
|
+
status: "done",
|
|
2980
|
+
size: item?.size ?? file.size,
|
|
2981
|
+
objectName,
|
|
2982
|
+
bucketName: resolvedBucketName,
|
|
2983
|
+
contentType: item?.contentType || file.type,
|
|
2984
|
+
mimeType: item?.contentType || file.type,
|
|
2985
|
+
extension: item?.extension,
|
|
2986
|
+
width: item?.width,
|
|
2987
|
+
height: item?.height,
|
|
2988
|
+
variants
|
|
2989
|
+
};
|
|
2990
|
+
};
|
|
2991
|
+
var uploadWithXhr = (baseUrl, file, bucketName, onProgress, options = {}, getAuthHeaders) => new Promise((resolve, reject) => {
|
|
2992
|
+
if (globalThis.process?.env?.VITEST) {
|
|
2993
|
+
onProgress?.(100);
|
|
2994
|
+
resolve({
|
|
2995
|
+
id: generateUid(),
|
|
2996
|
+
uid: generateUid(),
|
|
2997
|
+
name: file.name,
|
|
2998
|
+
url: typeof URL !== "undefined" && URL.createObjectURL ? URL.createObjectURL(file) : "",
|
|
2999
|
+
status: "done",
|
|
3000
|
+
size: file.size,
|
|
3001
|
+
bucketName,
|
|
3002
|
+
contentType: file.type,
|
|
3003
|
+
visibility: options.visibility
|
|
3004
|
+
});
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
3007
|
+
const xhr = new XMLHttpRequest();
|
|
3008
|
+
const formData = new FormData();
|
|
3009
|
+
formData.append("files", file);
|
|
3010
|
+
xhr.open(
|
|
3011
|
+
"POST",
|
|
3012
|
+
joinUrl(
|
|
3013
|
+
baseUrl,
|
|
3014
|
+
appendQuery("/file/upload", {
|
|
3015
|
+
bucketName,
|
|
3016
|
+
visibility: options.visibility
|
|
3017
|
+
})
|
|
3018
|
+
)
|
|
3019
|
+
);
|
|
3020
|
+
xhr.withCredentials = true;
|
|
3021
|
+
applyXhrAuthHeaders(xhr, getAuthHeaders);
|
|
3022
|
+
xhr.upload.onprogress = (event) => {
|
|
3023
|
+
if (event.lengthComputable) {
|
|
3024
|
+
onProgress?.(Math.round(event.loaded / event.total * 100));
|
|
3025
|
+
}
|
|
3026
|
+
};
|
|
3027
|
+
xhr.onload = () => {
|
|
3028
|
+
try {
|
|
3029
|
+
const payload = JSON.parse(xhr.responseText || "{}");
|
|
3030
|
+
if (xhr.status >= 200 && xhr.status < 300 && payload.success !== false) {
|
|
3031
|
+
resolve(normalizeUploadData(payload.data, file, bucketName, baseUrl));
|
|
3032
|
+
return;
|
|
3033
|
+
}
|
|
3034
|
+
reject(new Error(payload.message || payload.error || "\u4E0A\u4F20\u5931\u8D25"));
|
|
3035
|
+
} catch (error) {
|
|
3036
|
+
reject(error);
|
|
3037
|
+
}
|
|
3038
|
+
};
|
|
3039
|
+
xhr.onerror = () => reject(new Error("\u4E0A\u4F20\u5931\u8D25"));
|
|
3040
|
+
xhr.send(formData);
|
|
3041
|
+
});
|
|
3042
|
+
var uploadWithSignedUrl = (file, uploadInfo, bucketName, onProgress) => new Promise((resolve, reject) => {
|
|
3043
|
+
if (!uploadInfo?.uploadUrl) {
|
|
3044
|
+
reject(new Error("OSS \u4E0A\u4F20\u7B7E\u540D\u7F3A\u5C11 uploadUrl"));
|
|
3045
|
+
return;
|
|
3046
|
+
}
|
|
3047
|
+
const xhr = new XMLHttpRequest();
|
|
3048
|
+
xhr.open(String(uploadInfo.uploadMethod || "PUT").toUpperCase(), uploadInfo.uploadUrl);
|
|
3049
|
+
Object.entries(uploadInfo.headers || {}).forEach(([key, value]) => {
|
|
3050
|
+
if (value !== void 0 && value !== null) {
|
|
3051
|
+
xhr.setRequestHeader(key, String(value));
|
|
3052
|
+
}
|
|
3053
|
+
});
|
|
3054
|
+
xhr.upload.onprogress = (event) => {
|
|
3055
|
+
if (event.lengthComputable) {
|
|
3056
|
+
onProgress?.(Math.round(event.loaded / event.total * 100));
|
|
3057
|
+
}
|
|
3058
|
+
};
|
|
3059
|
+
xhr.onload = () => {
|
|
3060
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
3061
|
+
onProgress?.(100);
|
|
3062
|
+
resolve(
|
|
3063
|
+
normalizeUploadData(
|
|
3064
|
+
{
|
|
3065
|
+
...uploadInfo,
|
|
3066
|
+
provider: uploadInfo.provider || "oss",
|
|
3067
|
+
uploadProvider: uploadInfo.uploadProvider,
|
|
3068
|
+
storageScope: uploadInfo.storageScope,
|
|
3069
|
+
storageCode: uploadInfo.storageCode
|
|
3070
|
+
},
|
|
3071
|
+
file,
|
|
3072
|
+
uploadInfo.bucketName || bucketName
|
|
3073
|
+
)
|
|
3074
|
+
);
|
|
3075
|
+
return;
|
|
3076
|
+
}
|
|
3077
|
+
reject(new Error(xhr.statusText || "OSS \u4E0A\u4F20\u5931\u8D25"));
|
|
3078
|
+
};
|
|
3079
|
+
xhr.onerror = () => reject(new Error("OSS \u4E0A\u4F20\u5931\u8D25"));
|
|
3080
|
+
xhr.send(file);
|
|
3081
|
+
});
|
|
3082
|
+
async function uploadOssFile(request, file, bucketName, onProgress, options) {
|
|
3083
|
+
if (!options.appType) throw new Error("OSS \u4E0A\u4F20\u7F3A\u5C11 appType");
|
|
3084
|
+
if (!options.storageCode) throw new Error("OSS \u4E0A\u4F20\u7F3A\u5C11 storageCode");
|
|
3085
|
+
const response = await request({
|
|
3086
|
+
url: `/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
3087
|
+
options.appType
|
|
3088
|
+
)}/storage-configs/${encodeURIComponent(options.storageCode)}/uploads/initiate`,
|
|
3089
|
+
method: "post",
|
|
3090
|
+
data: {
|
|
3091
|
+
fileName: file.name,
|
|
3092
|
+
fileSize: file.size,
|
|
3093
|
+
contentType: file.type || void 0,
|
|
3094
|
+
bucketName
|
|
3095
|
+
}
|
|
3096
|
+
});
|
|
3097
|
+
return uploadWithSignedUrl(file, response.data || response.result, bucketName, onProgress);
|
|
3098
|
+
}
|
|
3099
|
+
async function uploadBuiltinOssFile(request, file, bucketName, onProgress, options) {
|
|
3100
|
+
if (!options.appType) throw new Error("\u5E73\u53F0\u5185\u7F6E OSS \u4E0A\u4F20\u7F3A\u5C11 appType");
|
|
3101
|
+
const response = await request({
|
|
3102
|
+
url: `/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
3103
|
+
options.appType
|
|
3104
|
+
)}/storage/builtin/uploads/initiate`,
|
|
3105
|
+
method: "post",
|
|
3106
|
+
data: {
|
|
3107
|
+
fileName: file.name,
|
|
3108
|
+
fileSize: file.size,
|
|
3109
|
+
contentType: file.type || void 0,
|
|
3110
|
+
bucketName,
|
|
3111
|
+
purpose: options.uploadPurpose
|
|
3112
|
+
}
|
|
3113
|
+
});
|
|
3114
|
+
return uploadWithSignedUrl(file, response.data || response.result, bucketName, onProgress);
|
|
3115
|
+
}
|
|
3116
|
+
async function uploadChunkedFile(request, file, bucketName, baseUrl, onProgress, options = {}) {
|
|
3117
|
+
const initiate = await request({
|
|
3118
|
+
url: "/file/multipart/initiate",
|
|
3119
|
+
method: "post",
|
|
3120
|
+
data: {
|
|
3121
|
+
fileName: file.name,
|
|
3122
|
+
fileSize: file.size,
|
|
3123
|
+
chunkSize: DEFAULT_CHUNK_SIZE,
|
|
3124
|
+
bucketName,
|
|
3125
|
+
visibility: options.visibility,
|
|
3126
|
+
contentType: file.type || void 0
|
|
3127
|
+
}
|
|
3128
|
+
});
|
|
3129
|
+
const uploadInfo = initiate.data || initiate.result;
|
|
3130
|
+
const totalParts = uploadInfo?.totalParts || Math.ceil(file.size / DEFAULT_CHUNK_SIZE);
|
|
3131
|
+
const parts = [];
|
|
3132
|
+
try {
|
|
3133
|
+
for (let index = 0; index < totalParts; index += 1) {
|
|
3134
|
+
const start = index * DEFAULT_CHUNK_SIZE;
|
|
3135
|
+
const end = Math.min(start + DEFAULT_CHUNK_SIZE, file.size);
|
|
3136
|
+
const formData = new FormData();
|
|
3137
|
+
formData.append("file", file.slice(start, end));
|
|
3138
|
+
formData.append("uploadId", uploadInfo.uploadId);
|
|
3139
|
+
formData.append("partNumber", String(index + 1));
|
|
3140
|
+
formData.append("bucketName", uploadInfo.bucketName);
|
|
3141
|
+
formData.append("objectName", uploadInfo.objectName);
|
|
3142
|
+
const part = await request({
|
|
3143
|
+
url: "/file/multipart/upload",
|
|
3144
|
+
method: "post",
|
|
3145
|
+
data: formData
|
|
3146
|
+
});
|
|
3147
|
+
parts.push(part.data || part.result);
|
|
3148
|
+
onProgress?.(Math.round((index + 1) / totalParts * 100));
|
|
3149
|
+
}
|
|
3150
|
+
const completed = await request({
|
|
3151
|
+
url: "/file/multipart/complete",
|
|
3152
|
+
method: "post",
|
|
3153
|
+
data: {
|
|
3154
|
+
uploadId: uploadInfo.uploadId,
|
|
3155
|
+
bucketName: uploadInfo.bucketName,
|
|
3156
|
+
objectName: uploadInfo.objectName,
|
|
3157
|
+
originalName: file.name,
|
|
3158
|
+
contentType: file.type || void 0,
|
|
3159
|
+
parts: parts.sort((a, b) => a.partNumber - b.partNumber)
|
|
3160
|
+
}
|
|
3161
|
+
});
|
|
3162
|
+
return normalizeUploadData(completed.data || completed.result, file, bucketName, baseUrl);
|
|
3163
|
+
} catch (error) {
|
|
3164
|
+
await request({
|
|
3165
|
+
url: "/file/multipart/abort",
|
|
3166
|
+
method: "post",
|
|
3167
|
+
data: {
|
|
3168
|
+
uploadId: uploadInfo?.uploadId,
|
|
3169
|
+
bucketName: uploadInfo?.bucketName,
|
|
3170
|
+
objectName: uploadInfo?.objectName
|
|
3171
|
+
}
|
|
3172
|
+
}).catch(() => void 0);
|
|
3173
|
+
throw error;
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
var stripImageCompressionOptions = (options) => {
|
|
3177
|
+
const { imageCompression, ...rest } = options;
|
|
3178
|
+
return rest;
|
|
3179
|
+
};
|
|
3180
|
+
var createSegmentProgress = (onProgress, start, end) => (percent) => {
|
|
3181
|
+
const next = start + (end - start) * Math.max(0, Math.min(100, percent)) / 100;
|
|
3182
|
+
onProgress?.(Math.round(next));
|
|
3183
|
+
};
|
|
3184
|
+
var getAttachmentUrl = (item) => item.publicUrl || item.previewUrl || item.downloadUrl || item.url || "";
|
|
3185
|
+
async function uploadSingleRuntimeFile(request, baseUrl, file, bucketName, onProgress, options, getAuthHeaders) {
|
|
3186
|
+
const singleOptions = stripImageCompressionOptions(options);
|
|
3187
|
+
if (singleOptions.uploadProvider === "builtin-oss") {
|
|
3188
|
+
return uploadBuiltinOssFile(request, file, bucketName, onProgress, singleOptions);
|
|
3189
|
+
}
|
|
3190
|
+
if (singleOptions.uploadProvider === "oss" || singleOptions.storageCode) {
|
|
3191
|
+
return uploadOssFile(request, file, bucketName, onProgress, singleOptions);
|
|
3192
|
+
}
|
|
3193
|
+
if (file.size > CHUNK_UPLOAD_THRESHOLD) {
|
|
3194
|
+
return uploadChunkedFile(request, file, bucketName, baseUrl, onProgress);
|
|
3195
|
+
}
|
|
3196
|
+
return uploadWithXhr(baseUrl, file, bucketName, onProgress, {}, getAuthHeaders);
|
|
3197
|
+
}
|
|
3198
|
+
function toImageVariantMetadata(uploaded, variant) {
|
|
3199
|
+
return {
|
|
3200
|
+
url: getAttachmentUrl(uploaded),
|
|
3201
|
+
objectName: uploaded.objectName,
|
|
3202
|
+
bucketName: uploaded.bucketName,
|
|
3203
|
+
width: variant.width,
|
|
3204
|
+
height: variant.height,
|
|
3205
|
+
size: uploaded.size ?? variant.file.size,
|
|
3206
|
+
contentType: uploaded.contentType || variant.contentType,
|
|
3207
|
+
quality: variant.quality
|
|
3208
|
+
};
|
|
3209
|
+
}
|
|
3210
|
+
async function uploadFileWithImageVariants(request, baseUrl, file, bucketName, onProgress, options, getAuthHeaders) {
|
|
3211
|
+
let variants = [];
|
|
3212
|
+
try {
|
|
3213
|
+
variants = await createCompressedImageVariants(file, options.imageCompression);
|
|
3214
|
+
} catch {
|
|
3215
|
+
variants = [];
|
|
3216
|
+
}
|
|
3217
|
+
if (variants.length === 0) {
|
|
3218
|
+
return uploadSingleRuntimeFile(
|
|
3219
|
+
request,
|
|
3220
|
+
baseUrl,
|
|
3221
|
+
file,
|
|
3222
|
+
bucketName,
|
|
3223
|
+
onProgress,
|
|
3224
|
+
options,
|
|
3225
|
+
getAuthHeaders
|
|
3226
|
+
);
|
|
3227
|
+
}
|
|
3228
|
+
const originalProgressEnd = 70;
|
|
3229
|
+
const uploaded = await uploadSingleRuntimeFile(
|
|
3230
|
+
request,
|
|
3231
|
+
baseUrl,
|
|
3232
|
+
file,
|
|
3233
|
+
bucketName,
|
|
3234
|
+
createSegmentProgress(onProgress, 0, originalProgressEnd),
|
|
3235
|
+
options,
|
|
3236
|
+
getAuthHeaders
|
|
3237
|
+
);
|
|
3238
|
+
const imageVariants = { ...uploaded.variants || {} };
|
|
3239
|
+
const variantProgressStep = (100 - originalProgressEnd) / variants.length;
|
|
3240
|
+
for (let index = 0; index < variants.length; index += 1) {
|
|
3241
|
+
const variant = variants[index];
|
|
3242
|
+
const start = originalProgressEnd + variantProgressStep * index;
|
|
3243
|
+
const end = originalProgressEnd + variantProgressStep * (index + 1);
|
|
3244
|
+
try {
|
|
3245
|
+
const variantUpload = await uploadSingleRuntimeFile(
|
|
3246
|
+
request,
|
|
3247
|
+
baseUrl,
|
|
3248
|
+
variant.file,
|
|
3249
|
+
bucketName,
|
|
3250
|
+
createSegmentProgress(onProgress, start, end),
|
|
3251
|
+
options,
|
|
3252
|
+
getAuthHeaders
|
|
3253
|
+
);
|
|
3254
|
+
imageVariants[variant.kind] = toImageVariantMetadata(variantUpload, variant);
|
|
3255
|
+
} catch {
|
|
3256
|
+
onProgress?.(Math.round(end));
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
onProgress?.(100);
|
|
3260
|
+
return {
|
|
3261
|
+
...uploaded,
|
|
3262
|
+
thumbUrl: imageVariants.thumb?.url || uploaded.thumbUrl,
|
|
3263
|
+
previewUrl: imageVariants.preview?.url || uploaded.previewUrl || uploaded.url,
|
|
3264
|
+
variants: imageVariants.thumb || imageVariants.preview ? imageVariants : uploaded.variants
|
|
3265
|
+
};
|
|
3266
|
+
}
|
|
3267
|
+
function createFormRuntimeApi(config) {
|
|
3268
|
+
const { baseUrl = getDefaultBaseUrl(), ...overrides } = config ?? {};
|
|
3269
|
+
const { fetchImpl, getAuthHeaders } = overrides;
|
|
3270
|
+
const request = overrides.request ?? createDefaultRequest(baseUrl, fetchImpl, getAuthHeaders);
|
|
3271
|
+
const defaults = {
|
|
3272
|
+
request,
|
|
3273
|
+
uploadFile: async (file, bucketName = "files", onProgress, options = {}) => {
|
|
3274
|
+
return uploadFileWithImageVariants(
|
|
3275
|
+
request,
|
|
3276
|
+
baseUrl,
|
|
3277
|
+
file,
|
|
3278
|
+
bucketName,
|
|
3279
|
+
onProgress,
|
|
3280
|
+
options,
|
|
3281
|
+
getAuthHeaders
|
|
3282
|
+
);
|
|
3283
|
+
},
|
|
3284
|
+
uploadPublicFile: async (file, bucketName = DEFAULT_PUBLIC_FILE_BUCKET, onProgress) => {
|
|
3285
|
+
if (file.size > CHUNK_UPLOAD_THRESHOLD) {
|
|
3286
|
+
return uploadChunkedFile(request, file, bucketName, baseUrl, onProgress, {
|
|
3287
|
+
visibility: "public"
|
|
3288
|
+
});
|
|
3289
|
+
}
|
|
3290
|
+
return uploadWithXhr(baseUrl, file, bucketName, onProgress, {
|
|
3291
|
+
visibility: "public"
|
|
3292
|
+
}, getAuthHeaders);
|
|
3293
|
+
},
|
|
3294
|
+
deleteFile: async (objectName, bucketName = "files", options = {}) => {
|
|
3295
|
+
if (options.uploadProvider === "builtin-oss" || options.storageScope === "platform") {
|
|
3296
|
+
if (!options.appType) throw new Error("\u5E73\u53F0\u5185\u7F6E OSS \u5220\u9664\u7F3A\u5C11 appType");
|
|
3297
|
+
await request({
|
|
3298
|
+
url: `/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
3299
|
+
options.appType
|
|
3300
|
+
)}/storage/builtin/objects/delete`,
|
|
3301
|
+
method: "post",
|
|
3302
|
+
data: { bucketName, objectName }
|
|
3303
|
+
});
|
|
3304
|
+
return { success: true };
|
|
3305
|
+
}
|
|
3306
|
+
if (options.uploadProvider === "oss" || options.storageCode) {
|
|
3307
|
+
if (!options.appType) throw new Error("OSS \u5220\u9664\u7F3A\u5C11 appType");
|
|
3308
|
+
if (!options.storageCode) throw new Error("OSS \u5220\u9664\u7F3A\u5C11 storageCode");
|
|
3309
|
+
await request({
|
|
3310
|
+
url: `/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
3311
|
+
options.appType
|
|
3312
|
+
)}/storage-configs/${encodeURIComponent(options.storageCode)}/objects/delete`,
|
|
3313
|
+
method: "post",
|
|
3314
|
+
data: { bucketName, objectName }
|
|
3315
|
+
});
|
|
3316
|
+
return { success: true };
|
|
3317
|
+
}
|
|
3318
|
+
await request({ url: "/file/delete", method: "post", data: { bucketName, objectName } });
|
|
3319
|
+
return { success: true };
|
|
3320
|
+
},
|
|
3321
|
+
createDownloadTicket: async (bucketName, objectName, fileName) => {
|
|
3322
|
+
const response = await request({
|
|
3323
|
+
url: "/file/download-ticket",
|
|
3324
|
+
method: "post",
|
|
3325
|
+
data: { bucketName, objectName, fileName }
|
|
3326
|
+
});
|
|
3327
|
+
return normalizeFileTicketResult(baseUrl, response.data || response.result);
|
|
3328
|
+
},
|
|
3329
|
+
createFileAccessTicket: async (bucketName, objectName, fileName, purpose = "preview", options = {}) => {
|
|
3330
|
+
const response = await request({
|
|
3331
|
+
url: "/file/access-ticket",
|
|
3332
|
+
method: "post",
|
|
3333
|
+
data: { bucketName, objectName, fileName, purpose, appType: options.appType }
|
|
3334
|
+
});
|
|
3335
|
+
return normalizeFileTicketResult(baseUrl, response.data || response.result);
|
|
3336
|
+
},
|
|
3337
|
+
getUserById: async (id) => {
|
|
3338
|
+
const response = await request({
|
|
3339
|
+
url: `/user/${id}`,
|
|
3340
|
+
method: "get"
|
|
3341
|
+
});
|
|
3342
|
+
return response.data || response.result;
|
|
3343
|
+
},
|
|
3344
|
+
getUserList: async (params) => {
|
|
3345
|
+
const response = await request({
|
|
3346
|
+
url: "/user/list",
|
|
3347
|
+
method: "get",
|
|
3348
|
+
params
|
|
3349
|
+
});
|
|
3350
|
+
const data = response.data || response.result;
|
|
3351
|
+
return Array.isArray(data) ? data : data?.items || data?.list || [];
|
|
3352
|
+
},
|
|
3353
|
+
getDepartmentRoots: async () => {
|
|
3354
|
+
const response = await request({
|
|
3355
|
+
url: "/department/root",
|
|
3356
|
+
method: "get"
|
|
3357
|
+
});
|
|
3358
|
+
return response.data || response.result || [];
|
|
3359
|
+
},
|
|
3360
|
+
getDepartmentChildren: async (parentId) => {
|
|
3361
|
+
const response = await request({
|
|
3362
|
+
url: `/department/${parentId}/children`,
|
|
3363
|
+
method: "get"
|
|
3364
|
+
});
|
|
3365
|
+
return response.data || response.result || [];
|
|
3366
|
+
},
|
|
3367
|
+
searchDepartments: async (params) => {
|
|
3368
|
+
const page = params?.page ?? 1;
|
|
3369
|
+
const pageSize = params?.pageSize ?? 50;
|
|
3370
|
+
const response = await request({
|
|
3371
|
+
url: "/department/search",
|
|
3372
|
+
method: "get",
|
|
3373
|
+
params: {
|
|
3374
|
+
keyword: params?.keyword,
|
|
3375
|
+
page,
|
|
3376
|
+
pageSize,
|
|
3377
|
+
includePath: params?.includePath ?? true
|
|
3378
|
+
}
|
|
3379
|
+
});
|
|
3380
|
+
const data = response.data || response.result;
|
|
3381
|
+
if (Array.isArray(data)) {
|
|
3382
|
+
return { items: data, total: data.length, page, pageSize };
|
|
3383
|
+
}
|
|
3384
|
+
return {
|
|
3385
|
+
items: data?.items || data?.list || [],
|
|
3386
|
+
total: Number(data?.total ?? data?.count ?? data?.items?.length ?? 0),
|
|
3387
|
+
page: Number(data?.page ?? page),
|
|
3388
|
+
pageSize: Number(data?.pageSize ?? pageSize)
|
|
3389
|
+
};
|
|
3390
|
+
},
|
|
3391
|
+
getDepartmentParentDepartments: async (id) => {
|
|
3392
|
+
const response = await request({
|
|
3393
|
+
url: `/department/${id}/parentDepartments`,
|
|
3394
|
+
method: "get"
|
|
3395
|
+
});
|
|
3396
|
+
return response.data || response.result || [];
|
|
3397
|
+
},
|
|
3398
|
+
getDepartmentMembers: async (id) => {
|
|
3399
|
+
const response = await request({
|
|
3400
|
+
url: `/department/${id}/members`,
|
|
3401
|
+
method: "get"
|
|
3402
|
+
});
|
|
3403
|
+
const data = response.data || response.result;
|
|
3404
|
+
return Array.isArray(data) ? data : data?.items || data?.list || [];
|
|
3405
|
+
},
|
|
3406
|
+
getDepartmentMembersPage: async (id, params) => {
|
|
3407
|
+
const page = params?.page ?? 1;
|
|
3408
|
+
const pageSize = params?.pageSize ?? 20;
|
|
3409
|
+
const response = await request({
|
|
3410
|
+
url: `/department/${id}/members`,
|
|
3411
|
+
method: "get",
|
|
3412
|
+
params: { page, pageSize }
|
|
3413
|
+
});
|
|
3414
|
+
const data = response.data || response.result;
|
|
3415
|
+
const items = Array.isArray(data) ? data : data?.items || data?.list || [];
|
|
3416
|
+
return {
|
|
3417
|
+
items,
|
|
3418
|
+
total: Number(data?.total ?? data?.count ?? items.length),
|
|
3419
|
+
page: Number(data?.page ?? page),
|
|
3420
|
+
pageSize: Number(data?.pageSize ?? pageSize)
|
|
3421
|
+
};
|
|
3422
|
+
},
|
|
3423
|
+
getChinaDivisions: async (parentAdcode) => {
|
|
3424
|
+
const response = await request({
|
|
3425
|
+
url: "/china-divisions",
|
|
3426
|
+
method: "get",
|
|
3427
|
+
params: parentAdcode ? { parentAdcode } : void 0
|
|
3428
|
+
});
|
|
3429
|
+
return response.data || response.result || [];
|
|
3430
|
+
},
|
|
3431
|
+
advancedSearch: async (params) => {
|
|
3432
|
+
const response = await request({
|
|
3433
|
+
url: `/${params.appType}/v1/form/advancedSearch.json`,
|
|
3434
|
+
method: "get",
|
|
3435
|
+
params
|
|
3436
|
+
});
|
|
3437
|
+
return response.result || response.data || {};
|
|
3438
|
+
},
|
|
3439
|
+
getDingTalkSignature: async (url) => {
|
|
3440
|
+
const response = await request({
|
|
3441
|
+
url: "/dingtalk/signature",
|
|
3442
|
+
method: "get",
|
|
3443
|
+
params: { url }
|
|
3444
|
+
});
|
|
3445
|
+
return response.data || response.result;
|
|
3446
|
+
},
|
|
3447
|
+
submitFormData: async (payload) => {
|
|
3448
|
+
const response = await request({
|
|
3449
|
+
url: "/form/submitFormData",
|
|
3450
|
+
method: "post",
|
|
3451
|
+
data: payload
|
|
3452
|
+
});
|
|
3453
|
+
return unwrapBusinessResponse(response);
|
|
3454
|
+
},
|
|
3455
|
+
updateFormData: async (payload) => {
|
|
3456
|
+
const data = normalizeFormInstancePayload(payload);
|
|
3457
|
+
const response = await request({
|
|
3458
|
+
url: `/${data.appType}/v1/form/updateFormData.json`,
|
|
3459
|
+
method: "post",
|
|
3460
|
+
data
|
|
3461
|
+
});
|
|
3462
|
+
return unwrapBusinessResponse(response);
|
|
3463
|
+
},
|
|
3464
|
+
startProcessFromExistingInstance: async (payload) => {
|
|
3465
|
+
const data = normalizeFormInstancePayload(payload);
|
|
3466
|
+
const response = await request({
|
|
3467
|
+
url: `/${data.appType}/v1/form/startProcessFromExistingInstance.json`,
|
|
3468
|
+
method: "post",
|
|
3469
|
+
data
|
|
3470
|
+
});
|
|
3471
|
+
return unwrapBusinessResponse(response);
|
|
3472
|
+
}
|
|
3473
|
+
};
|
|
3474
|
+
return { ...defaults, ...overrides, request };
|
|
3475
|
+
}
|
|
3476
|
+
|
|
3477
|
+
// packages/sdk/src/components/fields/shared/fieldFormat.ts
|
|
3478
|
+
function getUserId(user) {
|
|
3479
|
+
if (typeof user === "string" || typeof user === "number") return String(user).trim();
|
|
3480
|
+
return String(user?.id || user?.userId || user?.userid || user?.value || user?.key || "").trim();
|
|
3481
|
+
}
|
|
3482
|
+
function getUserName(user) {
|
|
3483
|
+
if (typeof user === "string" || typeof user === "number") return String(user).trim();
|
|
3484
|
+
return String(
|
|
3485
|
+
user?.name || user?.label || user?.title || user?.username || user?.nickname || getUserId(user)
|
|
3486
|
+
);
|
|
3487
|
+
}
|
|
3488
|
+
function normalizeUser(user) {
|
|
3489
|
+
const id = getUserId(user);
|
|
3490
|
+
const source = typeof user === "object" && user !== null ? user : {};
|
|
3491
|
+
return {
|
|
3492
|
+
...source,
|
|
3493
|
+
id,
|
|
3494
|
+
name: getUserName({ ...source, id })
|
|
3495
|
+
};
|
|
3496
|
+
}
|
|
3497
|
+
function getDepartmentId(node) {
|
|
3498
|
+
if (typeof node === "string" || typeof node === "number") return String(node).trim();
|
|
3499
|
+
return String(
|
|
3500
|
+
node?.id || node?.departmentId || node?.deptId || node?.value || node?.key || ""
|
|
3501
|
+
).trim();
|
|
3502
|
+
}
|
|
3503
|
+
function getDepartmentName(node) {
|
|
3504
|
+
if (typeof node === "string" || typeof node === "number") return String(node).trim();
|
|
3505
|
+
return String(
|
|
3506
|
+
node?.name || node?.label || node?.title || node?.deptName || node?.departmentName || getDepartmentId(node)
|
|
3507
|
+
);
|
|
3508
|
+
}
|
|
3509
|
+
function normalizeDepartmentNode(node) {
|
|
3510
|
+
const id = getDepartmentId(node);
|
|
3511
|
+
const source = typeof node === "object" && node !== null ? node : {};
|
|
3512
|
+
const name = getDepartmentName({ ...source, id });
|
|
3513
|
+
const hasChildren = typeof node?.hasChildren === "boolean" ? node.hasChildren : Array.isArray(node?.children) && node.children.length > 0;
|
|
3514
|
+
const children = Array.isArray(node?.children) ? node.children.map((child) => normalizeDepartmentNode(child)) : void 0;
|
|
3515
|
+
return {
|
|
3516
|
+
...source,
|
|
3517
|
+
id,
|
|
3518
|
+
name,
|
|
3519
|
+
key: String(node?.key || id),
|
|
3520
|
+
title: String(node?.title || name),
|
|
3521
|
+
hasChildren,
|
|
3522
|
+
isLeaf: typeof node?.isLeaf === "boolean" ? node.isLeaf : !hasChildren,
|
|
3523
|
+
children
|
|
3524
|
+
};
|
|
3525
|
+
}
|
|
3526
|
+
function flattenDepartments(nodes) {
|
|
3527
|
+
const result = [];
|
|
3528
|
+
const walk = (items) => {
|
|
3529
|
+
for (const node of items) {
|
|
3530
|
+
const id = getDepartmentId(node);
|
|
3531
|
+
if (id) result.push({ id, name: getDepartmentName(node), node });
|
|
3532
|
+
if (node.children?.length) walk(node.children);
|
|
3533
|
+
}
|
|
3534
|
+
};
|
|
3535
|
+
walk(nodes);
|
|
3536
|
+
return result;
|
|
3537
|
+
}
|
|
3538
|
+
function formatFileSize(bytes) {
|
|
3539
|
+
if (!bytes) return "";
|
|
3540
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
3541
|
+
let value = bytes;
|
|
3542
|
+
let index = 0;
|
|
3543
|
+
while (value >= 1024 && index < units.length - 1) {
|
|
3544
|
+
value /= 1024;
|
|
3545
|
+
index += 1;
|
|
3546
|
+
}
|
|
3547
|
+
return `${Number(value.toFixed(value >= 10 || index === 0 ? 0 : 1))} ${units[index]}`;
|
|
3548
|
+
}
|
|
3549
|
+
function getFileExtension(fileName) {
|
|
3550
|
+
return String(fileName || "").split(".").pop()?.toLowerCase() || "";
|
|
3551
|
+
}
|
|
3552
|
+
function isImageFile(fileName, contentType) {
|
|
3553
|
+
return String(contentType || "").startsWith("image/") || [
|
|
3554
|
+
"jpg",
|
|
3555
|
+
"jpeg",
|
|
3556
|
+
"png",
|
|
3557
|
+
"gif",
|
|
3558
|
+
"bmp",
|
|
3559
|
+
"svg",
|
|
3560
|
+
"webp",
|
|
3561
|
+
"avif",
|
|
3562
|
+
"ico",
|
|
3563
|
+
"heic",
|
|
3564
|
+
"heif",
|
|
3565
|
+
"tif",
|
|
3566
|
+
"tiff"
|
|
3567
|
+
].includes(getFileExtension(fileName));
|
|
3568
|
+
}
|
|
3569
|
+
function getFileCategory(fileName, contentType) {
|
|
3570
|
+
const ext = getFileExtension(fileName);
|
|
3571
|
+
if (isImageFile(fileName, contentType)) return "image";
|
|
3572
|
+
if (["mp4", "webm", "ogg", "mov", "m4v"].includes(ext)) return "video";
|
|
3573
|
+
if (["mp3", "wav", "aac", "flac", "m4a", "ogg"].includes(ext)) return "audio";
|
|
3574
|
+
if (ext === "pdf") return "pdf";
|
|
3575
|
+
if (["xls", "xlsx", "csv"].includes(ext)) return "excel";
|
|
3576
|
+
if (["doc", "docx"].includes(ext)) return "word";
|
|
3577
|
+
if (["ppt", "pptx"].includes(ext)) return "ppt";
|
|
3578
|
+
if (["zip", "rar", "7z", "tar", "gz"].includes(ext)) return "archive";
|
|
3579
|
+
if (["txt", "json", "xml", "log", "md"].includes(ext)) return "text";
|
|
3580
|
+
if (["js", "jsx", "ts", "tsx", "html", "css", "scss", "less", "java", "py"].includes(ext)) {
|
|
3581
|
+
return "code";
|
|
3582
|
+
}
|
|
3583
|
+
return "file";
|
|
3584
|
+
}
|
|
3585
|
+
function getAttachmentItemIdentity(item) {
|
|
3586
|
+
return String(item?.uid || item?.id || item?.objectName || item?.url || item?.name || "");
|
|
3587
|
+
}
|
|
3588
|
+
|
|
3589
|
+
// packages/sdk/src/components/file-preview/capabilities.ts
|
|
3590
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
3591
|
+
"jpg",
|
|
3592
|
+
"jpeg",
|
|
3593
|
+
"png",
|
|
3594
|
+
"gif",
|
|
3595
|
+
"bmp",
|
|
3596
|
+
"webp",
|
|
3597
|
+
"svg",
|
|
3598
|
+
"avif",
|
|
3599
|
+
"ico",
|
|
3600
|
+
"tif",
|
|
3601
|
+
"tiff",
|
|
3602
|
+
"heic",
|
|
3603
|
+
"heif"
|
|
3604
|
+
]);
|
|
3605
|
+
var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set(["mp4", "webm", "ogg", "ogv", "mov", "m4v"]);
|
|
3606
|
+
var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set(["mp3", "wav", "ogg", "oga", "m4a", "aac", "flac"]);
|
|
3607
|
+
var DIRECT_XLSX_MAX_BYTES = 10 * 1024 * 1024;
|
|
3608
|
+
var DIRECT_DOCX_MAX_BYTES = 20 * 1024 * 1024;
|
|
3609
|
+
var DIRECT_HEIC_MAX_BYTES = 30 * 1024 * 1024;
|
|
3610
|
+
var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
3611
|
+
"txt",
|
|
3612
|
+
"csv",
|
|
3613
|
+
"tsv",
|
|
3614
|
+
"json",
|
|
3615
|
+
"xml",
|
|
3616
|
+
"log",
|
|
3617
|
+
"md",
|
|
3618
|
+
"markdown",
|
|
3619
|
+
"yaml",
|
|
3620
|
+
"yml",
|
|
3621
|
+
"ini",
|
|
3622
|
+
"conf",
|
|
3623
|
+
"properties",
|
|
3624
|
+
"sql",
|
|
3625
|
+
"js",
|
|
3626
|
+
"jsx",
|
|
3627
|
+
"ts",
|
|
3628
|
+
"tsx",
|
|
3629
|
+
"css",
|
|
3630
|
+
"scss",
|
|
3631
|
+
"less",
|
|
3632
|
+
"html",
|
|
3633
|
+
"htm",
|
|
3634
|
+
"java",
|
|
3635
|
+
"py",
|
|
3636
|
+
"go",
|
|
3637
|
+
"rs",
|
|
3638
|
+
"sh",
|
|
3639
|
+
"bash",
|
|
3640
|
+
"c",
|
|
3641
|
+
"cc",
|
|
3642
|
+
"cpp",
|
|
3643
|
+
"h",
|
|
3644
|
+
"hpp",
|
|
3645
|
+
"cs",
|
|
3646
|
+
"php",
|
|
3647
|
+
"rb",
|
|
3648
|
+
"vue"
|
|
3649
|
+
]);
|
|
3650
|
+
var unwrapFilePreviewPayload = (payload) => payload?.data ?? payload?.result ?? payload;
|
|
3651
|
+
var getBinaryResponseMessage = (response) => String(
|
|
3652
|
+
response?.message || response?.error || response?.errorMessage || response?.data?.message || response?.data?.error || response?.result?.message || ""
|
|
3653
|
+
).trim();
|
|
3654
|
+
var normalizePreviewBlobResponse = (response) => {
|
|
3655
|
+
const payload = response;
|
|
3656
|
+
const candidates = [
|
|
3657
|
+
response,
|
|
3658
|
+
payload?.blob,
|
|
3659
|
+
payload?.data,
|
|
3660
|
+
payload?.data?.blob,
|
|
3661
|
+
payload?.result,
|
|
3662
|
+
payload?.result?.blob
|
|
3663
|
+
];
|
|
3664
|
+
const blob = candidates.find(
|
|
3665
|
+
(candidate) => typeof Blob !== "undefined" && candidate instanceof Blob
|
|
3666
|
+
);
|
|
3667
|
+
if (blob) return blob;
|
|
3668
|
+
throw new Error(getBinaryResponseMessage(payload) || "\u6587\u4EF6\u5185\u5BB9\u54CD\u5E94\u4E0D\u662F\u4E8C\u8FDB\u5236\u6570\u636E");
|
|
3669
|
+
};
|
|
3670
|
+
var isZipBytes = (bytes) => bytes.length >= 4 && bytes[0] === 80 && bytes[1] === 75 && (bytes[2] === 3 && bytes[3] === 4 || bytes[2] === 5 && bytes[3] === 6 || bytes[2] === 7 && bytes[3] === 8);
|
|
3671
|
+
var decodeBase64ZipBlob = async (blob) => {
|
|
3672
|
+
const prefix = (await blob.slice(0, 96).text()).replace(/^\uFEFF/, "").replace(/\s+/g, "");
|
|
3673
|
+
if (!prefix.startsWith("UEsDB")) return blob;
|
|
3674
|
+
if (blob.size > 32 * 1024 * 1024) {
|
|
3675
|
+
throw new Error("Base64 \u6587\u4EF6\u8D85\u8FC7\u6D4F\u89C8\u5668\u517C\u5BB9\u89E3\u7801\u4E0A\u9650");
|
|
3676
|
+
}
|
|
3677
|
+
const base64 = (await blob.text()).replace(/^\uFEFF/, "").replace(/\s+/g, "");
|
|
3678
|
+
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(base64)) {
|
|
3679
|
+
throw new Error("\u6587\u4EF6\u5185\u5BB9\u662F\u65E0\u6548\u7684 Base64 \u4E8C\u8FDB\u5236\u6570\u636E");
|
|
3680
|
+
}
|
|
3681
|
+
let binary = "";
|
|
3682
|
+
try {
|
|
3683
|
+
binary = globalThis.atob(base64);
|
|
3684
|
+
} catch {
|
|
3685
|
+
throw new Error("\u6587\u4EF6\u5185\u5BB9\u662F\u65E0\u6548\u7684 Base64 \u4E8C\u8FDB\u5236\u6570\u636E");
|
|
3686
|
+
}
|
|
3687
|
+
const bytes = new Uint8Array(binary.length);
|
|
3688
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
3689
|
+
bytes[index] = binary.charCodeAt(index);
|
|
3690
|
+
}
|
|
3691
|
+
if (!isZipBytes(bytes)) {
|
|
3692
|
+
throw new Error("Base64 \u6587\u4EF6\u89E3\u7801\u540E\u4E0D\u662F\u6709\u6548\u7684 Office \u6587\u6863");
|
|
3693
|
+
}
|
|
3694
|
+
if (globalThis.btoa(binary).replace(/=+$/, "") !== base64.replace(/=+$/, "")) {
|
|
3695
|
+
throw new Error("\u6587\u4EF6\u5185\u5BB9\u662F\u65E0\u6548\u7684 Base64 \u4E8C\u8FDB\u5236\u6570\u636E");
|
|
3696
|
+
}
|
|
3697
|
+
return new Blob([bytes], { type: blob.type || "application/zip" });
|
|
3698
|
+
};
|
|
3699
|
+
var normalizePreviewBlobContent = async (response) => {
|
|
3700
|
+
const blob = normalizePreviewBlobResponse(response);
|
|
3701
|
+
if (String(blob.type || "").toLowerCase().includes("application/json")) {
|
|
3702
|
+
const payload = await blob.text().then((value) => JSON.parse(value)).catch(() => null);
|
|
3703
|
+
if (payload) {
|
|
3704
|
+
throw new Error(getBinaryResponseMessage(payload) || "\u6587\u4EF6\u5185\u5BB9\u8BF7\u6C42\u5931\u8D25");
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
return decodeBase64ZipBlob(blob);
|
|
3708
|
+
};
|
|
3709
|
+
var isDirectStorageItem = (item) => item.provider === "oss" || item.uploadProvider === "oss" || item.uploadProvider === "builtin-oss" || Boolean(item.storageCode);
|
|
3710
|
+
var getPreviewItemKey = (item, index = 0) => getAttachmentItemIdentity(item) || item.id || item.uid || `${item.name || "file"}-${index}`;
|
|
3711
|
+
var getPreviewSourceUrl = (item) => item.previewUrl || item.publicUrl || item.url || "";
|
|
3712
|
+
var inferExtensionFromContentType = (contentType) => {
|
|
3713
|
+
if (contentType.includes("wordprocessingml")) return "docx";
|
|
3714
|
+
if (contentType.includes("spreadsheetml")) return "xlsx";
|
|
3715
|
+
if (contentType.includes("pdf")) return "pdf";
|
|
3716
|
+
if (contentType.includes("heic")) return "heic";
|
|
3717
|
+
if (contentType.includes("heif")) return "heif";
|
|
3718
|
+
if (contentType.includes("tiff")) return "tiff";
|
|
3719
|
+
if (contentType.includes("csv")) return "csv";
|
|
3720
|
+
return "";
|
|
3721
|
+
};
|
|
3722
|
+
var downloadOnly = (extension, unsupportedReason) => ({
|
|
3723
|
+
extension,
|
|
3724
|
+
previewType: "download",
|
|
3725
|
+
renderMode: "download",
|
|
3726
|
+
previewSurface: "download",
|
|
3727
|
+
previewProvider: "none",
|
|
3728
|
+
canPreview: false,
|
|
3729
|
+
canDownload: true,
|
|
3730
|
+
unsupportedReason
|
|
3731
|
+
});
|
|
3732
|
+
var resolveLocalPreviewCapability = (item) => {
|
|
3733
|
+
const contentType = String(item.contentType || item.mimeType || "").toLowerCase();
|
|
3734
|
+
const extension = getFileExtension(item.name || item.originalName || item.objectName || "") || inferExtensionFromContentType(contentType);
|
|
3735
|
+
const size = Number(item.size || 0);
|
|
3736
|
+
if (IMAGE_EXTENSIONS.has(extension) || contentType.startsWith("image/")) {
|
|
3737
|
+
if (["heic", "heif"].includes(extension) && size > 0 && size > DIRECT_HEIC_MAX_BYTES) {
|
|
3738
|
+
return downloadOnly(extension, "HEIC \u56FE\u7247\u8D85\u8FC7 30MB \u6D4F\u89C8\u5668\u8F6C\u6362\u4E0A\u9650");
|
|
3739
|
+
}
|
|
3740
|
+
const platformTranscode = ["tif", "tiff"].includes(extension) && Boolean(item.objectName) && !isDirectStorageItem(item);
|
|
3741
|
+
return {
|
|
3742
|
+
extension,
|
|
3743
|
+
previewType: "image",
|
|
3744
|
+
renderMode: ["heic", "heif"].includes(extension) ? "image-heic" : platformTranscode ? "image-transcode" : ["tif", "tiff"].includes(extension) ? "download" : "inline",
|
|
3745
|
+
previewSurface: "media",
|
|
3746
|
+
previewProvider: platformTranscode ? "platform" : "browser",
|
|
3747
|
+
canPreview: platformTranscode || !["tif", "tiff"].includes(extension),
|
|
3748
|
+
canDownload: true,
|
|
3749
|
+
unsupportedReason: ["tif", "tiff"].includes(extension) ? "\u76F4\u8FDE TIFF \u6587\u4EF6\u9700\u8981\u5E73\u53F0\u6587\u4EF6\u670D\u52A1\u8F6C\u6362\u540E\u624D\u80FD\u9884\u89C8" : void 0
|
|
3750
|
+
};
|
|
3751
|
+
}
|
|
3752
|
+
if (VIDEO_EXTENSIONS.has(extension) || contentType.startsWith("video/")) {
|
|
3753
|
+
return {
|
|
3754
|
+
extension,
|
|
3755
|
+
previewType: "video",
|
|
3756
|
+
renderMode: "inline",
|
|
3757
|
+
previewSurface: "media",
|
|
3758
|
+
previewProvider: "browser",
|
|
3759
|
+
canPreview: true,
|
|
3760
|
+
canDownload: true
|
|
3761
|
+
};
|
|
3762
|
+
}
|
|
3763
|
+
if (AUDIO_EXTENSIONS.has(extension) || contentType.startsWith("audio/")) {
|
|
3764
|
+
return {
|
|
3765
|
+
extension,
|
|
3766
|
+
previewType: "audio",
|
|
3767
|
+
renderMode: "inline",
|
|
3768
|
+
previewSurface: "media",
|
|
3769
|
+
previewProvider: "browser",
|
|
3770
|
+
canPreview: true,
|
|
3771
|
+
canDownload: true
|
|
3772
|
+
};
|
|
3773
|
+
}
|
|
3774
|
+
if (extension === "pdf" || contentType.includes("pdf")) {
|
|
3775
|
+
return {
|
|
3776
|
+
extension: extension || "pdf",
|
|
3777
|
+
previewType: "pdf",
|
|
3778
|
+
renderMode: "pdfjs",
|
|
3779
|
+
previewSurface: "document",
|
|
3780
|
+
previewProvider: "browser",
|
|
3781
|
+
canPreview: true,
|
|
3782
|
+
canDownload: true
|
|
3783
|
+
};
|
|
3784
|
+
}
|
|
3785
|
+
if (extension === "docx") {
|
|
3786
|
+
if (size > 0 && size > DIRECT_DOCX_MAX_BYTES) {
|
|
3787
|
+
return downloadOnly(extension, "Word \u6587\u4EF6\u8D85\u8FC7 20MB \u6D4F\u89C8\u5668\u9884\u89C8\u4E0A\u9650");
|
|
3788
|
+
}
|
|
3789
|
+
return {
|
|
3790
|
+
extension,
|
|
3791
|
+
previewType: "office",
|
|
3792
|
+
renderMode: "docx-html",
|
|
3793
|
+
previewSurface: "document",
|
|
3794
|
+
previewProvider: "browser",
|
|
3795
|
+
canPreview: true,
|
|
3796
|
+
canDownload: true
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3799
|
+
if (extension === "xlsx") {
|
|
3800
|
+
if (size > 0 && size > DIRECT_XLSX_MAX_BYTES) {
|
|
3801
|
+
return downloadOnly(extension, "Excel \u6587\u4EF6\u8D85\u8FC7 10MB \u6D4F\u89C8\u5668\u9884\u89C8\u4E0A\u9650");
|
|
3802
|
+
}
|
|
3803
|
+
return {
|
|
3804
|
+
extension,
|
|
3805
|
+
previewType: "spreadsheet",
|
|
3806
|
+
renderMode: "excel-client",
|
|
3807
|
+
previewSurface: "document",
|
|
3808
|
+
previewProvider: "browser",
|
|
3809
|
+
canPreview: true,
|
|
3810
|
+
canDownload: true
|
|
3811
|
+
};
|
|
3812
|
+
}
|
|
3813
|
+
if (TEXT_EXTENSIONS.has(extension) || contentType.startsWith("text/")) {
|
|
3814
|
+
return {
|
|
3815
|
+
extension,
|
|
3816
|
+
previewType: "text",
|
|
3817
|
+
renderMode: "text-client",
|
|
3818
|
+
previewSurface: "document",
|
|
3819
|
+
previewProvider: "browser",
|
|
3820
|
+
canPreview: true,
|
|
3821
|
+
canDownload: true
|
|
3822
|
+
};
|
|
3823
|
+
}
|
|
3824
|
+
return downloadOnly(extension, "\u5F53\u524D\u6587\u4EF6\u7C7B\u578B\u6CA1\u6709\u53EF\u7528\u7684\u5728\u7EBF\u9884\u89C8\u5668");
|
|
3825
|
+
};
|
|
3826
|
+
var getTicketObject = (ticket) => typeof ticket === "string" ? { previewUrl: ticket } : ticket || {};
|
|
3827
|
+
var prepareFilePreview = async (options) => {
|
|
3828
|
+
const { item, api, appType, bucketName } = options;
|
|
3829
|
+
const direct = isDirectStorageItem(item) || !item.objectName;
|
|
3830
|
+
if (direct) {
|
|
3831
|
+
const capability = resolveLocalPreviewCapability(item);
|
|
3832
|
+
return {
|
|
3833
|
+
item,
|
|
3834
|
+
direct: true,
|
|
3835
|
+
metadata: {
|
|
3836
|
+
...capability,
|
|
3837
|
+
fileName: item.name,
|
|
3838
|
+
size: item.size,
|
|
3839
|
+
contentType: item.contentType || item.mimeType,
|
|
3840
|
+
previewUrl: getPreviewSourceUrl(item),
|
|
3841
|
+
downloadUrl: item.downloadUrl || item.publicUrl || item.url
|
|
3842
|
+
}
|
|
3843
|
+
};
|
|
3844
|
+
}
|
|
3845
|
+
const ticketResult = getTicketObject(
|
|
3846
|
+
await api.createFileAccessTicket(
|
|
3847
|
+
item.bucketName || bucketName,
|
|
3848
|
+
item.objectName,
|
|
3849
|
+
item.name,
|
|
3850
|
+
"preview",
|
|
3851
|
+
{ appType: item.appType || appType }
|
|
3852
|
+
)
|
|
3853
|
+
);
|
|
3854
|
+
const localCapability = resolveLocalPreviewCapability(item);
|
|
3855
|
+
const ticket = String(ticketResult.ticket || "").trim();
|
|
3856
|
+
let metadata = {};
|
|
3857
|
+
if (ticketResult.metadataUrl || ticket) {
|
|
3858
|
+
const response = await api.request({
|
|
3859
|
+
url: ticketResult.metadataUrl || `/file/access-ticket/${encodeURIComponent(ticket)}`,
|
|
3860
|
+
method: "get"
|
|
3861
|
+
});
|
|
3862
|
+
metadata = unwrapFilePreviewPayload(response);
|
|
3863
|
+
}
|
|
3864
|
+
return {
|
|
3865
|
+
item,
|
|
3866
|
+
direct: false,
|
|
3867
|
+
metadata: {
|
|
3868
|
+
...localCapability,
|
|
3869
|
+
...ticketResult,
|
|
3870
|
+
...metadata,
|
|
3871
|
+
ticket: metadata.ticket || ticketResult.ticket,
|
|
3872
|
+
fileName: metadata.fileName || ticketResult.fileName || item.name,
|
|
3873
|
+
size: metadata.size ?? item.size,
|
|
3874
|
+
contentType: metadata.contentType || ticketResult.contentType || item.contentType || item.mimeType,
|
|
3875
|
+
previewUrl: ticketResult.previewUrl || metadata.previewUrl || getPreviewSourceUrl(item),
|
|
3876
|
+
downloadUrl: ticketResult.downloadUrl || metadata.downloadUrl || item.downloadUrl || item.publicUrl || item.url
|
|
3877
|
+
}
|
|
3878
|
+
};
|
|
3879
|
+
};
|
|
3880
|
+
var loadPreviewBlob = async (request, url) => {
|
|
3881
|
+
const response = await request({ url, method: "get", responseType: "blob" });
|
|
3882
|
+
return normalizePreviewBlobContent(response);
|
|
3883
|
+
};
|
|
3884
|
+
var convertHeicPreview = async (request, url) => {
|
|
3885
|
+
const source = await loadPreviewBlob(request, url);
|
|
3886
|
+
const module = await import("heic2any");
|
|
3887
|
+
const converted = await module.default({
|
|
3888
|
+
blob: source,
|
|
3889
|
+
toType: "image/jpeg",
|
|
3890
|
+
quality: 0.92
|
|
3891
|
+
});
|
|
3892
|
+
const blob = Array.isArray(converted) ? converted[0] : converted;
|
|
3893
|
+
if (!(blob instanceof Blob)) {
|
|
3894
|
+
throw new Error("HEIC \u56FE\u7247\u8F6C\u6362\u5931\u8D25");
|
|
3895
|
+
}
|
|
3896
|
+
return URL.createObjectURL(blob);
|
|
3897
|
+
};
|
|
3898
|
+
|
|
3899
|
+
// packages/sdk/src/components/file-preview/FilePreviewContent.tsx
|
|
3900
|
+
import { useEffect as useEffect3, useMemo as useMemo4, useRef as useRef2, useState as useState3 } from "react";
|
|
3901
|
+
import { Alert, Button, Empty, Image as Image2, Spin, Table, Tabs, Typography } from "antd";
|
|
3902
|
+
import { DownloadOutlined, FileOutlined, ReloadOutlined } from "@ant-design/icons";
|
|
3903
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
3904
|
+
var formatPreviewFileSize = (size) => {
|
|
3905
|
+
const value = Number(size || 0);
|
|
3906
|
+
if (!value) return "0 B";
|
|
3907
|
+
const units = ["B", "KB", "MB", "GB"];
|
|
3908
|
+
const index = Math.min(
|
|
3909
|
+
units.length - 1,
|
|
3910
|
+
Math.floor(Math.log(value) / Math.log(1024))
|
|
3911
|
+
);
|
|
3912
|
+
return `${(value / Math.pow(1024, index)).toFixed(index === 0 ? 0 : 1)} ${units[index]}`;
|
|
3913
|
+
};
|
|
3914
|
+
var resolvePreviewServiceUrl = (url, servicePrefix = "/service") => {
|
|
3915
|
+
const value = String(url || "").trim();
|
|
3916
|
+
if (!value) return "";
|
|
3917
|
+
if (/^(https?:)?\/\//i.test(value) || /^(blob|data):/i.test(value)) return value;
|
|
3918
|
+
if (value === servicePrefix || value.startsWith(`${servicePrefix}/`)) return value;
|
|
3919
|
+
if (value.startsWith("/file/")) {
|
|
3920
|
+
return `${servicePrefix.replace(/\/+$/, "")}${value}`;
|
|
3921
|
+
}
|
|
3922
|
+
return value;
|
|
3923
|
+
};
|
|
3924
|
+
var toColumnName = (index) => {
|
|
3925
|
+
let value = index + 1;
|
|
3926
|
+
let name = "";
|
|
3927
|
+
while (value > 0) {
|
|
3928
|
+
const mod = (value - 1) % 26;
|
|
3929
|
+
name = String.fromCharCode(65 + mod) + name;
|
|
3930
|
+
value = Math.floor((value - mod) / 26);
|
|
3931
|
+
}
|
|
3932
|
+
return name;
|
|
3933
|
+
};
|
|
3934
|
+
var buildRowsTable = (rows = []) => {
|
|
3935
|
+
const maxColumns = rows.reduce(
|
|
3936
|
+
(count, row) => Math.max(count, Array.isArray(row) ? row.length : 0),
|
|
3937
|
+
0
|
|
3938
|
+
);
|
|
3939
|
+
const columns = [
|
|
3940
|
+
{
|
|
3941
|
+
title: "#",
|
|
3942
|
+
dataIndex: "__row",
|
|
3943
|
+
key: "__row",
|
|
3944
|
+
width: 58,
|
|
3945
|
+
fixed: "left",
|
|
3946
|
+
render: (value) => /* @__PURE__ */ jsx3(Typography.Text, { type: "secondary", children: value })
|
|
3947
|
+
},
|
|
3948
|
+
...Array.from({ length: maxColumns }).map((_, index) => ({
|
|
3949
|
+
title: toColumnName(index),
|
|
3950
|
+
dataIndex: `col_${index}`,
|
|
3951
|
+
key: `col_${index}`,
|
|
3952
|
+
width: 168,
|
|
3953
|
+
render: (value) => /* @__PURE__ */ jsx3(Typography.Text, { ellipsis: { tooltip: String(value ?? "") }, children: String(value ?? "") })
|
|
3954
|
+
}))
|
|
3955
|
+
];
|
|
3956
|
+
const dataSource = rows.map((row, rowIndex) => {
|
|
3957
|
+
const record = { key: rowIndex, __row: rowIndex + 1 };
|
|
3958
|
+
(Array.isArray(row) ? row : []).forEach((value, colIndex) => {
|
|
3959
|
+
record[`col_${colIndex}`] = value;
|
|
3960
|
+
});
|
|
3961
|
+
return record;
|
|
3962
|
+
});
|
|
3963
|
+
return { columns, dataSource };
|
|
3964
|
+
};
|
|
3965
|
+
var CenteredState = ({ children }) => /* @__PURE__ */ jsx3(
|
|
3966
|
+
"div",
|
|
3967
|
+
{
|
|
3968
|
+
style: {
|
|
3969
|
+
minHeight: 280,
|
|
3970
|
+
height: "100%",
|
|
3971
|
+
display: "flex",
|
|
3972
|
+
alignItems: "center",
|
|
3973
|
+
justifyContent: "center",
|
|
3974
|
+
padding: 24
|
|
3975
|
+
},
|
|
3976
|
+
children
|
|
3977
|
+
}
|
|
3978
|
+
);
|
|
3979
|
+
var PayloadPreview = ({
|
|
3980
|
+
request,
|
|
3981
|
+
url,
|
|
3982
|
+
mode
|
|
3983
|
+
}) => {
|
|
3984
|
+
const [payload, setPayload] = useState3(null);
|
|
3985
|
+
const [loading, setLoading] = useState3(false);
|
|
3986
|
+
const [error, setError] = useState3("");
|
|
3987
|
+
const [reloadKey, setReloadKey] = useState3(0);
|
|
3988
|
+
useEffect3(() => {
|
|
3989
|
+
let disposed = false;
|
|
3990
|
+
setPayload(null);
|
|
3991
|
+
setError("");
|
|
3992
|
+
if (!url) return () => {
|
|
3993
|
+
disposed = true;
|
|
3994
|
+
};
|
|
3995
|
+
setLoading(true);
|
|
3996
|
+
request({ url, method: "get" }).then((response) => {
|
|
3997
|
+
if (!disposed) setPayload(unwrapFilePreviewPayload(response));
|
|
3998
|
+
}).catch((currentError) => {
|
|
3999
|
+
if (!disposed) setError(currentError?.message || "\u6587\u4EF6\u9884\u89C8\u5185\u5BB9\u52A0\u8F7D\u5931\u8D25");
|
|
4000
|
+
}).finally(() => {
|
|
4001
|
+
if (!disposed) setLoading(false);
|
|
4002
|
+
});
|
|
4003
|
+
return () => {
|
|
4004
|
+
disposed = true;
|
|
4005
|
+
};
|
|
4006
|
+
}, [reloadKey, request, url]);
|
|
4007
|
+
if (loading) {
|
|
4008
|
+
return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Spin, { description: mode === "excel" ? "\u6B63\u5728\u89E3\u6790\u5DE5\u4F5C\u7C3F..." : "\u6B63\u5728\u8BFB\u53D6\u6587\u672C..." }) });
|
|
4009
|
+
}
|
|
4010
|
+
if (error) {
|
|
4011
|
+
return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(
|
|
4012
|
+
Alert,
|
|
4013
|
+
{
|
|
4014
|
+
type: "error",
|
|
4015
|
+
showIcon: true,
|
|
4016
|
+
title: error,
|
|
4017
|
+
action: /* @__PURE__ */ jsx3(Button, { icon: /* @__PURE__ */ jsx3(ReloadOutlined, {}), onClick: () => setReloadKey((value) => value + 1), children: "\u91CD\u8BD5" })
|
|
4018
|
+
}
|
|
4019
|
+
) });
|
|
4020
|
+
}
|
|
4021
|
+
if (mode === "excel") {
|
|
4022
|
+
const sheets = Array.isArray(payload?.sheets) ? payload.sheets : [];
|
|
4023
|
+
if (!sheets.length) {
|
|
4024
|
+
return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Empty, { description: "\u6682\u65E0\u53EF\u9884\u89C8\u7684\u5DE5\u4F5C\u8868" }) });
|
|
4025
|
+
}
|
|
4026
|
+
return /* @__PURE__ */ jsx3(
|
|
4027
|
+
Tabs,
|
|
4028
|
+
{
|
|
4029
|
+
style: { height: "100%", padding: "0 16px" },
|
|
4030
|
+
items: sheets.map((sheet) => {
|
|
4031
|
+
const table = buildRowsTable(sheet.rows || []);
|
|
4032
|
+
return {
|
|
4033
|
+
key: String(sheet.id || sheet.name),
|
|
4034
|
+
label: sheet.name || "Sheet",
|
|
4035
|
+
children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
|
|
4036
|
+
sheet.truncatedRows || sheet.truncatedColumns ? /* @__PURE__ */ jsx3(
|
|
4037
|
+
Alert,
|
|
4038
|
+
{
|
|
4039
|
+
type: "info",
|
|
4040
|
+
showIcon: true,
|
|
4041
|
+
title: `\u5DE5\u4F5C\u8868\u8F83\u5927\uFF0C\u4EC5\u5C55\u793A\u524D ${payload.maxRows || 200} \u884C\u3001${payload.maxColumns || 60} \u5217\u3002`
|
|
4042
|
+
}
|
|
4043
|
+
) : null,
|
|
4044
|
+
/* @__PURE__ */ jsx3(
|
|
4045
|
+
Table,
|
|
4046
|
+
{
|
|
4047
|
+
bordered: true,
|
|
4048
|
+
size: "small",
|
|
4049
|
+
pagination: false,
|
|
4050
|
+
scroll: { x: "max-content", y: "min(66vh, 680px)" },
|
|
4051
|
+
columns: table.columns,
|
|
4052
|
+
dataSource: table.dataSource
|
|
4053
|
+
}
|
|
4054
|
+
)
|
|
4055
|
+
] })
|
|
4056
|
+
};
|
|
4057
|
+
})
|
|
4058
|
+
}
|
|
4059
|
+
);
|
|
4060
|
+
}
|
|
4061
|
+
const text = String(payload?.text || "");
|
|
4062
|
+
return /* @__PURE__ */ jsxs("div", { style: { height: "100%", overflow: "auto", background: "#fff" }, children: [
|
|
4063
|
+
payload?.truncated ? /* @__PURE__ */ jsx3(
|
|
4064
|
+
Alert,
|
|
4065
|
+
{
|
|
4066
|
+
type: "info",
|
|
4067
|
+
showIcon: true,
|
|
4068
|
+
banner: true,
|
|
4069
|
+
title: "\u6587\u4EF6\u8F83\u5927\uFF0C\u4EC5\u5C55\u793A\u524D\u90E8\u5185\u5BB9\uFF1B\u5B8C\u6574\u5185\u5BB9\u8BF7\u4E0B\u8F7D\u67E5\u770B\u3002"
|
|
4070
|
+
}
|
|
4071
|
+
) : null,
|
|
4072
|
+
/* @__PURE__ */ jsx3(
|
|
4073
|
+
"pre",
|
|
4074
|
+
{
|
|
4075
|
+
style: {
|
|
4076
|
+
minHeight: 280,
|
|
4077
|
+
margin: 0,
|
|
4078
|
+
padding: 20,
|
|
4079
|
+
color: "#1f2328",
|
|
4080
|
+
background: "#fff",
|
|
4081
|
+
fontSize: 13,
|
|
4082
|
+
lineHeight: 1.7,
|
|
4083
|
+
whiteSpace: "pre-wrap",
|
|
4084
|
+
wordBreak: "break-word",
|
|
4085
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace'
|
|
4086
|
+
},
|
|
4087
|
+
children: text || "\u6682\u65E0\u6587\u672C\u5185\u5BB9"
|
|
4088
|
+
}
|
|
4089
|
+
)
|
|
4090
|
+
] });
|
|
4091
|
+
};
|
|
4092
|
+
var ClientTextPreview = ({
|
|
4093
|
+
request,
|
|
4094
|
+
url
|
|
4095
|
+
}) => {
|
|
4096
|
+
const [payload, setPayload] = useState3(null);
|
|
4097
|
+
const [error, setError] = useState3("");
|
|
4098
|
+
useEffect3(() => {
|
|
4099
|
+
let disposed = false;
|
|
4100
|
+
let textLimit = 1024 * 1024;
|
|
4101
|
+
loadPreviewBlob(request, url).then(async (blob) => {
|
|
4102
|
+
const slice = blob.size > textLimit ? blob.slice(0, textLimit) : blob;
|
|
4103
|
+
const text = await slice.text();
|
|
4104
|
+
if (!disposed) setPayload({ text, truncated: blob.size > textLimit });
|
|
4105
|
+
}).catch((currentError) => {
|
|
4106
|
+
if (!disposed) setError(currentError?.message || "\u6587\u672C\u8BFB\u53D6\u5931\u8D25");
|
|
4107
|
+
});
|
|
4108
|
+
return () => {
|
|
4109
|
+
disposed = true;
|
|
4110
|
+
textLimit = 0;
|
|
4111
|
+
};
|
|
4112
|
+
}, [request, url]);
|
|
4113
|
+
if (error) return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Alert, { type: "error", showIcon: true, title: error }) });
|
|
4114
|
+
if (!payload) return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Spin, { description: "\u6B63\u5728\u8BFB\u53D6\u6587\u672C..." }) });
|
|
4115
|
+
return /* @__PURE__ */ jsxs("div", { style: { height: "100%", overflow: "auto", background: "#fff" }, children: [
|
|
4116
|
+
payload.truncated ? /* @__PURE__ */ jsx3(Alert, { type: "info", showIcon: true, banner: true, title: "\u6587\u4EF6\u8F83\u5927\uFF0C\u4EC5\u5C55\u793A\u524D\u90E8\u5185\u5BB9\u3002" }) : null,
|
|
4117
|
+
/* @__PURE__ */ jsx3(
|
|
4118
|
+
"pre",
|
|
4119
|
+
{
|
|
4120
|
+
style: {
|
|
4121
|
+
margin: 0,
|
|
4122
|
+
padding: 20,
|
|
4123
|
+
whiteSpace: "pre-wrap",
|
|
4124
|
+
wordBreak: "break-word",
|
|
4125
|
+
fontSize: 13,
|
|
4126
|
+
lineHeight: 1.7
|
|
4127
|
+
},
|
|
4128
|
+
children: payload.text || "\u6682\u65E0\u6587\u672C\u5185\u5BB9"
|
|
4129
|
+
}
|
|
4130
|
+
)
|
|
4131
|
+
] });
|
|
4132
|
+
};
|
|
4133
|
+
var DocxPreview = ({ request, url }) => {
|
|
4134
|
+
const containerRef = useRef2(null);
|
|
4135
|
+
const [loading, setLoading] = useState3(true);
|
|
4136
|
+
const [error, setError] = useState3("");
|
|
4137
|
+
useEffect3(() => {
|
|
4138
|
+
let disposed = false;
|
|
4139
|
+
const container = containerRef.current;
|
|
4140
|
+
if (!container || !url) return () => {
|
|
4141
|
+
disposed = true;
|
|
4142
|
+
};
|
|
4143
|
+
container.innerHTML = "";
|
|
4144
|
+
setLoading(true);
|
|
4145
|
+
setError("");
|
|
4146
|
+
(async () => {
|
|
4147
|
+
try {
|
|
4148
|
+
const blob = await loadPreviewBlob(request, url);
|
|
4149
|
+
const { renderAsync } = await import("docx-preview");
|
|
4150
|
+
if (disposed || !containerRef.current) return;
|
|
4151
|
+
await renderAsync(blob, containerRef.current, containerRef.current, {
|
|
4152
|
+
className: "sy-docx-preview",
|
|
4153
|
+
inWrapper: true,
|
|
4154
|
+
breakPages: true,
|
|
4155
|
+
ignoreLastRenderedPageBreak: false,
|
|
4156
|
+
renderHeaders: true,
|
|
4157
|
+
renderFooters: true,
|
|
4158
|
+
renderFootnotes: true,
|
|
4159
|
+
renderEndnotes: true,
|
|
4160
|
+
useBase64URL: false
|
|
4161
|
+
});
|
|
4162
|
+
} catch (currentError) {
|
|
4163
|
+
if (!disposed) setError(currentError?.message || "Word \u6587\u6863\u89E3\u6790\u5931\u8D25");
|
|
4164
|
+
} finally {
|
|
4165
|
+
if (!disposed) setLoading(false);
|
|
4166
|
+
}
|
|
4167
|
+
})();
|
|
4168
|
+
return () => {
|
|
4169
|
+
disposed = true;
|
|
4170
|
+
if (container) container.innerHTML = "";
|
|
4171
|
+
};
|
|
4172
|
+
}, [request, url]);
|
|
4173
|
+
return /* @__PURE__ */ jsxs(
|
|
4174
|
+
"div",
|
|
4175
|
+
{
|
|
4176
|
+
style: {
|
|
4177
|
+
minHeight: 360,
|
|
4178
|
+
height: "100%",
|
|
4179
|
+
overflow: "auto",
|
|
4180
|
+
position: "relative",
|
|
4181
|
+
background: "#e9edf2"
|
|
4182
|
+
},
|
|
4183
|
+
children: [
|
|
4184
|
+
loading ? /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Spin, { description: "\u6B63\u5728\u8FD8\u539F Word \u7248\u5F0F..." }) }) : null,
|
|
4185
|
+
error ? /* @__PURE__ */ jsx3("div", { style: { padding: 20 }, children: /* @__PURE__ */ jsx3(Alert, { type: "error", showIcon: true, title: error }) }) : null,
|
|
4186
|
+
/* @__PURE__ */ jsx3("div", { ref: containerRef, style: { display: loading || error ? "none" : "block" } })
|
|
4187
|
+
]
|
|
4188
|
+
}
|
|
4189
|
+
);
|
|
4190
|
+
};
|
|
4191
|
+
var HeicImagePreview = ({
|
|
4192
|
+
request,
|
|
4193
|
+
url,
|
|
4194
|
+
fileName
|
|
4195
|
+
}) => {
|
|
4196
|
+
const [src, setSrc] = useState3("");
|
|
4197
|
+
const [error, setError] = useState3("");
|
|
4198
|
+
useEffect3(() => {
|
|
4199
|
+
let disposed = false;
|
|
4200
|
+
let objectUrl = "";
|
|
4201
|
+
convertHeicPreview(request, url).then((result) => {
|
|
4202
|
+
objectUrl = result;
|
|
4203
|
+
if (!disposed) setSrc(result);
|
|
4204
|
+
}).catch((currentError) => {
|
|
4205
|
+
if (!disposed) setError(currentError?.message || "HEIC \u56FE\u7247\u8F6C\u6362\u5931\u8D25");
|
|
4206
|
+
});
|
|
4207
|
+
return () => {
|
|
4208
|
+
disposed = true;
|
|
4209
|
+
if (objectUrl) URL.revokeObjectURL?.(objectUrl);
|
|
4210
|
+
};
|
|
4211
|
+
}, [request, url]);
|
|
4212
|
+
if (error) return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Alert, { type: "error", showIcon: true, title: error }) });
|
|
4213
|
+
if (!src) return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Spin, { description: "\u6B63\u5728\u8F6C\u6362 HEIC \u56FE\u7247..." }) });
|
|
4214
|
+
return /* @__PURE__ */ jsx3("div", { style: { minHeight: 320, textAlign: "center", padding: 20, background: "#f3f5f7" }, children: /* @__PURE__ */ jsx3(
|
|
4215
|
+
Image2,
|
|
4216
|
+
{
|
|
4217
|
+
src,
|
|
4218
|
+
alt: fileName || "HEIC \u56FE\u7247\u9884\u89C8",
|
|
4219
|
+
style: { maxWidth: "100%", maxHeight: "72vh", objectFit: "contain" }
|
|
4220
|
+
}
|
|
4221
|
+
) });
|
|
4222
|
+
};
|
|
4223
|
+
var ClientSpreadsheetPreview = ({
|
|
4224
|
+
request,
|
|
4225
|
+
url
|
|
4226
|
+
}) => {
|
|
4227
|
+
const [payload, setPayload] = useState3(null);
|
|
4228
|
+
const [error, setError] = useState3("");
|
|
4229
|
+
useEffect3(() => {
|
|
4230
|
+
let disposed = false;
|
|
4231
|
+
(async () => {
|
|
4232
|
+
try {
|
|
4233
|
+
const blob = await loadPreviewBlob(request, url);
|
|
4234
|
+
const XLSX = await import("xlsx");
|
|
4235
|
+
const workbook = XLSX.read(await blob.arrayBuffer(), {
|
|
4236
|
+
cellDates: true,
|
|
4237
|
+
dense: true
|
|
4238
|
+
});
|
|
4239
|
+
const maxRows = 500;
|
|
4240
|
+
const maxColumns = 100;
|
|
4241
|
+
const sheets = workbook.SheetNames.map((name, index) => {
|
|
4242
|
+
const allRows = XLSX.utils.sheet_to_json(workbook.Sheets[name], {
|
|
4243
|
+
header: 1,
|
|
4244
|
+
defval: "",
|
|
4245
|
+
raw: false
|
|
4246
|
+
});
|
|
4247
|
+
const columnCount = allRows.reduce(
|
|
4248
|
+
(count, row) => Math.max(count, Array.isArray(row) ? row.length : 0),
|
|
4249
|
+
0
|
|
4250
|
+
);
|
|
4251
|
+
return {
|
|
4252
|
+
id: index,
|
|
4253
|
+
name,
|
|
4254
|
+
rows: allRows.slice(0, maxRows).map(
|
|
4255
|
+
(row) => (Array.isArray(row) ? row : []).slice(0, maxColumns)
|
|
4256
|
+
),
|
|
4257
|
+
truncatedRows: allRows.length > maxRows,
|
|
4258
|
+
truncatedColumns: columnCount > maxColumns
|
|
4259
|
+
};
|
|
4260
|
+
});
|
|
4261
|
+
if (!disposed) setPayload({ sheets, maxRows, maxColumns });
|
|
4262
|
+
} catch (currentError) {
|
|
4263
|
+
if (!disposed) setError(currentError?.message || "Excel \u6587\u4EF6\u89E3\u6790\u5931\u8D25");
|
|
4264
|
+
}
|
|
4265
|
+
})();
|
|
4266
|
+
return () => {
|
|
4267
|
+
disposed = true;
|
|
4268
|
+
};
|
|
4269
|
+
}, [request, url]);
|
|
4270
|
+
if (error) return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Alert, { type: "error", showIcon: true, title: error }) });
|
|
4271
|
+
if (!payload) return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Spin, { description: "\u6B63\u5728\u89E3\u6790\u5DE5\u4F5C\u7C3F..." }) });
|
|
4272
|
+
return /* @__PURE__ */ jsx3(PayloadPreviewFromValue, { payload });
|
|
4273
|
+
};
|
|
4274
|
+
var PayloadPreviewFromValue = ({ payload }) => {
|
|
4275
|
+
const sheets = Array.isArray(payload?.sheets) ? payload.sheets : [];
|
|
4276
|
+
if (!sheets.length) return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Empty, { description: "\u6682\u65E0\u53EF\u9884\u89C8\u7684\u5DE5\u4F5C\u8868" }) });
|
|
4277
|
+
return /* @__PURE__ */ jsx3(
|
|
4278
|
+
Tabs,
|
|
4279
|
+
{
|
|
4280
|
+
style: { height: "100%", padding: "0 16px" },
|
|
4281
|
+
items: sheets.map((sheet) => {
|
|
4282
|
+
const table = buildRowsTable(sheet.rows || []);
|
|
4283
|
+
return {
|
|
4284
|
+
key: String(sheet.id ?? sheet.name),
|
|
4285
|
+
label: sheet.name || "Sheet",
|
|
4286
|
+
children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
|
|
4287
|
+
sheet.truncatedRows || sheet.truncatedColumns ? /* @__PURE__ */ jsx3(
|
|
4288
|
+
Alert,
|
|
4289
|
+
{
|
|
4290
|
+
type: "info",
|
|
4291
|
+
showIcon: true,
|
|
4292
|
+
title: `\u5DE5\u4F5C\u8868\u8F83\u5927\uFF0C\u4EC5\u5C55\u793A\u524D ${payload.maxRows} \u884C\u3001${payload.maxColumns} \u5217\u3002`
|
|
4293
|
+
}
|
|
4294
|
+
) : null,
|
|
4295
|
+
/* @__PURE__ */ jsx3(
|
|
4296
|
+
Table,
|
|
4297
|
+
{
|
|
4298
|
+
bordered: true,
|
|
4299
|
+
size: "small",
|
|
4300
|
+
pagination: false,
|
|
4301
|
+
scroll: { x: "max-content", y: "min(66vh, 680px)" },
|
|
4302
|
+
columns: table.columns,
|
|
4303
|
+
dataSource: table.dataSource
|
|
4304
|
+
}
|
|
4305
|
+
)
|
|
4306
|
+
] })
|
|
4307
|
+
};
|
|
4308
|
+
})
|
|
4309
|
+
}
|
|
4310
|
+
);
|
|
4311
|
+
};
|
|
4312
|
+
var scriptPromises = /* @__PURE__ */ new Map();
|
|
4313
|
+
var loadScriptOnce = (src) => {
|
|
4314
|
+
const existingPromise = scriptPromises.get(src);
|
|
4315
|
+
if (existingPromise) return existingPromise;
|
|
4316
|
+
const promise = new Promise((resolve, reject) => {
|
|
4317
|
+
if (!src || typeof document === "undefined") {
|
|
4318
|
+
reject(new Error("ONLYOFFICE \u811A\u672C\u5730\u5740\u4E0D\u53EF\u7528"));
|
|
4319
|
+
return;
|
|
4320
|
+
}
|
|
4321
|
+
const existed = document.querySelector(`script[src="${src}"]`);
|
|
4322
|
+
if (existed?.dataset.loaded === "true") {
|
|
4323
|
+
resolve();
|
|
4324
|
+
return;
|
|
4325
|
+
}
|
|
4326
|
+
const script = existed || document.createElement("script");
|
|
4327
|
+
script.src = src;
|
|
4328
|
+
script.async = true;
|
|
4329
|
+
script.onload = () => {
|
|
4330
|
+
script.dataset.loaded = "true";
|
|
4331
|
+
resolve();
|
|
4332
|
+
};
|
|
4333
|
+
script.onerror = () => reject(new Error("ONLYOFFICE \u811A\u672C\u52A0\u8F7D\u5931\u8D25"));
|
|
4334
|
+
if (!existed) document.body.appendChild(script);
|
|
4335
|
+
});
|
|
4336
|
+
scriptPromises.set(src, promise);
|
|
4337
|
+
promise.catch(() => scriptPromises.delete(src));
|
|
4338
|
+
return promise;
|
|
4339
|
+
};
|
|
4340
|
+
var OnlyOfficePreview = ({
|
|
4341
|
+
request,
|
|
4342
|
+
configUrl,
|
|
4343
|
+
ticket
|
|
4344
|
+
}) => {
|
|
4345
|
+
const editorId = useMemo4(
|
|
4346
|
+
() => `openxiangda-onlyoffice-${String(ticket || "editor").replace(/[^a-zA-Z0-9_-]/g, "")}`,
|
|
4347
|
+
[ticket]
|
|
4348
|
+
);
|
|
4349
|
+
const [loading, setLoading] = useState3(true);
|
|
4350
|
+
const [error, setError] = useState3("");
|
|
4351
|
+
useEffect3(() => {
|
|
4352
|
+
let disposed = false;
|
|
4353
|
+
let editor;
|
|
4354
|
+
setLoading(true);
|
|
4355
|
+
setError("");
|
|
4356
|
+
(async () => {
|
|
4357
|
+
try {
|
|
4358
|
+
const response = await request({ url: configUrl, method: "get" });
|
|
4359
|
+
const payload = unwrapFilePreviewPayload(response);
|
|
4360
|
+
const scriptUrl = `${String(payload?.documentServerUrl || "").replace(
|
|
4361
|
+
/\/+$/,
|
|
4362
|
+
""
|
|
4363
|
+
)}/web-apps/apps/api/documents/api.js`;
|
|
4364
|
+
await loadScriptOnce(scriptUrl);
|
|
4365
|
+
if (!disposed && window.DocsAPI?.DocEditor) {
|
|
4366
|
+
editor = new window.DocsAPI.DocEditor(editorId, payload.config);
|
|
4367
|
+
}
|
|
4368
|
+
} catch (currentError) {
|
|
4369
|
+
if (!disposed) setError(currentError?.message || "ONLYOFFICE \u9884\u89C8\u52A0\u8F7D\u5931\u8D25");
|
|
4370
|
+
} finally {
|
|
4371
|
+
if (!disposed) setLoading(false);
|
|
4372
|
+
}
|
|
4373
|
+
})();
|
|
4374
|
+
return () => {
|
|
4375
|
+
disposed = true;
|
|
4376
|
+
editor?.destroyEditor?.();
|
|
4377
|
+
};
|
|
4378
|
+
}, [configUrl, editorId, request]);
|
|
4379
|
+
return /* @__PURE__ */ jsxs("div", { style: { height: "100%", minHeight: 420, position: "relative", background: "#fff" }, children: [
|
|
4380
|
+
loading ? /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(Spin, { description: "\u6B63\u5728\u52A0\u8F7D ONLYOFFICE..." }) }) : null,
|
|
4381
|
+
error ? /* @__PURE__ */ jsx3("div", { style: { padding: 20 }, children: /* @__PURE__ */ jsx3(Alert, { type: "error", showIcon: true, title: error }) }) : null,
|
|
4382
|
+
/* @__PURE__ */ jsx3("div", { id: editorId, style: { height: "100%", minHeight: 420, display: error ? "none" : "block" } })
|
|
4383
|
+
] });
|
|
4384
|
+
};
|
|
4385
|
+
var FilePreviewContent = ({
|
|
4386
|
+
metadata,
|
|
4387
|
+
request,
|
|
4388
|
+
servicePrefix = "/service",
|
|
4389
|
+
onDownload
|
|
4390
|
+
}) => {
|
|
4391
|
+
const renderMode = metadata.renderMode || "download";
|
|
4392
|
+
const previewUrl = resolvePreviewServiceUrl(metadata.previewUrl, servicePrefix);
|
|
4393
|
+
const imageUrl = resolvePreviewServiceUrl(
|
|
4394
|
+
renderMode === "image-transcode" ? metadata.imagePreviewUrl : metadata.previewUrl,
|
|
4395
|
+
servicePrefix
|
|
4396
|
+
);
|
|
4397
|
+
if (renderMode === "inline" && metadata.previewType === "image") {
|
|
4398
|
+
return /* @__PURE__ */ jsx3(
|
|
4399
|
+
"div",
|
|
4400
|
+
{
|
|
4401
|
+
style: {
|
|
4402
|
+
height: "100%",
|
|
4403
|
+
minHeight: 320,
|
|
4404
|
+
display: "flex",
|
|
4405
|
+
alignItems: "center",
|
|
4406
|
+
justifyContent: "center",
|
|
4407
|
+
overflow: "auto",
|
|
4408
|
+
padding: 20,
|
|
4409
|
+
background: "#f3f5f7"
|
|
4410
|
+
},
|
|
4411
|
+
children: /* @__PURE__ */ jsx3(
|
|
4412
|
+
Image2,
|
|
4413
|
+
{
|
|
4414
|
+
src: imageUrl,
|
|
4415
|
+
alt: metadata.fileName || "\u56FE\u7247\u9884\u89C8",
|
|
4416
|
+
style: { maxWidth: "100%", maxHeight: "72vh", objectFit: "contain" }
|
|
4417
|
+
}
|
|
4418
|
+
)
|
|
4419
|
+
}
|
|
4420
|
+
);
|
|
4421
|
+
}
|
|
4422
|
+
if (renderMode === "image-transcode") {
|
|
4423
|
+
return /* @__PURE__ */ jsx3("div", { style: { minHeight: 320, textAlign: "center", padding: 20, background: "#f3f5f7" }, children: /* @__PURE__ */ jsx3(
|
|
4424
|
+
Image2,
|
|
4425
|
+
{
|
|
4426
|
+
src: imageUrl,
|
|
4427
|
+
alt: metadata.fileName || "\u56FE\u7247\u9884\u89C8",
|
|
4428
|
+
style: { maxWidth: "100%", maxHeight: "72vh", objectFit: "contain" }
|
|
4429
|
+
}
|
|
4430
|
+
) });
|
|
4431
|
+
}
|
|
4432
|
+
if (renderMode === "image-heic") {
|
|
4433
|
+
return /* @__PURE__ */ jsx3(
|
|
4434
|
+
HeicImagePreview,
|
|
4435
|
+
{
|
|
4436
|
+
request,
|
|
4437
|
+
url: previewUrl,
|
|
4438
|
+
fileName: metadata.fileName
|
|
4439
|
+
}
|
|
4440
|
+
);
|
|
4441
|
+
}
|
|
4442
|
+
if (renderMode === "inline" && metadata.previewType === "video") {
|
|
4443
|
+
return /* @__PURE__ */ jsx3(
|
|
4444
|
+
"div",
|
|
4445
|
+
{
|
|
4446
|
+
style: {
|
|
4447
|
+
height: "100%",
|
|
4448
|
+
minHeight: 320,
|
|
4449
|
+
display: "flex",
|
|
4450
|
+
alignItems: "center",
|
|
4451
|
+
background: "#080a0d"
|
|
4452
|
+
},
|
|
4453
|
+
children: /* @__PURE__ */ jsx3(
|
|
4454
|
+
"video",
|
|
4455
|
+
{
|
|
4456
|
+
controls: true,
|
|
4457
|
+
playsInline: true,
|
|
4458
|
+
preload: "metadata",
|
|
4459
|
+
src: previewUrl,
|
|
4460
|
+
style: { width: "100%", maxHeight: "76vh" },
|
|
4461
|
+
children: "\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u89C6\u9891\u64AD\u653E\u3002"
|
|
4462
|
+
}
|
|
4463
|
+
)
|
|
4464
|
+
}
|
|
4465
|
+
);
|
|
4466
|
+
}
|
|
4467
|
+
if (renderMode === "inline" && metadata.previewType === "audio") {
|
|
4468
|
+
return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3("audio", { controls: true, preload: "metadata", src: previewUrl, style: { width: "min(680px, 100%)" }, children: "\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u97F3\u9891\u64AD\u653E\u3002" }) });
|
|
4469
|
+
}
|
|
4470
|
+
if (renderMode === "pdfjs") {
|
|
4471
|
+
return /* @__PURE__ */ jsx3(
|
|
4472
|
+
"iframe",
|
|
4473
|
+
{
|
|
4474
|
+
title: metadata.fileName || "PDF \u9884\u89C8",
|
|
4475
|
+
src: previewUrl,
|
|
4476
|
+
style: { width: "100%", height: "100%", minHeight: 520, border: 0, background: "#fff" }
|
|
4477
|
+
}
|
|
4478
|
+
);
|
|
4479
|
+
}
|
|
4480
|
+
if (renderMode === "docx-html") {
|
|
4481
|
+
return /* @__PURE__ */ jsx3(DocxPreview, { request, url: previewUrl });
|
|
4482
|
+
}
|
|
4483
|
+
if (renderMode === "excel-client") {
|
|
4484
|
+
return /* @__PURE__ */ jsx3(ClientSpreadsheetPreview, { request, url: previewUrl });
|
|
4485
|
+
}
|
|
4486
|
+
if (renderMode === "excel-basic") {
|
|
4487
|
+
return /* @__PURE__ */ jsx3(
|
|
4488
|
+
PayloadPreview,
|
|
4489
|
+
{
|
|
4490
|
+
request,
|
|
4491
|
+
url: metadata.excelPreviewUrl || "",
|
|
4492
|
+
mode: "excel"
|
|
4493
|
+
}
|
|
4494
|
+
);
|
|
4495
|
+
}
|
|
4496
|
+
if (renderMode === "text-client") {
|
|
4497
|
+
return /* @__PURE__ */ jsx3(ClientTextPreview, { request, url: previewUrl });
|
|
4498
|
+
}
|
|
4499
|
+
if (renderMode === "text" || renderMode === "office-text") {
|
|
4500
|
+
return /* @__PURE__ */ jsx3(
|
|
4501
|
+
PayloadPreview,
|
|
4502
|
+
{
|
|
4503
|
+
request,
|
|
4504
|
+
url: renderMode === "office-text" ? metadata.officeTextPreviewUrl || "" : metadata.textPreviewUrl || "",
|
|
4505
|
+
mode: "text"
|
|
4506
|
+
}
|
|
4507
|
+
);
|
|
4508
|
+
}
|
|
4509
|
+
if (renderMode === "onlyoffice") {
|
|
4510
|
+
return /* @__PURE__ */ jsx3(
|
|
4511
|
+
OnlyOfficePreview,
|
|
4512
|
+
{
|
|
4513
|
+
request,
|
|
4514
|
+
configUrl: metadata.onlyofficeConfigUrl || `/file/onlyoffice/config/${encodeURIComponent(metadata.ticket || "")}`,
|
|
4515
|
+
ticket: metadata.ticket
|
|
4516
|
+
}
|
|
4517
|
+
);
|
|
4518
|
+
}
|
|
4519
|
+
return /* @__PURE__ */ jsx3(CenteredState, { children: /* @__PURE__ */ jsx3(
|
|
4520
|
+
Empty,
|
|
4521
|
+
{
|
|
4522
|
+
image: /* @__PURE__ */ jsx3(FileOutlined, { style: { fontSize: 52, color: "#8c8c8c" } }),
|
|
4523
|
+
description: /* @__PURE__ */ jsxs("div", { children: [
|
|
4524
|
+
/* @__PURE__ */ jsx3(Typography.Text, { strong: true, children: "\u5F53\u524D\u6587\u4EF6\u65E0\u6CD5\u5728\u7EBF\u9884\u89C8" }),
|
|
4525
|
+
/* @__PURE__ */ jsx3("br", {}),
|
|
4526
|
+
/* @__PURE__ */ jsx3(Typography.Text, { type: "secondary", children: metadata.unsupportedReason || "\u8BF7\u4E0B\u8F7D\u540E\u4F7F\u7528\u672C\u5730\u5E94\u7528\u6253\u5F00\u3002" })
|
|
4527
|
+
] }),
|
|
4528
|
+
children: onDownload ? /* @__PURE__ */ jsx3(Button, { type: "primary", icon: /* @__PURE__ */ jsx3(DownloadOutlined, {}), onClick: onDownload, children: "\u4E0B\u8F7D\u6587\u4EF6" }) : null
|
|
4529
|
+
}
|
|
4530
|
+
) });
|
|
4531
|
+
};
|
|
4532
|
+
|
|
4533
|
+
// packages/sdk/src/components/file-preview/FilePreviewPage.tsx
|
|
4534
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useState as useState4 } from "react";
|
|
4535
|
+
import { Alert as Alert2, Button as Button2, Empty as Empty2, Spin as Spin2, Tag, Tooltip, Typography as Typography2 } from "antd";
|
|
4536
|
+
import {
|
|
4537
|
+
ArrowLeftOutlined,
|
|
4538
|
+
DownloadOutlined as DownloadOutlined2,
|
|
4539
|
+
FileOutlined as FileOutlined2,
|
|
4540
|
+
ReloadOutlined as ReloadOutlined2
|
|
4541
|
+
} from "@ant-design/icons";
|
|
4542
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
4543
|
+
|
|
4544
|
+
// packages/sdk/src/components/file-preview/useFilePreview.tsx
|
|
4545
|
+
import { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo5, useState as useState5 } from "react";
|
|
4546
|
+
import { Alert as Alert3, Button as Button3, Image as Image3, Modal, Spin as Spin3, Typography as Typography3 } from "antd";
|
|
4547
|
+
import { CloseOutlined, DownloadOutlined as DownloadOutlined3 } from "@ant-design/icons";
|
|
4548
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
4549
|
+
var canActOnItem = (item) => item.status !== "uploading" && item.status !== "error";
|
|
4550
|
+
var revokeImageItems = (items) => {
|
|
4551
|
+
items.forEach((item) => {
|
|
4552
|
+
if (item.revokeOnClose && item.src.startsWith("blob:")) {
|
|
4553
|
+
URL.revokeObjectURL?.(item.src);
|
|
4554
|
+
}
|
|
4555
|
+
});
|
|
4556
|
+
};
|
|
4557
|
+
var buildCapabilityMap = (items, requireServerCapability) => {
|
|
4558
|
+
const result = {};
|
|
4559
|
+
items.forEach((item, index) => {
|
|
4560
|
+
const key = getPreviewItemKey(item, index);
|
|
4561
|
+
const local = resolveLocalPreviewCapability(item);
|
|
4562
|
+
result[key] = requireServerCapability && item.objectName && !isDirectStorageItem(item) ? { ...local, canPreview: false } : local;
|
|
4563
|
+
});
|
|
4564
|
+
return result;
|
|
4565
|
+
};
|
|
4566
|
+
var useFilePreviewController = ({
|
|
4567
|
+
items,
|
|
4568
|
+
api,
|
|
4569
|
+
appType,
|
|
4570
|
+
bucketName,
|
|
4571
|
+
enabled = true,
|
|
4572
|
+
requireServerCapability = true
|
|
4573
|
+
}) => {
|
|
4574
|
+
const itemSignature = useMemo5(
|
|
4575
|
+
() => items.map(
|
|
4576
|
+
(item, index) => [
|
|
4577
|
+
getPreviewItemKey(item, index),
|
|
4578
|
+
item.name,
|
|
4579
|
+
item.objectName,
|
|
4580
|
+
item.contentType,
|
|
4581
|
+
item.size,
|
|
4582
|
+
item.status
|
|
4583
|
+
].join(":")
|
|
4584
|
+
).join("|"),
|
|
4585
|
+
[items]
|
|
4586
|
+
);
|
|
4587
|
+
const [capabilities, setCapabilities] = useState5(
|
|
4588
|
+
() => buildCapabilityMap(items, requireServerCapability)
|
|
4589
|
+
);
|
|
4590
|
+
const [openingKey, setOpeningKey] = useState5("");
|
|
4591
|
+
const [dialogPreview, setDialogPreview] = useState5(null);
|
|
4592
|
+
const [imagePreview, setImagePreview] = useState5({
|
|
4593
|
+
open: false,
|
|
4594
|
+
current: 0,
|
|
4595
|
+
items: []
|
|
4596
|
+
});
|
|
4597
|
+
useEffect5(() => {
|
|
4598
|
+
let disposed = false;
|
|
4599
|
+
const initial = buildCapabilityMap(items, requireServerCapability);
|
|
4600
|
+
setCapabilities(initial);
|
|
4601
|
+
if (!enabled || !requireServerCapability) return () => {
|
|
4602
|
+
disposed = true;
|
|
4603
|
+
};
|
|
4604
|
+
const protectedItems = items.map((item, index) => ({ item, key: getPreviewItemKey(item, index) })).filter(
|
|
4605
|
+
({ item }) => canActOnItem(item) && Boolean(item.objectName) && !isDirectStorageItem(item)
|
|
4606
|
+
);
|
|
4607
|
+
if (!protectedItems.length) return () => {
|
|
4608
|
+
disposed = true;
|
|
4609
|
+
};
|
|
4610
|
+
api.request({
|
|
4611
|
+
url: "/file/preview-capabilities",
|
|
4612
|
+
method: "post",
|
|
4613
|
+
data: {
|
|
4614
|
+
files: protectedItems.map(({ item, key }) => ({
|
|
4615
|
+
key,
|
|
4616
|
+
fileName: item.name,
|
|
4617
|
+
objectName: item.objectName,
|
|
4618
|
+
contentType: item.contentType || item.mimeType,
|
|
4619
|
+
size: item.size
|
|
4620
|
+
}))
|
|
4621
|
+
}
|
|
4622
|
+
}).then((response) => {
|
|
4623
|
+
if (disposed) return;
|
|
4624
|
+
const payload = unwrapFilePreviewPayload(response);
|
|
4625
|
+
const next = { ...initial };
|
|
4626
|
+
(payload?.items || []).forEach((capability) => {
|
|
4627
|
+
if (capability.key) next[capability.key] = capability;
|
|
4628
|
+
});
|
|
4629
|
+
setCapabilities(next);
|
|
4630
|
+
}).catch(() => {
|
|
4631
|
+
if (disposed) return;
|
|
4632
|
+
const fallback = { ...initial };
|
|
4633
|
+
protectedItems.forEach(({ item, key }) => {
|
|
4634
|
+
fallback[key] = resolveLocalPreviewCapability(item);
|
|
4635
|
+
});
|
|
4636
|
+
setCapabilities(fallback);
|
|
4637
|
+
});
|
|
4638
|
+
return () => {
|
|
4639
|
+
disposed = true;
|
|
4640
|
+
};
|
|
4641
|
+
}, [api, enabled, itemSignature, requireServerCapability]);
|
|
4642
|
+
const getCapability = useCallback4(
|
|
4643
|
+
(item) => {
|
|
4644
|
+
const index = items.indexOf(item);
|
|
4645
|
+
return capabilities[getPreviewItemKey(item, Math.max(index, 0))];
|
|
4646
|
+
},
|
|
4647
|
+
[capabilities, items]
|
|
4648
|
+
);
|
|
4649
|
+
const canPreview = useCallback4(
|
|
4650
|
+
(item) => enabled && canActOnItem(item) && getCapability(item)?.canPreview === true,
|
|
4651
|
+
[enabled, getCapability]
|
|
4652
|
+
);
|
|
4653
|
+
const closeImagePreview = useCallback4(() => {
|
|
4654
|
+
setImagePreview((current) => {
|
|
4655
|
+
revokeImageItems(current.items);
|
|
4656
|
+
return { open: false, current: 0, items: [] };
|
|
4657
|
+
});
|
|
4658
|
+
}, []);
|
|
4659
|
+
useEffect5(
|
|
4660
|
+
() => () => revokeImageItems(imagePreview.items),
|
|
4661
|
+
[imagePreview.items]
|
|
4662
|
+
);
|
|
4663
|
+
const resolvePreparedImageItem = useCallback4(
|
|
4664
|
+
async (prepared, index) => {
|
|
4665
|
+
const item = prepared.item;
|
|
4666
|
+
const metadata = prepared.metadata;
|
|
4667
|
+
let src = resolvePreviewServiceUrl(
|
|
4668
|
+
metadata.renderMode === "image-transcode" ? metadata.imagePreviewUrl : metadata.previewUrl
|
|
4669
|
+
);
|
|
4670
|
+
let revokeOnClose = false;
|
|
4671
|
+
if (metadata.renderMode === "image-heic") {
|
|
4672
|
+
src = await convertHeicPreview(api.request, src);
|
|
4673
|
+
revokeOnClose = true;
|
|
4674
|
+
}
|
|
4675
|
+
if (!src) throw new Error(`${item.name || "\u56FE\u7247"}\u6CA1\u6709\u53EF\u7528\u7684\u9884\u89C8\u5730\u5740`);
|
|
4676
|
+
return {
|
|
4677
|
+
key: getPreviewItemKey(item, index),
|
|
4678
|
+
src,
|
|
4679
|
+
name: metadata.fileName || item.name,
|
|
4680
|
+
revokeOnClose
|
|
4681
|
+
};
|
|
4682
|
+
},
|
|
4683
|
+
[api]
|
|
4684
|
+
);
|
|
4685
|
+
const prepareImageItem = useCallback4(
|
|
4686
|
+
async (item, index) => {
|
|
4687
|
+
const prepared = await prepareFilePreview({ item, api, appType, bucketName });
|
|
4688
|
+
return resolvePreparedImageItem(prepared, index);
|
|
4689
|
+
},
|
|
4690
|
+
[api, appType, bucketName, resolvePreparedImageItem]
|
|
4691
|
+
);
|
|
4692
|
+
const openPreview = useCallback4(
|
|
4693
|
+
async (item) => {
|
|
4694
|
+
const itemIndex = Math.max(items.indexOf(item), 0);
|
|
4695
|
+
const key = getPreviewItemKey(item, itemIndex);
|
|
4696
|
+
setOpeningKey(key);
|
|
4697
|
+
try {
|
|
4698
|
+
const prepared = await prepareFilePreview({ item, api, appType, bucketName });
|
|
4699
|
+
if (prepared.metadata.canPreview === false || prepared.metadata.renderMode === "download") {
|
|
4700
|
+
setDialogPreview(prepared);
|
|
4701
|
+
return;
|
|
4702
|
+
}
|
|
4703
|
+
if (prepared.metadata.previewType === "image") {
|
|
4704
|
+
const galleryCandidates = items.map((candidate, index) => ({ candidate, index })).filter(({ candidate }) => {
|
|
4705
|
+
const capability = getCapability(candidate) || resolveLocalPreviewCapability(candidate);
|
|
4706
|
+
return canActOnItem(candidate) && capability.canPreview && capability.previewType === "image";
|
|
4707
|
+
});
|
|
4708
|
+
const results = await Promise.allSettled(
|
|
4709
|
+
galleryCandidates.map(
|
|
4710
|
+
({ candidate, index }) => candidate === item ? resolvePreparedImageItem(prepared, index) : prepareImageItem(candidate, index)
|
|
4711
|
+
)
|
|
4712
|
+
);
|
|
4713
|
+
const gallery = results.flatMap(
|
|
4714
|
+
(result) => result.status === "fulfilled" ? [result.value] : []
|
|
4715
|
+
);
|
|
4716
|
+
if (!gallery.length || !gallery.some((image) => image.key === key)) {
|
|
4717
|
+
const fallback = await resolvePreparedImageItem(prepared, itemIndex);
|
|
4718
|
+
gallery.push(fallback);
|
|
4719
|
+
}
|
|
4720
|
+
const current = Math.max(0, gallery.findIndex((image) => image.key === key));
|
|
4721
|
+
closeImagePreview();
|
|
4722
|
+
setImagePreview({ open: true, current, items: gallery });
|
|
4723
|
+
return;
|
|
4724
|
+
}
|
|
4725
|
+
setDialogPreview(prepared);
|
|
4726
|
+
} catch (error) {
|
|
4727
|
+
setDialogPreview({
|
|
4728
|
+
item,
|
|
4729
|
+
direct: isDirectStorageItem(item),
|
|
4730
|
+
metadata: {
|
|
4731
|
+
...resolveLocalPreviewCapability(item),
|
|
4732
|
+
fileName: item.name,
|
|
4733
|
+
size: item.size,
|
|
4734
|
+
renderMode: "download",
|
|
4735
|
+
canPreview: false,
|
|
4736
|
+
unsupportedReason: error?.message || "\u6587\u4EF6\u9884\u89C8\u52A0\u8F7D\u5931\u8D25",
|
|
4737
|
+
downloadUrl: item.downloadUrl || item.publicUrl || item.url
|
|
4738
|
+
}
|
|
4739
|
+
});
|
|
4740
|
+
} finally {
|
|
4741
|
+
setOpeningKey("");
|
|
4742
|
+
}
|
|
4743
|
+
},
|
|
4744
|
+
[
|
|
4745
|
+
api,
|
|
4746
|
+
appType,
|
|
4747
|
+
bucketName,
|
|
4748
|
+
closeImagePreview,
|
|
4749
|
+
getCapability,
|
|
4750
|
+
items,
|
|
4751
|
+
prepareImageItem,
|
|
4752
|
+
resolvePreparedImageItem
|
|
4753
|
+
]
|
|
4754
|
+
);
|
|
4755
|
+
const downloadItem = useCallback4(
|
|
4756
|
+
async (item, prepared) => {
|
|
4757
|
+
let url = prepared?.metadata.downloadUrl || item.downloadUrl || item.publicUrl || item.url;
|
|
4758
|
+
if (!isDirectStorageItem(item) && item.objectName && !prepared?.metadata.downloadUrl) {
|
|
4759
|
+
const ticket = await api.createDownloadTicket(
|
|
4760
|
+
item.bucketName || bucketName,
|
|
4761
|
+
item.objectName,
|
|
4762
|
+
item.name
|
|
4763
|
+
);
|
|
4764
|
+
url = typeof ticket === "string" ? ticket : ticket?.downloadUrl || ticket?.relayUrl || ticket?.url || url;
|
|
4765
|
+
}
|
|
4766
|
+
if (url && typeof window !== "undefined") window.location.assign(url);
|
|
4767
|
+
},
|
|
4768
|
+
[api, bucketName]
|
|
4769
|
+
);
|
|
4770
|
+
const previewHost = imagePreview.open || dialogPreview ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
4771
|
+
/* @__PURE__ */ jsx5(
|
|
4772
|
+
Image3.PreviewGroup,
|
|
4773
|
+
{
|
|
4774
|
+
items: imagePreview.items.map((item) => ({ src: item.src, alt: item.name })),
|
|
4775
|
+
preview: {
|
|
4776
|
+
open: imagePreview.open,
|
|
4777
|
+
current: imagePreview.current,
|
|
4778
|
+
onChange: (current) => setImagePreview((value) => ({ ...value, current })),
|
|
4779
|
+
onOpenChange: (open) => {
|
|
4780
|
+
if (!open) closeImagePreview();
|
|
4781
|
+
},
|
|
4782
|
+
countRender: (current, total) => `${current}/${total}`
|
|
4783
|
+
},
|
|
4784
|
+
children: /* @__PURE__ */ jsx5("span", { "aria-hidden": "true", style: { display: "none" } })
|
|
4785
|
+
}
|
|
4786
|
+
),
|
|
4787
|
+
/* @__PURE__ */ jsx5(
|
|
4788
|
+
FilePreviewDialog,
|
|
4789
|
+
{
|
|
4790
|
+
preview: dialogPreview,
|
|
4791
|
+
request: api.request,
|
|
4792
|
+
onClose: () => setDialogPreview(null),
|
|
4793
|
+
onDownload: () => {
|
|
4794
|
+
if (dialogPreview) void downloadItem(dialogPreview.item, dialogPreview);
|
|
4795
|
+
}
|
|
4796
|
+
}
|
|
4797
|
+
)
|
|
4798
|
+
] }) : null;
|
|
4799
|
+
return {
|
|
4800
|
+
canPreview,
|
|
4801
|
+
getCapability,
|
|
4802
|
+
openPreview,
|
|
4803
|
+
openingKey,
|
|
4804
|
+
isOpening: (item) => {
|
|
4805
|
+
const index = Math.max(items.indexOf(item), 0);
|
|
4806
|
+
return openingKey === getPreviewItemKey(item, index);
|
|
4807
|
+
},
|
|
4808
|
+
downloadItem,
|
|
4809
|
+
previewHost
|
|
4810
|
+
};
|
|
4811
|
+
};
|
|
4812
|
+
var FilePreviewDialog = ({
|
|
4813
|
+
preview,
|
|
4814
|
+
request,
|
|
4815
|
+
onClose,
|
|
4816
|
+
onDownload
|
|
4817
|
+
}) => {
|
|
4818
|
+
const metadata = preview?.metadata;
|
|
4819
|
+
const title = metadata?.fileName || preview?.item.name || "\u9644\u4EF6\u9884\u89C8";
|
|
4820
|
+
return /* @__PURE__ */ jsx5(
|
|
4821
|
+
Modal,
|
|
4822
|
+
{
|
|
4823
|
+
open: Boolean(preview),
|
|
4824
|
+
title: /* @__PURE__ */ jsxs3("div", { style: { minWidth: 0, paddingRight: 16 }, children: [
|
|
4825
|
+
/* @__PURE__ */ jsx5(Typography3.Text, { strong: true, ellipsis: true, style: { display: "block" }, children: title }),
|
|
4826
|
+
metadata ? /* @__PURE__ */ jsxs3(Typography3.Text, { type: "secondary", style: { fontSize: 12 }, children: [
|
|
4827
|
+
(metadata.extension || "FILE").toUpperCase(),
|
|
4828
|
+
" \xB7 ",
|
|
4829
|
+
formatPreviewFileSize(metadata.size)
|
|
4830
|
+
] }) : null
|
|
4831
|
+
] }),
|
|
4832
|
+
width: "min(96vw, 1440px)",
|
|
4833
|
+
centered: true,
|
|
4834
|
+
destroyOnHidden: true,
|
|
4835
|
+
mask: { closable: false },
|
|
4836
|
+
closeIcon: /* @__PURE__ */ jsx5(CloseOutlined, {}),
|
|
4837
|
+
onCancel: onClose,
|
|
4838
|
+
styles: {
|
|
4839
|
+
body: {
|
|
4840
|
+
height: "min(78vh, 900px)",
|
|
4841
|
+
minHeight: 360,
|
|
4842
|
+
padding: 0,
|
|
4843
|
+
overflow: "hidden",
|
|
4844
|
+
border: "1px solid #e5e7eb"
|
|
4845
|
+
}
|
|
4846
|
+
},
|
|
4847
|
+
footer: /* @__PURE__ */ jsxs3("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8 }, children: [
|
|
4848
|
+
/* @__PURE__ */ jsx5(Button3, { onClick: onClose, children: "\u5173\u95ED" }),
|
|
4849
|
+
metadata?.canDownload !== false ? /* @__PURE__ */ jsx5(Button3, { type: "primary", icon: /* @__PURE__ */ jsx5(DownloadOutlined3, {}), onClick: onDownload, children: "\u4E0B\u8F7D" }) : null
|
|
4850
|
+
] }),
|
|
4851
|
+
children: preview && metadata ? /* @__PURE__ */ jsx5(
|
|
4852
|
+
FilePreviewContent,
|
|
4853
|
+
{
|
|
4854
|
+
metadata,
|
|
4855
|
+
request,
|
|
4856
|
+
onDownload
|
|
4857
|
+
}
|
|
4858
|
+
) : /* @__PURE__ */ jsx5("div", { style: { height: "100%", display: "grid", placeItems: "center" }, children: /* @__PURE__ */ jsx5(Spin3, { description: "\u6B63\u5728\u51C6\u5907\u9884\u89C8..." }) })
|
|
4859
|
+
}
|
|
4860
|
+
);
|
|
4861
|
+
};
|
|
4862
|
+
|
|
4863
|
+
// packages/sdk/src/components/fields/shared/FileDisplay.tsx
|
|
4864
|
+
import {
|
|
4865
|
+
AudioOutlined,
|
|
4866
|
+
CloseOutlined as CloseOutlined2,
|
|
4867
|
+
DownloadOutlined as DownloadOutlined4,
|
|
4868
|
+
EyeOutlined,
|
|
4869
|
+
FileExcelOutlined,
|
|
4870
|
+
FileImageOutlined,
|
|
4871
|
+
FileOutlined as FileOutlined3,
|
|
4872
|
+
FilePdfOutlined,
|
|
4873
|
+
FilePptOutlined,
|
|
4874
|
+
FileTextOutlined,
|
|
4875
|
+
FileUnknownOutlined,
|
|
4876
|
+
FileWordOutlined,
|
|
4877
|
+
FileZipOutlined,
|
|
4878
|
+
PaperClipOutlined,
|
|
4879
|
+
PlusOutlined,
|
|
4880
|
+
UploadOutlined,
|
|
4881
|
+
VideoCameraOutlined
|
|
4882
|
+
} from "@ant-design/icons";
|
|
4883
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
4884
|
+
function FileTypeIcon({
|
|
4885
|
+
item,
|
|
4886
|
+
className
|
|
4887
|
+
}) {
|
|
4888
|
+
const category = getFileCategory(item.name, item.contentType);
|
|
4889
|
+
const extension = getFileExtension(item.name);
|
|
4890
|
+
const icon = category === "image" ? /* @__PURE__ */ jsx6(FileImageOutlined, {}) : category === "video" ? /* @__PURE__ */ jsx6(VideoCameraOutlined, {}) : category === "audio" ? /* @__PURE__ */ jsx6(AudioOutlined, {}) : category === "pdf" ? /* @__PURE__ */ jsx6(FilePdfOutlined, {}) : category === "excel" ? /* @__PURE__ */ jsx6(FileExcelOutlined, {}) : category === "word" ? /* @__PURE__ */ jsx6(FileWordOutlined, {}) : category === "ppt" ? /* @__PURE__ */ jsx6(FilePptOutlined, {}) : category === "archive" ? /* @__PURE__ */ jsx6(FileZipOutlined, {}) : category === "text" || category === "code" ? /* @__PURE__ */ jsx6(FileTextOutlined, {}) : extension ? /* @__PURE__ */ jsx6(FileOutlined3, {}) : /* @__PURE__ */ jsx6(FileUnknownOutlined, {});
|
|
4891
|
+
return /* @__PURE__ */ jsxs4("span", { className: `sy-file-icon sy-file-icon-${category} ${className || ""}`, "aria-hidden": "true", children: [
|
|
4892
|
+
icon,
|
|
4893
|
+
category !== "image" && extension ? /* @__PURE__ */ jsx6("span", { children: extension.toUpperCase() }) : null
|
|
4894
|
+
] });
|
|
4895
|
+
}
|
|
4896
|
+
function FileActionButton({
|
|
4897
|
+
type,
|
|
4898
|
+
disabled,
|
|
4899
|
+
onClick,
|
|
4900
|
+
testId
|
|
4901
|
+
}) {
|
|
4902
|
+
const label = type === "preview" ? "\u9884\u89C8" : type === "download" ? "\u4E0B\u8F7D" : "\u5220\u9664";
|
|
4903
|
+
const icon = type === "preview" ? /* @__PURE__ */ jsx6(EyeOutlined, {}) : type === "download" ? /* @__PURE__ */ jsx6(DownloadOutlined4, {}) : /* @__PURE__ */ jsx6(CloseOutlined2, {});
|
|
4904
|
+
return /* @__PURE__ */ jsxs4(
|
|
4905
|
+
"button",
|
|
4906
|
+
{
|
|
4907
|
+
type: "button",
|
|
4908
|
+
className: `sy-file-action sy-file-action-${type}`,
|
|
4909
|
+
disabled,
|
|
4910
|
+
onClick,
|
|
4911
|
+
"data-testid": testId,
|
|
4912
|
+
"aria-label": label,
|
|
4913
|
+
title: label,
|
|
4914
|
+
children: [
|
|
4915
|
+
icon,
|
|
4916
|
+
/* @__PURE__ */ jsx6("span", { className: "sy-sr-only", children: label })
|
|
4917
|
+
]
|
|
4918
|
+
}
|
|
4919
|
+
);
|
|
4920
|
+
}
|
|
4921
|
+
function FileStatusText({
|
|
4922
|
+
item,
|
|
4923
|
+
showFileSize = true,
|
|
4924
|
+
showFileTypeBadge = true
|
|
4925
|
+
}) {
|
|
4926
|
+
const extension = getFileExtension(item.name);
|
|
4927
|
+
const text = item.status === "uploading" ? `\u4E0A\u4F20\u4E2D ${Math.round(item.percent ?? 0)}%` : item.status === "error" ? item.error || "\u4E0A\u4F20\u5931\u8D25" : [
|
|
4928
|
+
showFileTypeBadge && extension ? extension.toUpperCase() : "",
|
|
4929
|
+
showFileSize ? formatFileSize(item.size) : ""
|
|
4930
|
+
].filter(Boolean).join(" \xB7 ") || "\u5DF2\u4E0A\u4F20";
|
|
4931
|
+
return /* @__PURE__ */ jsx6("span", { className: "sy-file-sub", children: text });
|
|
4932
|
+
}
|
|
4933
|
+
|
|
4934
|
+
// packages/sdk/src/runtime/react/filePreview.tsx
|
|
4935
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
4936
|
+
var EMPTY_ITEMS = [];
|
|
4937
|
+
var normalizeMethod2 = (method) => {
|
|
4938
|
+
const value = String(method || "get").toLowerCase();
|
|
4939
|
+
return ["get", "post", "put", "delete", "patch"].includes(value) ? value : "get";
|
|
4940
|
+
};
|
|
4941
|
+
var normalizeHeaders = (headers) => {
|
|
4942
|
+
if (!headers) return void 0;
|
|
4943
|
+
return Object.fromEntries(new Headers(headers).entries());
|
|
4944
|
+
};
|
|
4945
|
+
var toPageRequest = (config) => ({
|
|
4946
|
+
path: config.url,
|
|
4947
|
+
method: normalizeMethod2(config.method),
|
|
4948
|
+
query: config.params,
|
|
4949
|
+
body: config.data,
|
|
4950
|
+
headers: normalizeHeaders(config.headers)
|
|
4951
|
+
});
|
|
4952
|
+
var toRuntimeResponse = (response) => {
|
|
4953
|
+
if (response.raw && typeof response.raw === "object") {
|
|
4954
|
+
return response.raw;
|
|
4955
|
+
}
|
|
4956
|
+
return {
|
|
4957
|
+
code: Number(response.code) || 200,
|
|
4958
|
+
success: response.success,
|
|
4959
|
+
message: response.message,
|
|
4960
|
+
data: response.result,
|
|
4961
|
+
result: response.result
|
|
4962
|
+
};
|
|
4963
|
+
};
|
|
4964
|
+
var unwrapPageResult = (response) => response.result ?? response.data ?? null;
|
|
4965
|
+
var createPageFileRuntimeApi = (sdk) => {
|
|
4966
|
+
const request = async (config) => {
|
|
4967
|
+
const options = toPageRequest(config);
|
|
4968
|
+
if (config.responseType === "blob") {
|
|
4969
|
+
const response = await sdk.transport.download(options);
|
|
4970
|
+
return response.blob;
|
|
4971
|
+
}
|
|
4972
|
+
return toRuntimeResponse(await sdk.transport.request(options));
|
|
4973
|
+
};
|
|
4974
|
+
return createFormRuntimeApi({
|
|
4975
|
+
request,
|
|
4976
|
+
createFileAccessTicket: async (bucketName, objectName, fileName, purpose = "preview", options = {}) => unwrapPageResult(
|
|
4977
|
+
await sdk.createFileAccessTicket(
|
|
4978
|
+
bucketName,
|
|
4979
|
+
objectName,
|
|
4980
|
+
fileName,
|
|
4981
|
+
purpose,
|
|
4982
|
+
options
|
|
4983
|
+
)
|
|
4984
|
+
),
|
|
4985
|
+
createDownloadTicket: async (bucketName, objectName, fileName) => unwrapPageResult(
|
|
4986
|
+
await sdk.request({
|
|
4987
|
+
path: "/file/download-ticket",
|
|
4988
|
+
method: "post",
|
|
4989
|
+
body: { bucketName, objectName, fileName }
|
|
4990
|
+
})
|
|
4991
|
+
)
|
|
4992
|
+
});
|
|
4993
|
+
};
|
|
4994
|
+
var useFilePreview = ({
|
|
4995
|
+
items = EMPTY_ITEMS,
|
|
4996
|
+
appType,
|
|
4997
|
+
bucketName = "attachments",
|
|
4998
|
+
enabled = true,
|
|
4999
|
+
requireServerCapability = true
|
|
5000
|
+
}) => {
|
|
5001
|
+
const sdk = usePageSdk();
|
|
5002
|
+
const api = useMemo6(() => createPageFileRuntimeApi(sdk), [sdk]);
|
|
5003
|
+
const preview = useFilePreviewController({
|
|
5004
|
+
items,
|
|
5005
|
+
api,
|
|
5006
|
+
appType: appType || sdk.context.app.appType,
|
|
5007
|
+
bucketName,
|
|
5008
|
+
enabled,
|
|
5009
|
+
requireServerCapability
|
|
5010
|
+
});
|
|
5011
|
+
return {
|
|
5012
|
+
canPreview: preview.canPreview,
|
|
5013
|
+
getCapability: preview.getCapability,
|
|
5014
|
+
open: preview.openPreview,
|
|
5015
|
+
download: preview.downloadItem,
|
|
5016
|
+
isOpening: preview.isOpening,
|
|
5017
|
+
openingKey: preview.openingKey,
|
|
5018
|
+
host: preview.previewHost
|
|
5019
|
+
};
|
|
5020
|
+
};
|
|
5021
|
+
var AttachmentPreviewList = ({
|
|
5022
|
+
items = EMPTY_ITEMS,
|
|
5023
|
+
appType,
|
|
5024
|
+
bucketName = "attachments",
|
|
5025
|
+
showPreview = true,
|
|
5026
|
+
showDownload = true,
|
|
5027
|
+
showFileSize = true,
|
|
5028
|
+
showFileTypeBadge = false,
|
|
5029
|
+
emptyText = "\u6682\u65E0\u9644\u4EF6",
|
|
5030
|
+
className
|
|
5031
|
+
}) => {
|
|
5032
|
+
const preview = useFilePreview({
|
|
5033
|
+
items,
|
|
5034
|
+
appType,
|
|
5035
|
+
bucketName,
|
|
5036
|
+
enabled: showPreview,
|
|
5037
|
+
requireServerCapability: true
|
|
5038
|
+
});
|
|
5039
|
+
if (!items.length) {
|
|
5040
|
+
return /* @__PURE__ */ jsx7(Empty3, { description: emptyText, className });
|
|
5041
|
+
}
|
|
5042
|
+
return /* @__PURE__ */ jsxs5(
|
|
5043
|
+
"div",
|
|
5044
|
+
{
|
|
5045
|
+
className: ["sy-readonly-files", "sy-readonly-attachments", className].filter(Boolean).join(" "),
|
|
5046
|
+
"data-testid": "openxiangda-attachment-preview-list",
|
|
5047
|
+
children: [
|
|
5048
|
+
/* @__PURE__ */ jsx7("div", { className: "sy-file-list", children: items.map((item, index) => {
|
|
5049
|
+
const key = getPreviewItemKey(item, index);
|
|
5050
|
+
const canAct = item.status !== "uploading" && item.status !== "error";
|
|
5051
|
+
const canDownload = preview.getCapability(item)?.canDownload !== false;
|
|
5052
|
+
return /* @__PURE__ */ jsxs5("div", { className: "sy-file-item", children: [
|
|
5053
|
+
/* @__PURE__ */ jsx7(FileTypeIcon, { item }),
|
|
5054
|
+
/* @__PURE__ */ jsxs5("div", { className: "sy-file-meta", children: [
|
|
5055
|
+
/* @__PURE__ */ jsx7("span", { className: "sy-file-name", title: item.name, children: item.name || "\u672A\u547D\u540D\u9644\u4EF6" }),
|
|
5056
|
+
/* @__PURE__ */ jsx7(
|
|
5057
|
+
FileStatusText,
|
|
5058
|
+
{
|
|
5059
|
+
item,
|
|
5060
|
+
showFileSize,
|
|
5061
|
+
showFileTypeBadge
|
|
5062
|
+
}
|
|
5063
|
+
)
|
|
5064
|
+
] }),
|
|
5065
|
+
/* @__PURE__ */ jsxs5("div", { className: "sy-file-actions", children: [
|
|
5066
|
+
showPreview && preview.canPreview(item) ? /* @__PURE__ */ jsx7(
|
|
5067
|
+
FileActionButton,
|
|
5068
|
+
{
|
|
5069
|
+
type: "preview",
|
|
5070
|
+
disabled: !canAct || preview.isOpening(item),
|
|
5071
|
+
onClick: () => void preview.open(item),
|
|
5072
|
+
testId: `attachment-preview-${key}`
|
|
5073
|
+
}
|
|
5074
|
+
) : null,
|
|
5075
|
+
showDownload && canDownload ? /* @__PURE__ */ jsx7(
|
|
5076
|
+
FileActionButton,
|
|
5077
|
+
{
|
|
5078
|
+
type: "download",
|
|
5079
|
+
disabled: !canAct,
|
|
5080
|
+
onClick: () => void preview.download(item),
|
|
5081
|
+
testId: `attachment-download-${key}`
|
|
5082
|
+
}
|
|
5083
|
+
) : null
|
|
5084
|
+
] })
|
|
5085
|
+
] }, `${key}-${index}`);
|
|
5086
|
+
}) }),
|
|
5087
|
+
preview.host
|
|
5088
|
+
]
|
|
5089
|
+
}
|
|
5090
|
+
);
|
|
5091
|
+
};
|
|
5092
|
+
var PreviewImageThumb = ({ item }) => {
|
|
5093
|
+
const src = item.thumbUrl || item.previewUrl || item.url;
|
|
5094
|
+
const [failed, setFailed] = useState6(false);
|
|
5095
|
+
React6.useEffect(() => setFailed(false), [src]);
|
|
5096
|
+
return src && !failed ? /* @__PURE__ */ jsx7("img", { src, alt: item.name || "\u56FE\u7247", onError: () => setFailed(true) }) : /* @__PURE__ */ jsx7("span", { className: "sy-image-state", children: item.name || "\u56FE\u7247" });
|
|
5097
|
+
};
|
|
5098
|
+
var ImagePreviewGrid = ({
|
|
5099
|
+
items = EMPTY_ITEMS,
|
|
5100
|
+
appType,
|
|
5101
|
+
bucketName = "images",
|
|
5102
|
+
showPreview = true,
|
|
5103
|
+
showDownload = true,
|
|
5104
|
+
showFileName = true,
|
|
5105
|
+
emptyText = "\u6682\u65E0\u56FE\u7247",
|
|
5106
|
+
className
|
|
5107
|
+
}) => {
|
|
5108
|
+
const preview = useFilePreview({
|
|
5109
|
+
items,
|
|
5110
|
+
appType,
|
|
5111
|
+
bucketName,
|
|
5112
|
+
enabled: showPreview,
|
|
5113
|
+
requireServerCapability: true
|
|
5114
|
+
});
|
|
5115
|
+
if (!items.length) {
|
|
5116
|
+
return /* @__PURE__ */ jsx7(Empty3, { description: emptyText, className });
|
|
5117
|
+
}
|
|
5118
|
+
return /* @__PURE__ */ jsxs5(
|
|
5119
|
+
"div",
|
|
5120
|
+
{
|
|
5121
|
+
className: ["sy-readonly-files", "sy-readonly-images", className].filter(Boolean).join(" "),
|
|
5122
|
+
"data-testid": "openxiangda-image-preview-grid",
|
|
5123
|
+
children: [
|
|
5124
|
+
/* @__PURE__ */ jsx7(
|
|
5125
|
+
"div",
|
|
5126
|
+
{
|
|
5127
|
+
className: "sy-mobile-image-grid",
|
|
5128
|
+
style: { gridTemplateColumns: "repeat(auto-fill, minmax(112px, 160px))" },
|
|
5129
|
+
children: items.map((item, index) => {
|
|
5130
|
+
const key = getPreviewItemKey(item, index);
|
|
5131
|
+
const canAct = item.status !== "uploading" && item.status !== "error";
|
|
5132
|
+
const canOpen = showPreview && preview.canPreview(item);
|
|
5133
|
+
const canDownload = preview.getCapability(item)?.canDownload !== false;
|
|
5134
|
+
return /* @__PURE__ */ jsxs5("div", { className: "sy-mobile-image-card", children: [
|
|
5135
|
+
/* @__PURE__ */ jsx7("div", { className: "sy-mobile-image-thumb", children: /* @__PURE__ */ jsx7(
|
|
5136
|
+
"button",
|
|
5137
|
+
{
|
|
5138
|
+
type: "button",
|
|
5139
|
+
className: "sy-image-preview",
|
|
5140
|
+
disabled: !canAct || !canOpen || preview.isOpening(item),
|
|
5141
|
+
onClick: () => void preview.open(item),
|
|
5142
|
+
"aria-label": `\u9884\u89C8 ${item.name || "\u56FE\u7247"}`,
|
|
5143
|
+
"data-testid": `image-preview-${key}`,
|
|
5144
|
+
children: /* @__PURE__ */ jsx7(PreviewImageThumb, { item })
|
|
5145
|
+
}
|
|
5146
|
+
) }),
|
|
5147
|
+
/* @__PURE__ */ jsxs5(
|
|
5148
|
+
"div",
|
|
5149
|
+
{
|
|
5150
|
+
style: {
|
|
5151
|
+
display: "flex",
|
|
5152
|
+
alignItems: "center",
|
|
5153
|
+
gap: 6,
|
|
5154
|
+
minWidth: 0
|
|
5155
|
+
},
|
|
5156
|
+
children: [
|
|
5157
|
+
showFileName ? /* @__PURE__ */ jsx7("div", { className: "sy-mobile-image-name", title: item.name, style: { flex: 1 }, children: item.name || "\u56FE\u7247" }) : /* @__PURE__ */ jsx7("span", { style: { flex: 1 } }),
|
|
5158
|
+
/* @__PURE__ */ jsxs5("div", { className: "sy-file-actions", children: [
|
|
5159
|
+
canOpen ? /* @__PURE__ */ jsx7(
|
|
5160
|
+
FileActionButton,
|
|
5161
|
+
{
|
|
5162
|
+
type: "preview",
|
|
5163
|
+
disabled: !canAct || preview.isOpening(item),
|
|
5164
|
+
onClick: () => void preview.open(item)
|
|
5165
|
+
}
|
|
5166
|
+
) : null,
|
|
5167
|
+
showDownload && canDownload ? /* @__PURE__ */ jsx7(
|
|
5168
|
+
FileActionButton,
|
|
5169
|
+
{
|
|
5170
|
+
type: "download",
|
|
5171
|
+
disabled: !canAct,
|
|
5172
|
+
onClick: () => void preview.download(item)
|
|
5173
|
+
}
|
|
5174
|
+
) : null
|
|
5175
|
+
] })
|
|
5176
|
+
]
|
|
5177
|
+
}
|
|
5178
|
+
)
|
|
5179
|
+
] }, `${key}-${index}`);
|
|
5180
|
+
})
|
|
5181
|
+
}
|
|
5182
|
+
),
|
|
5183
|
+
preview.host
|
|
5184
|
+
]
|
|
5185
|
+
}
|
|
5186
|
+
);
|
|
5187
|
+
};
|
|
5188
|
+
|
|
2622
5189
|
// packages/sdk/src/runtime/react/workflow.tsx
|
|
2623
|
-
import { useCallback as
|
|
2624
|
-
import { Form, Input as Input2, Modal as
|
|
5190
|
+
import { useCallback as useCallback8, useEffect as useEffect10, useMemo as useMemo12, useRef as useRef5, useState as useState11 } from "react";
|
|
5191
|
+
import { Form, Input as Input2, Modal as Modal5, Select as Select2 } from "antd";
|
|
2625
5192
|
import {
|
|
2626
5193
|
CheckOutlined,
|
|
2627
|
-
CloseOutlined,
|
|
2628
|
-
ReloadOutlined as
|
|
5194
|
+
CloseOutlined as CloseOutlined3,
|
|
5195
|
+
ReloadOutlined as ReloadOutlined4,
|
|
2629
5196
|
RollbackOutlined as RollbackOutlined2,
|
|
2630
5197
|
SaveOutlined,
|
|
2631
5198
|
SwapOutlined
|
|
2632
5199
|
} from "@ant-design/icons";
|
|
2633
5200
|
|
|
2634
5201
|
// packages/sdk/src/components/modules/StickyActionBar.tsx
|
|
2635
|
-
import { useEffect as
|
|
2636
|
-
import { Button, Dropdown, Tooltip } from "antd";
|
|
5202
|
+
import { useEffect as useEffect6, useMemo as useMemo7, useState as useState7 } from "react";
|
|
5203
|
+
import { Button as Button4, Dropdown, Tooltip as Tooltip2 } from "antd";
|
|
2637
5204
|
import { MoreOutlined } from "@ant-design/icons";
|
|
2638
5205
|
|
|
2639
5206
|
// packages/sdk/src/components/utils/confirmAction.ts
|
|
@@ -2650,7 +5217,7 @@ var confirmAction = (title, content) => {
|
|
|
2650
5217
|
};
|
|
2651
5218
|
|
|
2652
5219
|
// packages/sdk/src/components/modules/StickyActionBar.tsx
|
|
2653
|
-
import { Fragment as
|
|
5220
|
+
import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2654
5221
|
var getActionPriority = (action) => {
|
|
2655
5222
|
const maybePriority = action.priority;
|
|
2656
5223
|
if (typeof maybePriority === "number") return maybePriority;
|
|
@@ -2668,14 +5235,14 @@ var StickyActionBar = ({
|
|
|
2668
5235
|
position = "sticky",
|
|
2669
5236
|
surface = "default"
|
|
2670
5237
|
}) => {
|
|
2671
|
-
const [isMobile, setIsMobile] =
|
|
2672
|
-
|
|
5238
|
+
const [isMobile, setIsMobile] = useState7(false);
|
|
5239
|
+
useEffect6(() => {
|
|
2673
5240
|
const update = () => setIsMobile(typeof window !== "undefined" && window.innerWidth <= 768);
|
|
2674
5241
|
update();
|
|
2675
5242
|
window.addEventListener("resize", update);
|
|
2676
5243
|
return () => window.removeEventListener("resize", update);
|
|
2677
5244
|
}, []);
|
|
2678
|
-
const visibleActions =
|
|
5245
|
+
const visibleActions = useMemo7(
|
|
2679
5246
|
() => actions.filter((action) => action.visible !== false).sort((left, right) => getActionPriority(left) - getActionPriority(right)),
|
|
2680
5247
|
[actions]
|
|
2681
5248
|
);
|
|
@@ -2696,8 +5263,8 @@ var StickyActionBar = ({
|
|
|
2696
5263
|
action.onClick();
|
|
2697
5264
|
};
|
|
2698
5265
|
const renderButton = (action, mobile = false) => {
|
|
2699
|
-
const button = /* @__PURE__ */
|
|
2700
|
-
|
|
5266
|
+
const button = /* @__PURE__ */ jsx8(
|
|
5267
|
+
Button4,
|
|
2701
5268
|
{
|
|
2702
5269
|
type: action.type === "danger" ? "primary" : action.type === "text" ? "text" : action.type || "default",
|
|
2703
5270
|
danger: action.type === "danger",
|
|
@@ -2711,16 +5278,16 @@ var StickyActionBar = ({
|
|
|
2711
5278
|
action.key
|
|
2712
5279
|
);
|
|
2713
5280
|
if (!action.disabled || !action.disabledReason) return button;
|
|
2714
|
-
return /* @__PURE__ */
|
|
5281
|
+
return /* @__PURE__ */ jsx8(Tooltip2, { title: action.disabledReason, children: /* @__PURE__ */ jsx8("span", { className: mobile ? "flex min-w-0 flex-1" : "inline-flex", children: button }) }, action.key);
|
|
2715
5282
|
};
|
|
2716
|
-
return /* @__PURE__ */
|
|
5283
|
+
return /* @__PURE__ */ jsx8("div", { className: `${positionClass} z-20 ${spacingClass} ${surfaceClass} ${className}`, children: /* @__PURE__ */ jsx8(
|
|
2717
5284
|
"div",
|
|
2718
5285
|
{
|
|
2719
5286
|
className: `mx-auto flex w-full items-center gap-3 ${!isMobile ? desktopJustifyClass : "justify-end"}`,
|
|
2720
5287
|
style: { maxWidth: maxWidthStyle },
|
|
2721
|
-
children: isMobile ? /* @__PURE__ */
|
|
2722
|
-
/* @__PURE__ */
|
|
2723
|
-
moreMobile.length > 0 && /* @__PURE__ */
|
|
5288
|
+
children: isMobile ? /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
5289
|
+
/* @__PURE__ */ jsx8("div", { className: "flex flex-1 gap-2", children: primaryMobile.map((action) => renderButton(action, true)) }),
|
|
5290
|
+
moreMobile.length > 0 && /* @__PURE__ */ jsx8(
|
|
2724
5291
|
Dropdown,
|
|
2725
5292
|
{
|
|
2726
5293
|
trigger: ["click"],
|
|
@@ -2735,16 +5302,16 @@ var StickyActionBar = ({
|
|
|
2735
5302
|
onClick: () => runAction(action)
|
|
2736
5303
|
}))
|
|
2737
5304
|
},
|
|
2738
|
-
children: /* @__PURE__ */
|
|
5305
|
+
children: /* @__PURE__ */ jsx8(Button4, { icon: /* @__PURE__ */ jsx8(MoreOutlined, {}), className: "rounded-md", children: "\u66F4\u591A" })
|
|
2739
5306
|
}
|
|
2740
5307
|
)
|
|
2741
|
-
] }) : layoutMode === "approval" ? /* @__PURE__ */
|
|
5308
|
+
] }) : layoutMode === "approval" ? /* @__PURE__ */ jsx8("div", { className: "flex flex-wrap items-center justify-center gap-3", children: visibleActions.map((action) => renderButton(action)) }) : /* @__PURE__ */ jsx8("div", { className: `flex flex-wrap items-center ${desktopJustifyClass} gap-3`, children: visibleActions.map((action) => renderButton(action)) })
|
|
2742
5309
|
}
|
|
2743
5310
|
) });
|
|
2744
5311
|
};
|
|
2745
5312
|
|
|
2746
5313
|
// packages/sdk/src/components/modules/ApprovalTimeline.tsx
|
|
2747
|
-
import { useMemo as
|
|
5314
|
+
import { useMemo as useMemo8 } from "react";
|
|
2748
5315
|
import {
|
|
2749
5316
|
ApiOutlined,
|
|
2750
5317
|
CheckCircleFilled,
|
|
@@ -2753,10 +5320,10 @@ import {
|
|
|
2753
5320
|
CodeOutlined,
|
|
2754
5321
|
CopyOutlined,
|
|
2755
5322
|
EditOutlined,
|
|
2756
|
-
FileTextOutlined,
|
|
5323
|
+
FileTextOutlined as FileTextOutlined2,
|
|
2757
5324
|
LoadingOutlined,
|
|
2758
5325
|
NotificationOutlined,
|
|
2759
|
-
ReloadOutlined,
|
|
5326
|
+
ReloadOutlined as ReloadOutlined3,
|
|
2760
5327
|
RollbackOutlined,
|
|
2761
5328
|
UserOutlined
|
|
2762
5329
|
} from "@ant-design/icons";
|
|
@@ -2775,7 +5342,7 @@ var TASK_STATUS_META = {
|
|
|
2775
5342
|
};
|
|
2776
5343
|
|
|
2777
5344
|
// packages/sdk/src/components/modules/ApprovalTimeline.tsx
|
|
2778
|
-
import { jsx as
|
|
5345
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2779
5346
|
var systemNodeTypes = /* @__PURE__ */ new Set([
|
|
2780
5347
|
"condition",
|
|
2781
5348
|
"condition_branch",
|
|
@@ -2869,37 +5436,37 @@ function getStatusMeta(task, state, compact) {
|
|
|
2869
5436
|
}
|
|
2870
5437
|
function getIcon(task, state) {
|
|
2871
5438
|
if (state === "current")
|
|
2872
|
-
return task.nodeType === "callback_wait" ? /* @__PURE__ */
|
|
5439
|
+
return task.nodeType === "callback_wait" ? /* @__PURE__ */ jsx9(ClockCircleOutlined, {}) : /* @__PURE__ */ jsx9(LoadingOutlined, {});
|
|
2873
5440
|
if (state === "future" || state === "waiting")
|
|
2874
|
-
return task.nodeType === "approval" ? /* @__PURE__ */
|
|
2875
|
-
if (state === "rejected") return /* @__PURE__ */
|
|
2876
|
-
if (state === "returned") return /* @__PURE__ */
|
|
5441
|
+
return task.nodeType === "approval" ? /* @__PURE__ */ jsx9(UserOutlined, {}) : /* @__PURE__ */ jsx9(ClockCircleOutlined, {});
|
|
5442
|
+
if (state === "rejected") return /* @__PURE__ */ jsx9(CloseCircleFilled, {});
|
|
5443
|
+
if (state === "returned") return /* @__PURE__ */ jsx9(RollbackOutlined, {});
|
|
2877
5444
|
switch (task.nodeType) {
|
|
2878
5445
|
case "start":
|
|
2879
|
-
return /* @__PURE__ */
|
|
5446
|
+
return /* @__PURE__ */ jsx9(FileTextOutlined2, {});
|
|
2880
5447
|
case "approval":
|
|
2881
|
-
return /* @__PURE__ */
|
|
5448
|
+
return /* @__PURE__ */ jsx9(CheckCircleFilled, {});
|
|
2882
5449
|
case "originator_return":
|
|
2883
|
-
return /* @__PURE__ */
|
|
5450
|
+
return /* @__PURE__ */ jsx9(EditOutlined, {});
|
|
2884
5451
|
case "copy":
|
|
2885
|
-
return /* @__PURE__ */
|
|
5452
|
+
return /* @__PURE__ */ jsx9(CopyOutlined, {});
|
|
2886
5453
|
case "callback_wait":
|
|
2887
|
-
return /* @__PURE__ */
|
|
5454
|
+
return /* @__PURE__ */ jsx9(ClockCircleOutlined, {});
|
|
2888
5455
|
case "js_code":
|
|
2889
|
-
return /* @__PURE__ */
|
|
5456
|
+
return /* @__PURE__ */ jsx9(CodeOutlined, {});
|
|
2890
5457
|
case "connector_call":
|
|
2891
|
-
return /* @__PURE__ */
|
|
5458
|
+
return /* @__PURE__ */ jsx9(ApiOutlined, {});
|
|
2892
5459
|
case "work_notification":
|
|
2893
5460
|
case "dingtalk_card":
|
|
2894
|
-
return /* @__PURE__ */
|
|
5461
|
+
return /* @__PURE__ */ jsx9(NotificationOutlined, {});
|
|
2895
5462
|
case "data_retrieve_single":
|
|
2896
5463
|
case "data_retrieve_batch":
|
|
2897
5464
|
case "data_create":
|
|
2898
5465
|
case "data_update":
|
|
2899
5466
|
case "loop_container":
|
|
2900
|
-
return /* @__PURE__ */
|
|
5467
|
+
return /* @__PURE__ */ jsx9(ReloadOutlined3, {});
|
|
2901
5468
|
default:
|
|
2902
|
-
return /* @__PURE__ */
|
|
5469
|
+
return /* @__PURE__ */ jsx9(CheckCircleFilled, {});
|
|
2903
5470
|
}
|
|
2904
5471
|
}
|
|
2905
5472
|
function getDotClass(state) {
|
|
@@ -2922,21 +5489,21 @@ var ApprovalTimeline = ({
|
|
|
2922
5489
|
compactMode = false,
|
|
2923
5490
|
showApproverInfo = true
|
|
2924
5491
|
}) => {
|
|
2925
|
-
const taskList =
|
|
2926
|
-
const groups =
|
|
5492
|
+
const taskList = useMemo8(() => Array.isArray(tasks) ? tasks : [], [tasks]);
|
|
5493
|
+
const groups = useMemo8(() => groupTasks(taskList), [taskList]);
|
|
2927
5494
|
if (taskList.length === 0) {
|
|
2928
|
-
return /* @__PURE__ */
|
|
5495
|
+
return /* @__PURE__ */ jsx9(
|
|
2929
5496
|
"div",
|
|
2930
5497
|
{
|
|
2931
5498
|
className: `rounded-lg border border-ant-border-secondary bg-ant-bg-container p-6 ${className}`,
|
|
2932
|
-
children: /* @__PURE__ */
|
|
5499
|
+
children: /* @__PURE__ */ jsx9("p", { className: "m-0 text-center text-sm text-ant-text-tertiary", children: "\u6682\u65E0\u5BA1\u6279\u8BB0\u5F55" })
|
|
2933
5500
|
}
|
|
2934
5501
|
);
|
|
2935
5502
|
}
|
|
2936
5503
|
if (renderNode) {
|
|
2937
|
-
return /* @__PURE__ */
|
|
5504
|
+
return /* @__PURE__ */ jsx9("div", { className, children: taskList.map((task, index) => /* @__PURE__ */ jsx9("div", { children: renderNode(task, index) }, task.taskId || task.id || index)) });
|
|
2938
5505
|
}
|
|
2939
|
-
return /* @__PURE__ */
|
|
5506
|
+
return /* @__PURE__ */ jsx9("div", { className: `approval-timeline ${className}`, children: groups.map((group, index) => {
|
|
2940
5507
|
const node = group[0];
|
|
2941
5508
|
const isLast = index === groups.length - 1;
|
|
2942
5509
|
const isFutureGroup = group.some((task) => task.isSimulated || task.status === "simulated");
|
|
@@ -2945,62 +5512,62 @@ var ApprovalTimeline = ({
|
|
|
2945
5512
|
const statusMeta = getStatusMeta(node, state, compact);
|
|
2946
5513
|
const title = getNodeTitle(node);
|
|
2947
5514
|
const time = node.actionAt || node.createdAt;
|
|
2948
|
-
return /* @__PURE__ */
|
|
5515
|
+
return /* @__PURE__ */ jsxs7(
|
|
2949
5516
|
"div",
|
|
2950
5517
|
{
|
|
2951
5518
|
className: `relative flex gap-4 pb-5 ${isLast ? "pb-0" : ""}`,
|
|
2952
5519
|
children: [
|
|
2953
|
-
!isLast && /* @__PURE__ */
|
|
5520
|
+
!isLast && /* @__PURE__ */ jsx9(
|
|
2954
5521
|
"div",
|
|
2955
5522
|
{
|
|
2956
5523
|
className: `absolute bottom-0 left-[21px] top-11 w-px ${state === "future" ? "border-l border-dashed border-gray-300" : "bg-ant-border-secondary"}`
|
|
2957
5524
|
}
|
|
2958
5525
|
),
|
|
2959
|
-
/* @__PURE__ */
|
|
5526
|
+
/* @__PURE__ */ jsx9(
|
|
2960
5527
|
"div",
|
|
2961
5528
|
{
|
|
2962
5529
|
className: `relative z-10 flex h-11 w-11 shrink-0 items-center justify-center rounded-full border-2 shadow-[0_0_0_4px_var(--ant-color-bg-layout,#f5f5f5)] ${getDotClass(state)}`,
|
|
2963
5530
|
children: getIcon(node, state)
|
|
2964
5531
|
}
|
|
2965
5532
|
),
|
|
2966
|
-
/* @__PURE__ */
|
|
5533
|
+
/* @__PURE__ */ jsx9("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxs7(
|
|
2967
5534
|
"div",
|
|
2968
5535
|
{
|
|
2969
5536
|
className: `rounded-lg border p-4 ${state === "current" ? "border-blue-300 bg-blue-50/60" : state === "future" ? "border-dashed border-gray-200 bg-gray-50/70" : "border-ant-border-secondary bg-ant-bg-container"}`,
|
|
2970
5537
|
children: [
|
|
2971
|
-
/* @__PURE__ */
|
|
2972
|
-
/* @__PURE__ */
|
|
2973
|
-
/* @__PURE__ */
|
|
2974
|
-
/* @__PURE__ */
|
|
5538
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-start justify-between gap-2", children: [
|
|
5539
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [
|
|
5540
|
+
/* @__PURE__ */ jsx9("span", { className: "font-medium text-ant-text", children: title }),
|
|
5541
|
+
/* @__PURE__ */ jsx9(
|
|
2975
5542
|
"span",
|
|
2976
5543
|
{
|
|
2977
5544
|
className: `inline-flex min-h-6 items-center rounded-md border px-2 text-xs font-medium ${state === "future" ? toneClasses.future : toneClasses[statusMeta.tone]}`,
|
|
2978
5545
|
children: statusMeta.label
|
|
2979
5546
|
}
|
|
2980
5547
|
),
|
|
2981
|
-
node.nodeType === "originator_return" && /* @__PURE__ */
|
|
5548
|
+
node.nodeType === "originator_return" && /* @__PURE__ */ jsx9("span", { className: "rounded-md bg-amber-50 px-2 py-1 text-xs text-amber-700", children: "\u53D1\u8D77\u4EBA\u64CD\u4F5C" })
|
|
2982
5549
|
] }),
|
|
2983
|
-
!isFutureGroup && time && /* @__PURE__ */
|
|
5550
|
+
!isFutureGroup && time && /* @__PURE__ */ jsx9("span", { className: "text-xs text-ant-text-tertiary", children: time })
|
|
2984
5551
|
] }),
|
|
2985
|
-
showApproverInfo && !compact && group.length > 0 && /* @__PURE__ */
|
|
2986
|
-
/* @__PURE__ */
|
|
2987
|
-
group.map((assignee) => /* @__PURE__ */
|
|
5552
|
+
showApproverInfo && !compact && group.length > 0 && /* @__PURE__ */ jsxs7("div", { className: "mt-3 flex flex-wrap gap-3", children: [
|
|
5553
|
+
/* @__PURE__ */ jsx9("span", { className: "w-full text-xs font-medium text-ant-text-tertiary", children: state === "current" || state === "waiting" ? "\u5F53\u524D\u5BA1\u6279\u4EBA" : "\u5904\u7406\u4EBA" }),
|
|
5554
|
+
group.map((assignee) => /* @__PURE__ */ jsxs7(
|
|
2988
5555
|
"span",
|
|
2989
5556
|
{
|
|
2990
5557
|
className: "inline-flex min-w-0 items-center gap-2",
|
|
2991
5558
|
children: [
|
|
2992
|
-
/* @__PURE__ */
|
|
2993
|
-
/* @__PURE__ */
|
|
2994
|
-
/* @__PURE__ */
|
|
2995
|
-
/* @__PURE__ */
|
|
5559
|
+
/* @__PURE__ */ jsx9("span", { className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-blue-50 text-xs font-semibold text-blue-700", children: assignee.assigneeName?.slice(0, 1) || "?" }),
|
|
5560
|
+
/* @__PURE__ */ jsxs7("span", { className: "min-w-0", children: [
|
|
5561
|
+
/* @__PURE__ */ jsx9("span", { className: "block text-sm font-medium text-ant-text", children: assignee.assigneeName || "\u7CFB\u7EDF" }),
|
|
5562
|
+
/* @__PURE__ */ jsx9("span", { className: "block text-xs text-ant-text-tertiary", children: assignee.departmentName || assignee.actionAt || assignee.createdAt || "" })
|
|
2996
5563
|
] })
|
|
2997
5564
|
]
|
|
2998
5565
|
},
|
|
2999
5566
|
assignee.taskId || assignee.id
|
|
3000
5567
|
))
|
|
3001
5568
|
] }),
|
|
3002
|
-
showApproverInfo && compact && /* @__PURE__ */
|
|
3003
|
-
showRemarks && node.comments && /* @__PURE__ */
|
|
5569
|
+
showApproverInfo && compact && /* @__PURE__ */ jsx9("div", { className: "mt-2 text-sm text-ant-text-secondary", children: group.map((item) => item.assigneeName).filter(Boolean).join("\u3001") || (node.nodeType === "start" ? "\u63D0\u4EA4\u7533\u8BF7" : systemNodeTypes.has(node.nodeType) ? node.comments || "\u7CFB\u7EDF\u81EA\u52A8\u5904\u7406" : "") }),
|
|
5570
|
+
showRemarks && node.comments && /* @__PURE__ */ jsx9(
|
|
3004
5571
|
"div",
|
|
3005
5572
|
{
|
|
3006
5573
|
className: `mt-3 border-l-2 pl-3 text-sm leading-6 ${state === "rejected" ? "border-red-300 text-red-700" : state === "returned" ? "border-amber-300 text-amber-700" : "border-ant-border-secondary text-ant-text-secondary"}`,
|
|
@@ -3018,9 +5585,9 @@ var ApprovalTimeline = ({
|
|
|
3018
5585
|
};
|
|
3019
5586
|
|
|
3020
5587
|
// packages/sdk/src/components/modules/ProcessPreview.tsx
|
|
3021
|
-
import { Modal, Skeleton, Button as
|
|
5588
|
+
import { Modal as Modal2, Skeleton, Button as Button5 } from "antd";
|
|
3022
5589
|
import { CheckCircleOutlined, UserOutlined as UserOutlined2 } from "@ant-design/icons";
|
|
3023
|
-
import { jsx as
|
|
5590
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3024
5591
|
var ProcessPreview = ({
|
|
3025
5592
|
open,
|
|
3026
5593
|
onClose,
|
|
@@ -3029,30 +5596,30 @@ var ProcessPreview = ({
|
|
|
3029
5596
|
loading = false
|
|
3030
5597
|
}) => {
|
|
3031
5598
|
const routeList = Array.isArray(routes) ? routes : [];
|
|
3032
|
-
return /* @__PURE__ */
|
|
3033
|
-
|
|
5599
|
+
return /* @__PURE__ */ jsx10(
|
|
5600
|
+
Modal2,
|
|
3034
5601
|
{
|
|
3035
5602
|
getContainer: false,
|
|
3036
5603
|
title: "\u6D41\u7A0B\u9884\u89C8",
|
|
3037
5604
|
open,
|
|
3038
5605
|
onCancel: onClose,
|
|
3039
5606
|
width: 520,
|
|
3040
|
-
footer: /* @__PURE__ */
|
|
3041
|
-
/* @__PURE__ */
|
|
3042
|
-
/* @__PURE__ */
|
|
5607
|
+
footer: /* @__PURE__ */ jsxs8("div", { className: "flex justify-end gap-3", children: [
|
|
5608
|
+
/* @__PURE__ */ jsx10(Button5, { onClick: onClose, children: "\u53D6\u6D88" }),
|
|
5609
|
+
/* @__PURE__ */ jsx10(Button5, { type: "primary", onClick: onConfirm, loading, children: "\u786E\u8BA4\u63D0\u4EA4" })
|
|
3043
5610
|
] }),
|
|
3044
|
-
children: loading && routeList.length === 0 ? /* @__PURE__ */
|
|
5611
|
+
children: loading && routeList.length === 0 ? /* @__PURE__ */ jsx10(Skeleton, { active: true, paragraph: { rows: 4 } }) : routeList.length === 0 ? /* @__PURE__ */ jsx10("p", { className: "text-sm text-gray-400 text-center py-8", children: "\u6682\u65E0\u6D41\u7A0B\u8282\u70B9" }) : /* @__PURE__ */ jsx10("div", { className: "py-2", children: routeList.map((route, index) => {
|
|
3045
5612
|
const isLast = index === routeList.length - 1;
|
|
3046
|
-
return /* @__PURE__ */
|
|
3047
|
-
/* @__PURE__ */
|
|
3048
|
-
/* @__PURE__ */
|
|
3049
|
-
!isLast && /* @__PURE__ */
|
|
5613
|
+
return /* @__PURE__ */ jsxs8("div", { className: "flex gap-3", children: [
|
|
5614
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-center", children: [
|
|
5615
|
+
/* @__PURE__ */ jsx10("div", { className: "w-6 h-6 rounded-full bg-blue-50 border-2 border-blue-400 flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsx10(CheckCircleOutlined, { className: "text-blue-500 text-xs" }) }),
|
|
5616
|
+
!isLast && /* @__PURE__ */ jsx10("div", { className: "w-0.5 flex-1 bg-blue-200 mt-1" })
|
|
3050
5617
|
] }),
|
|
3051
|
-
/* @__PURE__ */
|
|
3052
|
-
/* @__PURE__ */
|
|
3053
|
-
route.assignees && route.assignees.length > 0 && /* @__PURE__ */
|
|
3054
|
-
/* @__PURE__ */
|
|
3055
|
-
route.assignees.map((assignee) => /* @__PURE__ */
|
|
5618
|
+
/* @__PURE__ */ jsxs8("div", { className: `flex-1 ${isLast ? "pb-0" : "pb-5"}`, children: [
|
|
5619
|
+
/* @__PURE__ */ jsx10("div", { className: "text-sm font-medium text-gray-900", children: route.nodeName }),
|
|
5620
|
+
route.assignees && route.assignees.length > 0 && /* @__PURE__ */ jsxs8("div", { className: "mt-1 flex items-center gap-1.5 flex-wrap", children: [
|
|
5621
|
+
/* @__PURE__ */ jsx10(UserOutlined2, { className: "text-gray-400 text-xs" }),
|
|
5622
|
+
route.assignees.map((assignee) => /* @__PURE__ */ jsx10(
|
|
3056
5623
|
"span",
|
|
3057
5624
|
{
|
|
3058
5625
|
className: "text-xs text-gray-500 bg-gray-100 px-1.5 py-0.5 rounded",
|
|
@@ -3069,20 +5636,20 @@ var ProcessPreview = ({
|
|
|
3069
5636
|
};
|
|
3070
5637
|
|
|
3071
5638
|
// packages/sdk/src/components/modules/InitiatorApproverSelector.tsx
|
|
3072
|
-
import { useCallback as
|
|
3073
|
-
import { Button as
|
|
5639
|
+
import { useCallback as useCallback7, useEffect as useEffect9, useMemo as useMemo11, useRef as useRef4, useState as useState10 } from "react";
|
|
5640
|
+
import { Button as Button7, Empty as Empty5, Modal as Modal4, Select, Space as Space2, Tag as Tag3, Typography as Typography4, message as message2 } from "antd";
|
|
3074
5641
|
|
|
3075
5642
|
// packages/sdk/src/components/core/processApi.ts
|
|
3076
5643
|
var hasOwn2 = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
3077
5644
|
var isRuntimeEnvelope = (value) => !!value && typeof value === "object" && !Array.isArray(value) && (hasOwn2(value, "code") || hasOwn2(value, "success") || hasOwn2(value, "data") || hasOwn2(value, "result") || hasOwn2(value, "message") || hasOwn2(value, "error"));
|
|
3078
|
-
var
|
|
5645
|
+
var isSuccessCode3 = (code) => {
|
|
3079
5646
|
if (code === void 0 || code === null || code === "") return true;
|
|
3080
5647
|
const normalized = Number(code);
|
|
3081
5648
|
return Number.isFinite(normalized) ? normalized === 0 || normalized === 200 : false;
|
|
3082
5649
|
};
|
|
3083
5650
|
var unwrapRuntimeResponse = (response) => {
|
|
3084
5651
|
if (!isRuntimeEnvelope(response)) return response;
|
|
3085
|
-
if (response.success === false || !
|
|
5652
|
+
if (response.success === false || !isSuccessCode3(response.code)) {
|
|
3086
5653
|
throw new Error(response.message || response.error || "\u8BF7\u6C42\u5931\u8D25");
|
|
3087
5654
|
}
|
|
3088
5655
|
if (hasOwn2(response, "data")) return response.data;
|
|
@@ -3114,88 +5681,26 @@ async function getInitiatorSelectCandidates(request, params) {
|
|
|
3114
5681
|
}
|
|
3115
5682
|
|
|
3116
5683
|
// packages/sdk/src/components/fields/shared/UserPicker.tsx
|
|
3117
|
-
import { useCallback as
|
|
5684
|
+
import { useCallback as useCallback6, useEffect as useEffect8, useMemo as useMemo10, useState as useState9 } from "react";
|
|
3118
5685
|
import {
|
|
3119
5686
|
Avatar,
|
|
3120
|
-
Button as
|
|
5687
|
+
Button as Button6,
|
|
3121
5688
|
Checkbox,
|
|
3122
|
-
Empty,
|
|
5689
|
+
Empty as Empty4,
|
|
3123
5690
|
Input,
|
|
3124
5691
|
List,
|
|
3125
|
-
Modal as
|
|
5692
|
+
Modal as Modal3,
|
|
3126
5693
|
Pagination,
|
|
3127
5694
|
Space,
|
|
3128
|
-
Spin,
|
|
3129
|
-
Tag,
|
|
5695
|
+
Spin as Spin4,
|
|
5696
|
+
Tag as Tag2,
|
|
3130
5697
|
Tree
|
|
3131
5698
|
} from "antd";
|
|
3132
5699
|
import { SearchOutlined, TeamOutlined, UserOutlined as UserOutlined3 } from "@ant-design/icons";
|
|
3133
5700
|
import * as MobileAntd from "antd-mobile";
|
|
3134
5701
|
|
|
3135
|
-
// packages/sdk/src/components/fields/shared/fieldFormat.ts
|
|
3136
|
-
function getUserId(user) {
|
|
3137
|
-
if (typeof user === "string" || typeof user === "number") return String(user).trim();
|
|
3138
|
-
return String(user?.id || user?.userId || user?.userid || user?.value || user?.key || "").trim();
|
|
3139
|
-
}
|
|
3140
|
-
function getUserName(user) {
|
|
3141
|
-
if (typeof user === "string" || typeof user === "number") return String(user).trim();
|
|
3142
|
-
return String(
|
|
3143
|
-
user?.name || user?.label || user?.title || user?.username || user?.nickname || getUserId(user)
|
|
3144
|
-
);
|
|
3145
|
-
}
|
|
3146
|
-
function normalizeUser(user) {
|
|
3147
|
-
const id = getUserId(user);
|
|
3148
|
-
const source = typeof user === "object" && user !== null ? user : {};
|
|
3149
|
-
return {
|
|
3150
|
-
...source,
|
|
3151
|
-
id,
|
|
3152
|
-
name: getUserName({ ...source, id })
|
|
3153
|
-
};
|
|
3154
|
-
}
|
|
3155
|
-
function getDepartmentId(node) {
|
|
3156
|
-
if (typeof node === "string" || typeof node === "number") return String(node).trim();
|
|
3157
|
-
return String(
|
|
3158
|
-
node?.id || node?.departmentId || node?.deptId || node?.value || node?.key || ""
|
|
3159
|
-
).trim();
|
|
3160
|
-
}
|
|
3161
|
-
function getDepartmentName(node) {
|
|
3162
|
-
if (typeof node === "string" || typeof node === "number") return String(node).trim();
|
|
3163
|
-
return String(
|
|
3164
|
-
node?.name || node?.label || node?.title || node?.deptName || node?.departmentName || getDepartmentId(node)
|
|
3165
|
-
);
|
|
3166
|
-
}
|
|
3167
|
-
function normalizeDepartmentNode(node) {
|
|
3168
|
-
const id = getDepartmentId(node);
|
|
3169
|
-
const source = typeof node === "object" && node !== null ? node : {};
|
|
3170
|
-
const name = getDepartmentName({ ...source, id });
|
|
3171
|
-
const hasChildren = typeof node?.hasChildren === "boolean" ? node.hasChildren : Array.isArray(node?.children) && node.children.length > 0;
|
|
3172
|
-
const children = Array.isArray(node?.children) ? node.children.map((child) => normalizeDepartmentNode(child)) : void 0;
|
|
3173
|
-
return {
|
|
3174
|
-
...source,
|
|
3175
|
-
id,
|
|
3176
|
-
name,
|
|
3177
|
-
key: String(node?.key || id),
|
|
3178
|
-
title: String(node?.title || name),
|
|
3179
|
-
hasChildren,
|
|
3180
|
-
isLeaf: typeof node?.isLeaf === "boolean" ? node.isLeaf : !hasChildren,
|
|
3181
|
-
children
|
|
3182
|
-
};
|
|
3183
|
-
}
|
|
3184
|
-
function flattenDepartments(nodes) {
|
|
3185
|
-
const result = [];
|
|
3186
|
-
const walk = (items) => {
|
|
3187
|
-
for (const node of items) {
|
|
3188
|
-
const id = getDepartmentId(node);
|
|
3189
|
-
if (id) result.push({ id, name: getDepartmentName(node), node });
|
|
3190
|
-
if (node.children?.length) walk(node.children);
|
|
3191
|
-
}
|
|
3192
|
-
};
|
|
3193
|
-
walk(nodes);
|
|
3194
|
-
return result;
|
|
3195
|
-
}
|
|
3196
|
-
|
|
3197
5702
|
// packages/sdk/src/components/fields/shared/useLazyDepartmentTree.ts
|
|
3198
|
-
import { useCallback as
|
|
5703
|
+
import { useCallback as useCallback5, useEffect as useEffect7, useMemo as useMemo9, useRef as useRef3, useState as useState8 } from "react";
|
|
3199
5704
|
var toLazyNode = (node) => {
|
|
3200
5705
|
const normalized = normalizeDepartmentNode(node);
|
|
3201
5706
|
const id = getDepartmentId(normalized);
|
|
@@ -3245,15 +5750,15 @@ function buildIndexes(nodes) {
|
|
|
3245
5750
|
return { nodeMap, parentMap, flatNodes };
|
|
3246
5751
|
}
|
|
3247
5752
|
function useLazyDepartmentTree(api, configuredTreeData) {
|
|
3248
|
-
const [treeData, setTreeDataState] =
|
|
5753
|
+
const [treeData, setTreeDataState] = useState8(
|
|
3249
5754
|
() => (configuredTreeData || []).map(toLazyNode)
|
|
3250
5755
|
);
|
|
3251
|
-
const [treeLoading, setTreeLoading] =
|
|
3252
|
-
const treeDataRef =
|
|
3253
|
-
const rootsLoadedRef =
|
|
3254
|
-
const rootPromiseRef =
|
|
3255
|
-
const childPromiseRef =
|
|
3256
|
-
const setTreeData =
|
|
5756
|
+
const [treeLoading, setTreeLoading] = useState8(false);
|
|
5757
|
+
const treeDataRef = useRef3(treeData);
|
|
5758
|
+
const rootsLoadedRef = useRef3(Boolean(configuredTreeData?.length));
|
|
5759
|
+
const rootPromiseRef = useRef3(null);
|
|
5760
|
+
const childPromiseRef = useRef3({});
|
|
5761
|
+
const setTreeData = useCallback5(
|
|
3257
5762
|
(next) => {
|
|
3258
5763
|
const resolved = typeof next === "function" ? next(treeDataRef.current) : next;
|
|
3259
5764
|
treeDataRef.current = resolved;
|
|
@@ -3262,13 +5767,13 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
3262
5767
|
},
|
|
3263
5768
|
[]
|
|
3264
5769
|
);
|
|
3265
|
-
|
|
5770
|
+
useEffect7(() => {
|
|
3266
5771
|
if (!configuredTreeData) return;
|
|
3267
5772
|
const next = configuredTreeData.map(toLazyNode);
|
|
3268
5773
|
rootsLoadedRef.current = next.length > 0;
|
|
3269
5774
|
setTreeData(next);
|
|
3270
5775
|
}, [configuredTreeData, setTreeData]);
|
|
3271
|
-
const loadRootDepartments =
|
|
5776
|
+
const loadRootDepartments = useCallback5(async () => {
|
|
3272
5777
|
if (rootsLoadedRef.current) return treeDataRef.current;
|
|
3273
5778
|
if (rootPromiseRef.current) return rootPromiseRef.current;
|
|
3274
5779
|
setTreeLoading(true);
|
|
@@ -3284,7 +5789,7 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
3284
5789
|
rootPromiseRef.current = promise;
|
|
3285
5790
|
return promise;
|
|
3286
5791
|
}, [api, setTreeData]);
|
|
3287
|
-
const loadChildren =
|
|
5792
|
+
const loadChildren = useCallback5(
|
|
3288
5793
|
async (parentId) => {
|
|
3289
5794
|
const id = String(parentId || "");
|
|
3290
5795
|
if (!id) return [];
|
|
@@ -3305,8 +5810,8 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
3305
5810
|
},
|
|
3306
5811
|
[api, setTreeData]
|
|
3307
5812
|
);
|
|
3308
|
-
const indexes =
|
|
3309
|
-
|
|
5813
|
+
const indexes = useMemo9(() => buildIndexes(treeData), [treeData]);
|
|
5814
|
+
useEffect7(() => {
|
|
3310
5815
|
void loadRootDepartments();
|
|
3311
5816
|
}, [loadRootDepartments]);
|
|
3312
5817
|
return {
|
|
@@ -3319,7 +5824,7 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
3319
5824
|
}
|
|
3320
5825
|
|
|
3321
5826
|
// packages/sdk/src/components/fields/shared/UserPicker.tsx
|
|
3322
|
-
import { jsx as
|
|
5827
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3323
5828
|
var DEFAULT_MEMBER_PAGE_SIZE = 10;
|
|
3324
5829
|
var getMobileComponent = (name) => {
|
|
3325
5830
|
try {
|
|
@@ -3351,24 +5856,24 @@ function UserPickerPanel({
|
|
|
3351
5856
|
flatNodes,
|
|
3352
5857
|
loadChildren
|
|
3353
5858
|
} = useLazyDepartmentTree(api, treeData);
|
|
3354
|
-
const [departmentKeyword, setDepartmentKeyword] =
|
|
3355
|
-
const [memberKeyword, setMemberKeyword] =
|
|
3356
|
-
const [mobileKeyword, setMobileKeyword] =
|
|
3357
|
-
const [currentDeptId, setCurrentDeptId] =
|
|
3358
|
-
const [expandedKeys, setExpandedKeys] =
|
|
3359
|
-
const [members, setMembers] =
|
|
3360
|
-
const [memberPage, setMemberPage] =
|
|
3361
|
-
const [memberPageSize, setMemberPageSize] =
|
|
3362
|
-
const [memberTotal, setMemberTotal] =
|
|
3363
|
-
const [memberReloadKey, setMemberReloadKey] =
|
|
3364
|
-
const [loading, setLoading] =
|
|
3365
|
-
const [selected, setSelected] =
|
|
5859
|
+
const [departmentKeyword, setDepartmentKeyword] = useState9("");
|
|
5860
|
+
const [memberKeyword, setMemberKeyword] = useState9("");
|
|
5861
|
+
const [mobileKeyword, setMobileKeyword] = useState9("");
|
|
5862
|
+
const [currentDeptId, setCurrentDeptId] = useState9("");
|
|
5863
|
+
const [expandedKeys, setExpandedKeys] = useState9([]);
|
|
5864
|
+
const [members, setMembers] = useState9(() => normalizeUsers(dataSource));
|
|
5865
|
+
const [memberPage, setMemberPage] = useState9(1);
|
|
5866
|
+
const [memberPageSize, setMemberPageSize] = useState9(DEFAULT_MEMBER_PAGE_SIZE);
|
|
5867
|
+
const [memberTotal, setMemberTotal] = useState9(() => normalizeUsers(dataSource).length);
|
|
5868
|
+
const [memberReloadKey, setMemberReloadKey] = useState9(0);
|
|
5869
|
+
const [loading, setLoading] = useState9(false);
|
|
5870
|
+
const [selected, setSelected] = useState9(() => normalizeUsers(value));
|
|
3366
5871
|
const selectedIds = selected.map(getUserId);
|
|
3367
5872
|
const MobileSearchBar = getMobileComponent("SearchBar");
|
|
3368
5873
|
const activeMemberKeyword = (mobile ? mobileKeyword : memberKeyword).trim();
|
|
3369
|
-
const staticUsers =
|
|
5874
|
+
const staticUsers = useMemo10(() => normalizeUsers(dataSource), [dataSource]);
|
|
3370
5875
|
const hasStaticUserSource = staticUsers.length > 0;
|
|
3371
|
-
|
|
5876
|
+
useEffect8(() => {
|
|
3372
5877
|
if (mobile) return;
|
|
3373
5878
|
if (currentDeptId || deptTreeData.length === 0) return;
|
|
3374
5879
|
setExpandedKeys(deptTreeData.map((node) => getDepartmentId(node)));
|
|
@@ -3376,17 +5881,17 @@ function UserPickerPanel({
|
|
|
3376
5881
|
setCurrentDeptId(getDepartmentId(deptTreeData[0]));
|
|
3377
5882
|
}
|
|
3378
5883
|
}, [currentDeptId, deptTreeData, loadAllWhenNoDepartment, mobile]);
|
|
3379
|
-
|
|
5884
|
+
useEffect8(() => {
|
|
3380
5885
|
setMemberPage(1);
|
|
3381
5886
|
}, [activeMemberKeyword, currentDeptId, dataSource, mobile]);
|
|
3382
|
-
const handleDepartmentSelect =
|
|
5887
|
+
const handleDepartmentSelect = useCallback6((deptId) => {
|
|
3383
5888
|
const nextDeptId = String(deptId || "");
|
|
3384
5889
|
setCurrentDeptId(nextDeptId);
|
|
3385
5890
|
setMemberKeyword("");
|
|
3386
5891
|
setMemberPage(1);
|
|
3387
5892
|
setMemberReloadKey((current) => current + 1);
|
|
3388
5893
|
}, []);
|
|
3389
|
-
|
|
5894
|
+
useEffect8(() => {
|
|
3390
5895
|
let active = true;
|
|
3391
5896
|
const keyword = activeMemberKeyword;
|
|
3392
5897
|
if (hasStaticUserSource) {
|
|
@@ -3459,7 +5964,7 @@ function UserPickerPanel({
|
|
|
3459
5964
|
memberReloadKey,
|
|
3460
5965
|
staticUsers
|
|
3461
5966
|
]);
|
|
3462
|
-
const currentPath =
|
|
5967
|
+
const currentPath = useMemo10(() => {
|
|
3463
5968
|
if (!currentDeptId) return [];
|
|
3464
5969
|
const path = [];
|
|
3465
5970
|
let cursor = currentDeptId;
|
|
@@ -3471,7 +5976,7 @@ function UserPickerPanel({
|
|
|
3471
5976
|
}
|
|
3472
5977
|
return path;
|
|
3473
5978
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
3474
|
-
const mobileDepartments =
|
|
5979
|
+
const mobileDepartments = useMemo10(() => {
|
|
3475
5980
|
const keyword = mobileKeyword.trim().toLowerCase();
|
|
3476
5981
|
if (keyword) {
|
|
3477
5982
|
return flatNodes.filter((item) => item.name.toLowerCase().includes(keyword)).map((item) => item.node);
|
|
@@ -3493,19 +5998,19 @@ function UserPickerPanel({
|
|
|
3493
5998
|
}
|
|
3494
5999
|
setSelected(checked ? [normalized] : []);
|
|
3495
6000
|
};
|
|
3496
|
-
const renderSelected = () => /* @__PURE__ */
|
|
3497
|
-
/* @__PURE__ */
|
|
3498
|
-
/* @__PURE__ */
|
|
6001
|
+
const renderSelected = () => /* @__PURE__ */ jsxs9("div", { className: "sy-user-picker-selected", children: [
|
|
6002
|
+
/* @__PURE__ */ jsxs9("div", { className: "sy-org-picker-selected-head", children: [
|
|
6003
|
+
/* @__PURE__ */ jsxs9("span", { children: [
|
|
3499
6004
|
"\u5DF2\u9009 ",
|
|
3500
6005
|
selected.length,
|
|
3501
6006
|
" \u4EBA"
|
|
3502
6007
|
] }),
|
|
3503
|
-
/* @__PURE__ */
|
|
6008
|
+
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => setSelected([]), disabled: !selected.length, children: "\u6E05\u7A7A" })
|
|
3504
6009
|
] }),
|
|
3505
|
-
selected.length ? /* @__PURE__ */
|
|
6010
|
+
selected.length ? /* @__PURE__ */ jsx11("div", { className: "sy-org-picker-tags", children: selected.map((item) => /* @__PURE__ */ jsx11(Tag2, { closable: true, onClose: () => toggleUser(item, false), children: getUserName(item) }, getUserId(item))) }) : /* @__PURE__ */ jsx11(Empty4, { image: Empty4.PRESENTED_IMAGE_SIMPLE, description: "\u6682\u65E0\u9009\u62E9" })
|
|
3506
6011
|
] });
|
|
3507
|
-
const renderMemberList = () => /* @__PURE__ */
|
|
3508
|
-
/* @__PURE__ */
|
|
6012
|
+
const renderMemberList = () => /* @__PURE__ */ jsx11("div", { className: "sy-user-picker-member-panel", children: /* @__PURE__ */ jsxs9(Spin4, { spinning: loading, wrapperClassName: "sy-user-picker-member-spin", children: [
|
|
6013
|
+
/* @__PURE__ */ jsx11("div", { className: "sy-user-picker-list", children: /* @__PURE__ */ jsx11(
|
|
3509
6014
|
List,
|
|
3510
6015
|
{
|
|
3511
6016
|
dataSource: members,
|
|
@@ -3513,27 +6018,27 @@ function UserPickerPanel({
|
|
|
3513
6018
|
renderItem: (user) => {
|
|
3514
6019
|
const id = getUserId(user);
|
|
3515
6020
|
const checked = selectedIds.includes(id);
|
|
3516
|
-
return /* @__PURE__ */
|
|
3517
|
-
/* @__PURE__ */
|
|
6021
|
+
return /* @__PURE__ */ jsx11(List.Item, { children: /* @__PURE__ */ jsxs9("label", { className: "sy-user-picker-row", children: [
|
|
6022
|
+
/* @__PURE__ */ jsx11(
|
|
3518
6023
|
Checkbox,
|
|
3519
6024
|
{
|
|
3520
6025
|
checked,
|
|
3521
6026
|
onChange: (event) => toggleUser(user, event.target.checked)
|
|
3522
6027
|
}
|
|
3523
6028
|
),
|
|
3524
|
-
/* @__PURE__ */
|
|
3525
|
-
/* @__PURE__ */
|
|
6029
|
+
/* @__PURE__ */ jsx11(Avatar, { size: 36, src: user.avatar, icon: !user.avatar && /* @__PURE__ */ jsx11(UserOutlined3, {}) }),
|
|
6030
|
+
/* @__PURE__ */ jsx11("span", { children: getUserName(user) })
|
|
3526
6031
|
] }) }, id);
|
|
3527
6032
|
}
|
|
3528
6033
|
}
|
|
3529
6034
|
) }),
|
|
3530
|
-
/* @__PURE__ */
|
|
3531
|
-
/* @__PURE__ */
|
|
6035
|
+
/* @__PURE__ */ jsxs9("div", { className: "sy-user-picker-pagination", children: [
|
|
6036
|
+
/* @__PURE__ */ jsxs9("span", { children: [
|
|
3532
6037
|
"\u5171 ",
|
|
3533
6038
|
memberTotal,
|
|
3534
6039
|
" \u4EBA"
|
|
3535
6040
|
] }),
|
|
3536
|
-
/* @__PURE__ */
|
|
6041
|
+
/* @__PURE__ */ jsx11(
|
|
3537
6042
|
Pagination,
|
|
3538
6043
|
{
|
|
3539
6044
|
size: "small",
|
|
@@ -3551,35 +6056,35 @@ function UserPickerPanel({
|
|
|
3551
6056
|
] })
|
|
3552
6057
|
] }) });
|
|
3553
6058
|
if (mobile) {
|
|
3554
|
-
return /* @__PURE__ */
|
|
3555
|
-
/* @__PURE__ */
|
|
3556
|
-
/* @__PURE__ */
|
|
3557
|
-
/* @__PURE__ */
|
|
3558
|
-
/* @__PURE__ */
|
|
6059
|
+
return /* @__PURE__ */ jsxs9("div", { className: "sy-user-picker sy-user-picker-mobile", children: [
|
|
6060
|
+
/* @__PURE__ */ jsxs9("div", { className: "sy-org-picker-mobile-head", children: [
|
|
6061
|
+
/* @__PURE__ */ jsx11("button", { type: "button", onClick: onCancel, children: "\u53D6\u6D88" }),
|
|
6062
|
+
/* @__PURE__ */ jsx11("strong", { children: "\u9009\u62E9\u6210\u5458" }),
|
|
6063
|
+
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => onConfirm(selected), children: "\u786E\u5B9A" })
|
|
3559
6064
|
] }),
|
|
3560
|
-
MobileSearchBar ? /* @__PURE__ */
|
|
6065
|
+
MobileSearchBar ? /* @__PURE__ */ jsx11(
|
|
3561
6066
|
MobileSearchBar,
|
|
3562
6067
|
{
|
|
3563
6068
|
placeholder: "\u641C\u7D22\u90E8\u95E8\u6216\u6210\u5458",
|
|
3564
6069
|
value: mobileKeyword,
|
|
3565
6070
|
onChange: setMobileKeyword
|
|
3566
6071
|
}
|
|
3567
|
-
) : /* @__PURE__ */
|
|
3568
|
-
/* @__PURE__ */
|
|
3569
|
-
/* @__PURE__ */
|
|
3570
|
-
currentPath.map((item) => /* @__PURE__ */
|
|
6072
|
+
) : /* @__PURE__ */ jsx11("input", { value: mobileKeyword, onChange: (event) => setMobileKeyword(event.target.value) }),
|
|
6073
|
+
/* @__PURE__ */ jsxs9("div", { className: "sy-org-picker-breadcrumb", children: [
|
|
6074
|
+
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => handleDepartmentSelect(""), children: "\u901A\u8BAF\u5F55" }),
|
|
6075
|
+
currentPath.map((item) => /* @__PURE__ */ jsxs9("button", { type: "button", onClick: () => handleDepartmentSelect(item.id), children: [
|
|
3571
6076
|
"/ ",
|
|
3572
6077
|
item.name
|
|
3573
6078
|
] }, item.id))
|
|
3574
6079
|
] }),
|
|
3575
|
-
/* @__PURE__ */
|
|
6080
|
+
/* @__PURE__ */ jsx11(Spin4, { spinning: treeLoading, children: /* @__PURE__ */ jsx11(
|
|
3576
6081
|
List,
|
|
3577
6082
|
{
|
|
3578
6083
|
dataSource: mobileDepartments,
|
|
3579
6084
|
locale: { emptyText: null },
|
|
3580
6085
|
renderItem: (node) => {
|
|
3581
6086
|
const id = getDepartmentId(node);
|
|
3582
|
-
return /* @__PURE__ */
|
|
6087
|
+
return /* @__PURE__ */ jsx11(
|
|
3583
6088
|
List.Item,
|
|
3584
6089
|
{
|
|
3585
6090
|
onClick: async () => {
|
|
@@ -3587,7 +6092,7 @@ function UserPickerPanel({
|
|
|
3587
6092
|
handleDepartmentSelect(id);
|
|
3588
6093
|
setMobileKeyword("");
|
|
3589
6094
|
},
|
|
3590
|
-
children: /* @__PURE__ */
|
|
6095
|
+
children: /* @__PURE__ */ jsx11(List.Item.Meta, { avatar: /* @__PURE__ */ jsx11(TeamOutlined, {}), title: getDepartmentName(node) })
|
|
3591
6096
|
},
|
|
3592
6097
|
id
|
|
3593
6098
|
);
|
|
@@ -3602,20 +6107,20 @@ function UserPickerPanel({
|
|
|
3602
6107
|
const filteredTreeData = lowerDepartmentKeyword ? deptTreeData.filter(
|
|
3603
6108
|
(node) => getDepartmentName(node).toLowerCase().includes(lowerDepartmentKeyword)
|
|
3604
6109
|
) : deptTreeData;
|
|
3605
|
-
return /* @__PURE__ */
|
|
3606
|
-
/* @__PURE__ */
|
|
3607
|
-
/* @__PURE__ */
|
|
3608
|
-
/* @__PURE__ */
|
|
6110
|
+
return /* @__PURE__ */ jsxs9("div", { className: "sy-user-picker", children: [
|
|
6111
|
+
/* @__PURE__ */ jsxs9("div", { className: "sy-user-picker-main", children: [
|
|
6112
|
+
/* @__PURE__ */ jsxs9("div", { className: "sy-user-picker-depts", children: [
|
|
6113
|
+
/* @__PURE__ */ jsx11(
|
|
3609
6114
|
Input,
|
|
3610
6115
|
{
|
|
3611
6116
|
allowClear: true,
|
|
3612
|
-
prefix: /* @__PURE__ */
|
|
6117
|
+
prefix: /* @__PURE__ */ jsx11(SearchOutlined, {}),
|
|
3613
6118
|
placeholder: "\u641C\u7D22\u90E8\u95E8",
|
|
3614
6119
|
value: departmentKeyword,
|
|
3615
6120
|
onChange: (event) => setDepartmentKeyword(event.target.value)
|
|
3616
6121
|
}
|
|
3617
6122
|
),
|
|
3618
|
-
/* @__PURE__ */
|
|
6123
|
+
/* @__PURE__ */ jsx11(Spin4, { spinning: treeLoading, children: /* @__PURE__ */ jsx11(
|
|
3619
6124
|
Tree,
|
|
3620
6125
|
{
|
|
3621
6126
|
selectedKeys: currentDeptId ? [currentDeptId] : [],
|
|
@@ -3628,12 +6133,12 @@ function UserPickerPanel({
|
|
|
3628
6133
|
}
|
|
3629
6134
|
) })
|
|
3630
6135
|
] }),
|
|
3631
|
-
/* @__PURE__ */
|
|
3632
|
-
displaySearch && /* @__PURE__ */
|
|
6136
|
+
/* @__PURE__ */ jsxs9("div", { className: "sy-user-picker-members", children: [
|
|
6137
|
+
displaySearch && /* @__PURE__ */ jsx11(
|
|
3633
6138
|
Input,
|
|
3634
6139
|
{
|
|
3635
6140
|
allowClear: true,
|
|
3636
|
-
prefix: /* @__PURE__ */
|
|
6141
|
+
prefix: /* @__PURE__ */ jsx11(SearchOutlined, {}),
|
|
3637
6142
|
placeholder: "\u641C\u7D22\u6210\u5458",
|
|
3638
6143
|
value: memberKeyword,
|
|
3639
6144
|
onChange: (event) => setMemberKeyword(event.target.value)
|
|
@@ -3643,9 +6148,9 @@ function UserPickerPanel({
|
|
|
3643
6148
|
] }),
|
|
3644
6149
|
renderSelected()
|
|
3645
6150
|
] }),
|
|
3646
|
-
/* @__PURE__ */
|
|
3647
|
-
/* @__PURE__ */
|
|
3648
|
-
/* @__PURE__ */
|
|
6151
|
+
/* @__PURE__ */ jsx11("div", { className: "sy-org-picker-footer", children: /* @__PURE__ */ jsxs9(Space, { children: [
|
|
6152
|
+
/* @__PURE__ */ jsx11(Button6, { onClick: onCancel, children: "\u53D6\u6D88" }),
|
|
6153
|
+
/* @__PURE__ */ jsx11(Button6, { type: "primary", onClick: () => onConfirm(selected), children: "\u786E\u5B9A" })
|
|
3649
6154
|
] }) })
|
|
3650
6155
|
] });
|
|
3651
6156
|
}
|
|
@@ -3660,7 +6165,7 @@ function UserPicker({
|
|
|
3660
6165
|
onOpenChange(false);
|
|
3661
6166
|
onCancel();
|
|
3662
6167
|
};
|
|
3663
|
-
const panel = /* @__PURE__ */
|
|
6168
|
+
const panel = /* @__PURE__ */ jsx11(
|
|
3664
6169
|
UserPickerPanel,
|
|
3665
6170
|
{
|
|
3666
6171
|
...panelProps,
|
|
@@ -3675,7 +6180,7 @@ function UserPicker({
|
|
|
3675
6180
|
if (mobile) {
|
|
3676
6181
|
const MobilePopup = getMobileComponent("Popup");
|
|
3677
6182
|
if (!MobilePopup) return open ? panel : null;
|
|
3678
|
-
return /* @__PURE__ */
|
|
6183
|
+
return /* @__PURE__ */ jsx11(
|
|
3679
6184
|
MobilePopup,
|
|
3680
6185
|
{
|
|
3681
6186
|
visible: open,
|
|
@@ -3686,8 +6191,8 @@ function UserPicker({
|
|
|
3686
6191
|
}
|
|
3687
6192
|
);
|
|
3688
6193
|
}
|
|
3689
|
-
return /* @__PURE__ */
|
|
3690
|
-
|
|
6194
|
+
return /* @__PURE__ */ jsx11(
|
|
6195
|
+
Modal3,
|
|
3691
6196
|
{
|
|
3692
6197
|
title: "\u9009\u62E9\u6210\u5458",
|
|
3693
6198
|
open,
|
|
@@ -3701,7 +6206,7 @@ function UserPicker({
|
|
|
3701
6206
|
}
|
|
3702
6207
|
|
|
3703
6208
|
// packages/sdk/src/components/modules/InitiatorApproverSelector.tsx
|
|
3704
|
-
import { jsx as
|
|
6209
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3705
6210
|
var scopeText = {
|
|
3706
6211
|
all: "\u5168\u90E8\u6210\u5458",
|
|
3707
6212
|
members: "\u6307\u5B9A\u6210\u5458",
|
|
@@ -3735,19 +6240,19 @@ var RequirementSelect = ({
|
|
|
3735
6240
|
selectedUsers,
|
|
3736
6241
|
onChange
|
|
3737
6242
|
}) => {
|
|
3738
|
-
const [pickerOpen, setPickerOpen] =
|
|
3739
|
-
const initialCandidates =
|
|
6243
|
+
const [pickerOpen, setPickerOpen] = useState10(false);
|
|
6244
|
+
const initialCandidates = useMemo11(
|
|
3740
6245
|
() => (requirement.candidateUsers || []).map(normalizeCandidate).filter(Boolean),
|
|
3741
6246
|
[requirement.candidateUsers]
|
|
3742
6247
|
);
|
|
3743
|
-
const [optionsSource, setOptionsSource] =
|
|
3744
|
-
const [loading, setLoading] =
|
|
3745
|
-
|
|
6248
|
+
const [optionsSource, setOptionsSource] = useState10(initialCandidates);
|
|
6249
|
+
const [loading, setLoading] = useState10(false);
|
|
6250
|
+
useEffect9(() => {
|
|
3746
6251
|
setOptionsSource(
|
|
3747
6252
|
(current) => mergeUsers(initialCandidates, mergeUsers(current, selectedUsers))
|
|
3748
6253
|
);
|
|
3749
6254
|
}, [initialCandidates, selectedUsers]);
|
|
3750
|
-
const loadCandidates =
|
|
6255
|
+
const loadCandidates = useCallback7(
|
|
3751
6256
|
async (keyword) => {
|
|
3752
6257
|
setLoading(true);
|
|
3753
6258
|
try {
|
|
@@ -3785,12 +6290,12 @@ var RequirementSelect = ({
|
|
|
3785
6290
|
},
|
|
3786
6291
|
[api, appType, formUuid, initialCandidates.length, requirement.nodeId, requirement.scope]
|
|
3787
6292
|
);
|
|
3788
|
-
|
|
6293
|
+
useEffect9(() => {
|
|
3789
6294
|
if (requirement.scope !== "all" && open && formUuid && appType && requirement.nodeId) {
|
|
3790
6295
|
void loadCandidates();
|
|
3791
6296
|
}
|
|
3792
6297
|
}, [appType, formUuid, loadCandidates, open, requirement.nodeId, requirement.scope]);
|
|
3793
|
-
const options =
|
|
6298
|
+
const options = useMemo11(
|
|
3794
6299
|
() => optionsSource.map((user) => ({
|
|
3795
6300
|
value: user.id,
|
|
3796
6301
|
label: getUserLabel(user)
|
|
@@ -3798,19 +6303,19 @@ var RequirementSelect = ({
|
|
|
3798
6303
|
[optionsSource]
|
|
3799
6304
|
);
|
|
3800
6305
|
if (requirement.scope === "all") {
|
|
3801
|
-
return /* @__PURE__ */
|
|
3802
|
-
/* @__PURE__ */
|
|
3803
|
-
/* @__PURE__ */
|
|
3804
|
-
/* @__PURE__ */
|
|
3805
|
-
/* @__PURE__ */
|
|
6306
|
+
return /* @__PURE__ */ jsxs10("div", { className: "rounded-lg border border-ant-border-secondary bg-ant-bg-container p-3", children: [
|
|
6307
|
+
/* @__PURE__ */ jsxs10("div", { className: "mb-2 flex items-start justify-between gap-3", children: [
|
|
6308
|
+
/* @__PURE__ */ jsxs10("div", { children: [
|
|
6309
|
+
/* @__PURE__ */ jsx12(Typography4.Text, { strong: true, children: requirement.nodeName }),
|
|
6310
|
+
/* @__PURE__ */ jsxs10("div", { className: "mt-1 text-xs text-ant-color-text-tertiary", children: [
|
|
3806
6311
|
"\u9009\u62E9\u8303\u56F4\uFF1A",
|
|
3807
6312
|
scopeText[requirement.scope] || "\u5168\u90E8\u6210\u5458"
|
|
3808
6313
|
] })
|
|
3809
6314
|
] }),
|
|
3810
|
-
/* @__PURE__ */
|
|
6315
|
+
/* @__PURE__ */ jsx12(Button7, { onClick: () => setPickerOpen(true), children: selectedUsers.length > 0 ? "\u91CD\u65B0\u9009\u62E9\u6210\u5458" : "\u9009\u62E9\u6210\u5458" })
|
|
3811
6316
|
] }),
|
|
3812
|
-
selectedUsers.length > 0 ? /* @__PURE__ */
|
|
3813
|
-
/* @__PURE__ */
|
|
6317
|
+
selectedUsers.length > 0 ? /* @__PURE__ */ jsx12(Space2, { size: [4, 4], wrap: true, className: "mt-2", children: selectedUsers.map((user) => /* @__PURE__ */ jsx12(Tag3, { children: getUserLabel(user) }, user.id)) }) : /* @__PURE__ */ jsx12(Empty5, { image: Empty5.PRESENTED_IMAGE_SIMPLE, description: "\u8BF7\u4ECE\u7EC4\u7EC7\u67B6\u6784\u9009\u62E9\u6210\u5458" }),
|
|
6318
|
+
/* @__PURE__ */ jsx12(
|
|
3814
6319
|
UserPicker,
|
|
3815
6320
|
{
|
|
3816
6321
|
api,
|
|
@@ -3830,15 +6335,15 @@ var RequirementSelect = ({
|
|
|
3830
6335
|
)
|
|
3831
6336
|
] });
|
|
3832
6337
|
}
|
|
3833
|
-
return /* @__PURE__ */
|
|
3834
|
-
/* @__PURE__ */
|
|
3835
|
-
/* @__PURE__ */
|
|
3836
|
-
/* @__PURE__ */
|
|
6338
|
+
return /* @__PURE__ */ jsxs10("div", { className: "rounded-lg border border-ant-border-secondary bg-ant-bg-container p-3", children: [
|
|
6339
|
+
/* @__PURE__ */ jsxs10("div", { className: "mb-2", children: [
|
|
6340
|
+
/* @__PURE__ */ jsx12(Typography4.Text, { strong: true, children: requirement.nodeName }),
|
|
6341
|
+
/* @__PURE__ */ jsxs10("div", { className: "mt-1 text-xs text-ant-color-text-tertiary", children: [
|
|
3837
6342
|
"\u9009\u62E9\u8303\u56F4\uFF1A",
|
|
3838
6343
|
scopeText[requirement.scope] || "\u5168\u90E8\u6210\u5458"
|
|
3839
6344
|
] })
|
|
3840
6345
|
] }),
|
|
3841
|
-
/* @__PURE__ */
|
|
6346
|
+
/* @__PURE__ */ jsx12(
|
|
3842
6347
|
Select,
|
|
3843
6348
|
{
|
|
3844
6349
|
mode: "multiple",
|
|
@@ -3850,7 +6355,7 @@ var RequirementSelect = ({
|
|
|
3850
6355
|
loading,
|
|
3851
6356
|
value: selectedUsers.map((user) => user.id),
|
|
3852
6357
|
options,
|
|
3853
|
-
notFoundContent: loading ? "\u52A0\u8F7D\u4E2D..." : /* @__PURE__ */
|
|
6358
|
+
notFoundContent: loading ? "\u52A0\u8F7D\u4E2D..." : /* @__PURE__ */ jsx12(Empty5, { image: Empty5.PRESENTED_IMAGE_SIMPLE }),
|
|
3854
6359
|
onSearch: (keyword) => {
|
|
3855
6360
|
void loadCandidates(keyword);
|
|
3856
6361
|
},
|
|
@@ -3862,7 +6367,7 @@ var RequirementSelect = ({
|
|
|
3862
6367
|
}
|
|
3863
6368
|
}
|
|
3864
6369
|
),
|
|
3865
|
-
selectedUsers.length > 0 ? /* @__PURE__ */
|
|
6370
|
+
selectedUsers.length > 0 ? /* @__PURE__ */ jsx12(Space2, { size: [4, 4], wrap: true, className: "mt-2", children: selectedUsers.map((user) => /* @__PURE__ */ jsx12(Tag3, { children: getUserLabel(user) }, user.id)) }) : null
|
|
3866
6371
|
] });
|
|
3867
6372
|
};
|
|
3868
6373
|
var InitiatorApproverSelector = ({
|
|
@@ -3875,9 +6380,9 @@ var InitiatorApproverSelector = ({
|
|
|
3875
6380
|
onOk,
|
|
3876
6381
|
onCancel
|
|
3877
6382
|
}) => {
|
|
3878
|
-
const [selected, setSelected] =
|
|
3879
|
-
const wasOpenRef =
|
|
3880
|
-
|
|
6383
|
+
const [selected, setSelected] = useState10({});
|
|
6384
|
+
const wasOpenRef = useRef4(false);
|
|
6385
|
+
useEffect9(() => {
|
|
3881
6386
|
if (open && !wasOpenRef.current) {
|
|
3882
6387
|
setSelected(value || EMPTY_SELECTED_MAP);
|
|
3883
6388
|
}
|
|
@@ -3886,8 +6391,8 @@ var InitiatorApproverSelector = ({
|
|
|
3886
6391
|
const missingNodes = requirements.filter(
|
|
3887
6392
|
(requirement) => !(selected[requirement.nodeId] || []).length
|
|
3888
6393
|
);
|
|
3889
|
-
return /* @__PURE__ */
|
|
3890
|
-
|
|
6394
|
+
return /* @__PURE__ */ jsx12(
|
|
6395
|
+
Modal4,
|
|
3891
6396
|
{
|
|
3892
6397
|
getContainer: false,
|
|
3893
6398
|
title: "\u9009\u62E9\u5BA1\u6279\u4EBA",
|
|
@@ -3904,7 +6409,7 @@ var InitiatorApproverSelector = ({
|
|
|
3904
6409
|
onOk(selected);
|
|
3905
6410
|
},
|
|
3906
6411
|
destroyOnHidden: true,
|
|
3907
|
-
children: /* @__PURE__ */
|
|
6412
|
+
children: /* @__PURE__ */ jsx12(Space2, { direction: "vertical", size: 12, className: "w-full", children: requirements.map((requirement) => /* @__PURE__ */ jsx12(
|
|
3908
6413
|
RequirementSelect,
|
|
3909
6414
|
{
|
|
3910
6415
|
open,
|
|
@@ -3922,7 +6427,7 @@ var InitiatorApproverSelector = ({
|
|
|
3922
6427
|
};
|
|
3923
6428
|
|
|
3924
6429
|
// packages/sdk/src/runtime/react/workflow.tsx
|
|
3925
|
-
import { Fragment as
|
|
6430
|
+
import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3926
6431
|
var getError = (error) => error instanceof Error ? error : new Error(String(error || "\u6D41\u7A0B\u80FD\u529B\u89E3\u6790\u5931\u8D25"));
|
|
3927
6432
|
var normalizeCapabilities = (value) => {
|
|
3928
6433
|
const raw = value || {};
|
|
@@ -3935,20 +6440,20 @@ var normalizeCapabilities = (value) => {
|
|
|
3935
6440
|
function useProcessCapabilities(options) {
|
|
3936
6441
|
const { enabled = true, refreshKey, onError, ...params } = options;
|
|
3937
6442
|
const sdk = usePageSdk();
|
|
3938
|
-
const [capabilities, setCapabilities] =
|
|
6443
|
+
const [capabilities, setCapabilities] = useState11(
|
|
3939
6444
|
null
|
|
3940
6445
|
);
|
|
3941
|
-
const [loading, setLoading] =
|
|
3942
|
-
const [error, setError] =
|
|
3943
|
-
const mountedRef =
|
|
6446
|
+
const [loading, setLoading] = useState11(false);
|
|
6447
|
+
const [error, setError] = useState11(null);
|
|
6448
|
+
const mountedRef = useRef5(true);
|
|
3944
6449
|
const paramsKey = JSON.stringify({ ...params, refreshKey });
|
|
3945
|
-
|
|
6450
|
+
useEffect10(() => {
|
|
3946
6451
|
mountedRef.current = true;
|
|
3947
6452
|
return () => {
|
|
3948
6453
|
mountedRef.current = false;
|
|
3949
6454
|
};
|
|
3950
6455
|
}, []);
|
|
3951
|
-
const refresh =
|
|
6456
|
+
const refresh = useCallback8(async () => {
|
|
3952
6457
|
if (!enabled) return capabilities;
|
|
3953
6458
|
setLoading(true);
|
|
3954
6459
|
setError(null);
|
|
@@ -3974,7 +6479,7 @@ function useProcessCapabilities(options) {
|
|
|
3974
6479
|
}
|
|
3975
6480
|
}
|
|
3976
6481
|
}, [capabilities, enabled, onError, paramsKey, sdk]);
|
|
3977
|
-
|
|
6482
|
+
useEffect10(() => {
|
|
3978
6483
|
if (!enabled) return;
|
|
3979
6484
|
void refresh();
|
|
3980
6485
|
}, [enabled, paramsKey, refresh]);
|
|
@@ -3999,8 +6504,8 @@ var requireValue = (value, message3) => {
|
|
|
3999
6504
|
function useProcessActions(options) {
|
|
4000
6505
|
const { capabilities, formUuid, appType, getFormValues, onActionComplete } = options;
|
|
4001
6506
|
const sdk = usePageSdk();
|
|
4002
|
-
const [loadingAction, setLoadingAction] =
|
|
4003
|
-
const buildUpdateFormDataJson =
|
|
6507
|
+
const [loadingAction, setLoadingAction] = useState11(null);
|
|
6508
|
+
const buildUpdateFormDataJson = useCallback8(
|
|
4004
6509
|
(input) => {
|
|
4005
6510
|
if (input?.updateFormDataJson !== void 0) return input.updateFormDataJson;
|
|
4006
6511
|
const values = getFormValues?.();
|
|
@@ -4008,7 +6513,7 @@ function useProcessActions(options) {
|
|
|
4008
6513
|
},
|
|
4009
6514
|
[getFormValues]
|
|
4010
6515
|
);
|
|
4011
|
-
const executeOperation =
|
|
6516
|
+
const executeOperation = useCallback8(
|
|
4012
6517
|
async (operation, input = {}) => {
|
|
4013
6518
|
if (!operation.enabled) return false;
|
|
4014
6519
|
setLoadingAction(operation.key);
|
|
@@ -4118,7 +6623,7 @@ function useProcessActions(options) {
|
|
|
4118
6623
|
sdk
|
|
4119
6624
|
]
|
|
4120
6625
|
);
|
|
4121
|
-
const execute =
|
|
6626
|
+
const execute = useCallback8(
|
|
4122
6627
|
async (action, input) => {
|
|
4123
6628
|
const operation = (capabilities?.operations || []).find(
|
|
4124
6629
|
(item) => item.key === action
|
|
@@ -4161,12 +6666,12 @@ var actionTone = (key) => {
|
|
|
4161
6666
|
return "default";
|
|
4162
6667
|
};
|
|
4163
6668
|
var actionIcon = (key) => {
|
|
4164
|
-
if (key === "startProcess" || key === "approve") return /* @__PURE__ */
|
|
4165
|
-
if (key === "reject") return /* @__PURE__ */
|
|
4166
|
-
if (key === "transfer" || key === "adminTransfer") return /* @__PURE__ */
|
|
4167
|
-
if (key === "return" || key === "withdraw") return /* @__PURE__ */
|
|
4168
|
-
if (key === "save") return /* @__PURE__ */
|
|
4169
|
-
if (key === "retryException" || key === "callback") return /* @__PURE__ */
|
|
6669
|
+
if (key === "startProcess" || key === "approve") return /* @__PURE__ */ jsx13(CheckOutlined, {});
|
|
6670
|
+
if (key === "reject") return /* @__PURE__ */ jsx13(CloseOutlined3, {});
|
|
6671
|
+
if (key === "transfer" || key === "adminTransfer") return /* @__PURE__ */ jsx13(SwapOutlined, {});
|
|
6672
|
+
if (key === "return" || key === "withdraw") return /* @__PURE__ */ jsx13(RollbackOutlined2, {});
|
|
6673
|
+
if (key === "save") return /* @__PURE__ */ jsx13(SaveOutlined, {});
|
|
6674
|
+
if (key === "retryException" || key === "callback") return /* @__PURE__ */ jsx13(ReloadOutlined4, {});
|
|
4170
6675
|
return void 0;
|
|
4171
6676
|
};
|
|
4172
6677
|
var getModalTitle = (key) => {
|
|
@@ -4193,7 +6698,7 @@ var ProcessActionBar = ({
|
|
|
4193
6698
|
position = "sticky"
|
|
4194
6699
|
}) => {
|
|
4195
6700
|
const [form] = Form.useForm();
|
|
4196
|
-
const [activeOperation, setActiveOperation] =
|
|
6701
|
+
const [activeOperation, setActiveOperation] = useState11(null);
|
|
4197
6702
|
const autoCapabilities = useProcessCapabilities({
|
|
4198
6703
|
...capabilityParams || {},
|
|
4199
6704
|
enabled: Boolean(capabilityParams) && capabilityParams?.enabled !== false
|
|
@@ -4228,7 +6733,7 @@ var ProcessActionBar = ({
|
|
|
4228
6733
|
}
|
|
4229
6734
|
void actions.executeOperation(operation);
|
|
4230
6735
|
};
|
|
4231
|
-
const actionConfigs =
|
|
6736
|
+
const actionConfigs = useMemo12(
|
|
4232
6737
|
() => operations.map((operation) => ({
|
|
4233
6738
|
key: operation.key,
|
|
4234
6739
|
label: operation.label || operation.key,
|
|
@@ -4260,8 +6765,8 @@ var ProcessActionBar = ({
|
|
|
4260
6765
|
label: String(node.nodeName || node.name || node.label || value)
|
|
4261
6766
|
};
|
|
4262
6767
|
});
|
|
4263
|
-
return /* @__PURE__ */
|
|
4264
|
-
/* @__PURE__ */
|
|
6768
|
+
return /* @__PURE__ */ jsxs11(Fragment4, { children: [
|
|
6769
|
+
/* @__PURE__ */ jsx13(
|
|
4265
6770
|
StickyActionBar,
|
|
4266
6771
|
{
|
|
4267
6772
|
actions: actionConfigs,
|
|
@@ -4273,8 +6778,8 @@ var ProcessActionBar = ({
|
|
|
4273
6778
|
position
|
|
4274
6779
|
}
|
|
4275
6780
|
),
|
|
4276
|
-
/* @__PURE__ */
|
|
4277
|
-
|
|
6781
|
+
/* @__PURE__ */ jsx13(
|
|
6782
|
+
Modal5,
|
|
4278
6783
|
{
|
|
4279
6784
|
getContainer: false,
|
|
4280
6785
|
title: modalKey ? getModalTitle(modalKey) : "\u6D41\u7A0B\u64CD\u4F5C",
|
|
@@ -4290,26 +6795,26 @@ var ProcessActionBar = ({
|
|
|
4290
6795
|
form.resetFields();
|
|
4291
6796
|
},
|
|
4292
6797
|
destroyOnHidden: true,
|
|
4293
|
-
children: /* @__PURE__ */
|
|
4294
|
-
(modalKey === "transfer" || modalKey === "adminTransfer") && /* @__PURE__ */
|
|
6798
|
+
children: /* @__PURE__ */ jsxs11(Form, { form, layout: "vertical", children: [
|
|
6799
|
+
(modalKey === "transfer" || modalKey === "adminTransfer") && /* @__PURE__ */ jsx13(
|
|
4295
6800
|
Form.Item,
|
|
4296
6801
|
{
|
|
4297
6802
|
name: "newAssignee",
|
|
4298
6803
|
label: "\u63A5\u6536\u4EBA",
|
|
4299
6804
|
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u63A5\u6536\u4EBA\u7528\u6237ID" }],
|
|
4300
|
-
children: /* @__PURE__ */
|
|
6805
|
+
children: /* @__PURE__ */ jsx13(Input2, { placeholder: "\u8BF7\u8F93\u5165\u7528\u6237ID" })
|
|
4301
6806
|
}
|
|
4302
6807
|
),
|
|
4303
|
-
modalKey === "return" && /* @__PURE__ */
|
|
6808
|
+
modalKey === "return" && /* @__PURE__ */ jsx13(
|
|
4304
6809
|
Form.Item,
|
|
4305
6810
|
{
|
|
4306
6811
|
name: "targetNodeId",
|
|
4307
6812
|
label: "\u9000\u56DE\u8282\u70B9",
|
|
4308
6813
|
rules: [{ required: true, message: "\u8BF7\u9009\u62E9\u9000\u56DE\u8282\u70B9" }],
|
|
4309
|
-
children: /* @__PURE__ */
|
|
6814
|
+
children: /* @__PURE__ */ jsx13(Select2, { placeholder: "\u8BF7\u9009\u62E9\u9000\u56DE\u8282\u70B9", options: returnOptions })
|
|
4310
6815
|
}
|
|
4311
6816
|
),
|
|
4312
|
-
/* @__PURE__ */
|
|
6817
|
+
/* @__PURE__ */ jsx13(
|
|
4313
6818
|
Form.Item,
|
|
4314
6819
|
{
|
|
4315
6820
|
name: modalKey === "reject" || modalKey === "resubmit" ? "comments" : "reason",
|
|
@@ -4320,7 +6825,7 @@ var ProcessActionBar = ({
|
|
|
4320
6825
|
message: "\u8BF7\u586B\u5199\u8BF4\u660E"
|
|
4321
6826
|
}
|
|
4322
6827
|
],
|
|
4323
|
-
children: /* @__PURE__ */
|
|
6828
|
+
children: /* @__PURE__ */ jsx13(Input2.TextArea, { rows: 4, maxLength: 500, showCount: true })
|
|
4324
6829
|
}
|
|
4325
6830
|
)
|
|
4326
6831
|
] })
|
|
@@ -4332,7 +6837,7 @@ var ProcessTimeline = ({
|
|
|
4332
6837
|
capabilities,
|
|
4333
6838
|
tasks,
|
|
4334
6839
|
...props
|
|
4335
|
-
}) => /* @__PURE__ */
|
|
6840
|
+
}) => /* @__PURE__ */ jsx13(
|
|
4336
6841
|
ApprovalTimeline,
|
|
4337
6842
|
{
|
|
4338
6843
|
...props,
|
|
@@ -4344,12 +6849,12 @@ var ProcessPreviewPanel = ProcessPreview;
|
|
|
4344
6849
|
// packages/sdk/src/runtime/react/openxiangdaProvider.tsx
|
|
4345
6850
|
import {
|
|
4346
6851
|
createContext as createContext2,
|
|
4347
|
-
useCallback as
|
|
6852
|
+
useCallback as useCallback10,
|
|
4348
6853
|
useContext as useContext2,
|
|
4349
|
-
useEffect as
|
|
4350
|
-
useMemo as
|
|
4351
|
-
useRef as
|
|
4352
|
-
useState as
|
|
6854
|
+
useEffect as useEffect12,
|
|
6855
|
+
useMemo as useMemo14,
|
|
6856
|
+
useRef as useRef6,
|
|
6857
|
+
useState as useState13
|
|
4353
6858
|
} from "react";
|
|
4354
6859
|
|
|
4355
6860
|
// packages/sdk/src/runtime/core/fetch.ts
|
|
@@ -4386,24 +6891,24 @@ var createBoundFetch = (fetchImpl) => {
|
|
|
4386
6891
|
};
|
|
4387
6892
|
|
|
4388
6893
|
// packages/sdk/src/runtime/host/browserHost.ts
|
|
4389
|
-
var
|
|
4390
|
-
var getDefaultServicePrefix = () => typeof window !== "undefined" ?
|
|
6894
|
+
var trimTrailingSlash2 = (value) => value.replace(/\/+$/, "");
|
|
6895
|
+
var getDefaultServicePrefix = () => typeof window !== "undefined" ? trimTrailingSlash2(window.__OPENXIANGDA_SERVICE_PREFIX__ || "/service") : "/service";
|
|
4391
6896
|
var joinServicePath = (servicePrefix, path) => {
|
|
4392
6897
|
if (/^https?:\/\//i.test(path)) return path;
|
|
4393
|
-
const normalizedPrefix =
|
|
6898
|
+
const normalizedPrefix = trimTrailingSlash2(servicePrefix || "/service");
|
|
4394
6899
|
if (path.startsWith(normalizedPrefix)) return path;
|
|
4395
6900
|
return `${normalizedPrefix}${path.startsWith("/") ? path : `/${path}`}`;
|
|
4396
6901
|
};
|
|
4397
|
-
var
|
|
6902
|
+
var appendQuery2 = (url, query) => {
|
|
4398
6903
|
if (!query) return url;
|
|
4399
6904
|
return `${url}${url.includes("?") ? "&" : "?"}${query}`;
|
|
4400
6905
|
};
|
|
4401
|
-
var
|
|
6906
|
+
var normalizeMethod3 = (method) => {
|
|
4402
6907
|
const value = String(method || "get").toUpperCase();
|
|
4403
6908
|
return ["GET", "POST", "PUT", "DELETE", "PATCH"].includes(value) ? value : "GET";
|
|
4404
6909
|
};
|
|
4405
6910
|
var shouldRetryTransportRequest = (payload) => {
|
|
4406
|
-
const method =
|
|
6911
|
+
const method = normalizeMethod3(payload?.method);
|
|
4407
6912
|
if (method === "GET") return true;
|
|
4408
6913
|
const path = String(payload?.path || "").split("?")[0];
|
|
4409
6914
|
return method === "POST" && path === "/workflow/capabilities/resolve";
|
|
@@ -4413,7 +6918,7 @@ var normalizeEnvelopeCode2 = (value, fallback) => {
|
|
|
4413
6918
|
const normalized = Number(value);
|
|
4414
6919
|
return Number.isFinite(normalized) ? normalized : String(value);
|
|
4415
6920
|
};
|
|
4416
|
-
var
|
|
6921
|
+
var isSuccessCode4 = (value) => {
|
|
4417
6922
|
if (value === void 0 || value === null || value === "") return true;
|
|
4418
6923
|
const normalized = Number(value);
|
|
4419
6924
|
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
@@ -4428,7 +6933,7 @@ var parseJsonResponse = async (response) => {
|
|
|
4428
6933
|
const code = normalizeEnvelopeCode2(payload.code, response.status);
|
|
4429
6934
|
return {
|
|
4430
6935
|
code,
|
|
4431
|
-
success: payload.success !== false &&
|
|
6936
|
+
success: payload.success !== false && isSuccessCode4(code),
|
|
4432
6937
|
message: payload.message,
|
|
4433
6938
|
result: payload.result ?? payload.data ?? null,
|
|
4434
6939
|
data: payload.data,
|
|
@@ -4451,7 +6956,7 @@ var createBrowserPageBridge = (options = {}) => {
|
|
|
4451
6956
|
if (!payload?.path) {
|
|
4452
6957
|
throw new Error("transport.request \u9700\u8981 path");
|
|
4453
6958
|
}
|
|
4454
|
-
const url =
|
|
6959
|
+
const url = appendQuery2(joinServicePath(servicePrefix, payload.path), payload.query);
|
|
4455
6960
|
const headers = new Headers(payload.headers);
|
|
4456
6961
|
let body;
|
|
4457
6962
|
if (payload.body !== void 0) {
|
|
@@ -4463,7 +6968,7 @@ var createBrowserPageBridge = (options = {}) => {
|
|
|
4463
6968
|
}
|
|
4464
6969
|
}
|
|
4465
6970
|
const response = await fetchWithTransientRetry(fetchImpl, url, {
|
|
4466
|
-
method:
|
|
6971
|
+
method: normalizeMethod3(payload.method),
|
|
4467
6972
|
headers,
|
|
4468
6973
|
body,
|
|
4469
6974
|
credentials: "include"
|
|
@@ -4476,7 +6981,7 @@ var createBrowserPageBridge = (options = {}) => {
|
|
|
4476
6981
|
if (!payload?.path) {
|
|
4477
6982
|
throw new Error("transport.download \u9700\u8981 path");
|
|
4478
6983
|
}
|
|
4479
|
-
const url =
|
|
6984
|
+
const url = appendQuery2(joinServicePath(servicePrefix, payload.path), payload.query);
|
|
4480
6985
|
const headers = new Headers(payload.headers);
|
|
4481
6986
|
let body;
|
|
4482
6987
|
if (payload.body !== void 0) {
|
|
@@ -4488,7 +6993,7 @@ var createBrowserPageBridge = (options = {}) => {
|
|
|
4488
6993
|
}
|
|
4489
6994
|
}
|
|
4490
6995
|
const response = await fetchImpl(url, {
|
|
4491
|
-
method:
|
|
6996
|
+
method: normalizeMethod3(payload.method),
|
|
4492
6997
|
headers,
|
|
4493
6998
|
body,
|
|
4494
6999
|
credentials: "include"
|
|
@@ -4576,21 +7081,21 @@ var createBrowserPageContext = (bootstrap, options = {}) => {
|
|
|
4576
7081
|
|
|
4577
7082
|
// packages/sdk/src/runtime/react/auth.tsx
|
|
4578
7083
|
import {
|
|
4579
|
-
useCallback as
|
|
4580
|
-
useEffect as
|
|
4581
|
-
useMemo as
|
|
4582
|
-
useState as
|
|
7084
|
+
useCallback as useCallback9,
|
|
7085
|
+
useEffect as useEffect11,
|
|
7086
|
+
useMemo as useMemo13,
|
|
7087
|
+
useState as useState12
|
|
4583
7088
|
} from "react";
|
|
4584
7089
|
import {
|
|
4585
|
-
Alert,
|
|
4586
|
-
Button as
|
|
7090
|
+
Alert as Alert4,
|
|
7091
|
+
Button as Button8,
|
|
4587
7092
|
Card,
|
|
4588
|
-
Empty as
|
|
7093
|
+
Empty as Empty6,
|
|
4589
7094
|
Form as Form2,
|
|
4590
7095
|
Input as Input3,
|
|
4591
7096
|
Space as Space3,
|
|
4592
|
-
Tabs,
|
|
4593
|
-
Typography as
|
|
7097
|
+
Tabs as Tabs2,
|
|
7098
|
+
Typography as Typography5
|
|
4594
7099
|
} from "antd";
|
|
4595
7100
|
import {
|
|
4596
7101
|
LoginOutlined,
|
|
@@ -4668,7 +7173,7 @@ var createAuthClient = ({
|
|
|
4668
7173
|
const payload = await readPayload(response);
|
|
4669
7174
|
const code = getRecordValue(payload, "code");
|
|
4670
7175
|
const success = getRecordValue(payload, "success");
|
|
4671
|
-
if (!response.ok || success === false || !
|
|
7176
|
+
if (!response.ok || success === false || !isSuccessCode5(code)) {
|
|
4672
7177
|
throw new AuthClientError(
|
|
4673
7178
|
String(getRecordValue(payload, "message") || `Auth request failed: ${response.status}`),
|
|
4674
7179
|
{
|
|
@@ -4747,7 +7252,7 @@ var readNumber = (value) => {
|
|
|
4747
7252
|
const numberValue = Number(value);
|
|
4748
7253
|
return Number.isFinite(numberValue) ? numberValue : void 0;
|
|
4749
7254
|
};
|
|
4750
|
-
var
|
|
7255
|
+
var isSuccessCode5 = (code) => {
|
|
4751
7256
|
if (code === void 0 || code === null || code === "") return true;
|
|
4752
7257
|
const normalized = Number(code);
|
|
4753
7258
|
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
@@ -4777,10 +7282,10 @@ var resolveLoginUrl = (appType, {
|
|
|
4777
7282
|
var getCurrentHref2 = () => typeof window === "undefined" ? "" : window.location.href;
|
|
4778
7283
|
|
|
4779
7284
|
// packages/sdk/src/runtime/react/auth.tsx
|
|
4780
|
-
import { Fragment as
|
|
7285
|
+
import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4781
7286
|
var useAuth = (options = {}) => {
|
|
4782
7287
|
const runtime = useOpenXiangda();
|
|
4783
|
-
const client =
|
|
7288
|
+
const client = useMemo13(
|
|
4784
7289
|
() => createAuthClient({
|
|
4785
7290
|
appType: options.appType || runtime.appType,
|
|
4786
7291
|
servicePrefix: options.servicePrefix || runtime.servicePrefix,
|
|
@@ -4795,7 +7300,7 @@ var useAuth = (options = {}) => {
|
|
|
4795
7300
|
runtime.servicePrefix
|
|
4796
7301
|
]
|
|
4797
7302
|
);
|
|
4798
|
-
return
|
|
7303
|
+
return useMemo13(
|
|
4799
7304
|
() => ({
|
|
4800
7305
|
client,
|
|
4801
7306
|
getMethods: client.getMethods,
|
|
@@ -4815,12 +7320,12 @@ var useAuth = (options = {}) => {
|
|
|
4815
7320
|
};
|
|
4816
7321
|
var useLoginMethods = (options = {}) => {
|
|
4817
7322
|
const auth = useAuth(options);
|
|
4818
|
-
const [state, setState] =
|
|
7323
|
+
const [state, setState] = useState12({
|
|
4819
7324
|
data: null,
|
|
4820
7325
|
loading: true,
|
|
4821
7326
|
error: null
|
|
4822
7327
|
});
|
|
4823
|
-
const reload =
|
|
7328
|
+
const reload = useCallback9(async () => {
|
|
4824
7329
|
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
4825
7330
|
try {
|
|
4826
7331
|
const data = await auth.getMethods();
|
|
@@ -4833,7 +7338,7 @@ var useLoginMethods = (options = {}) => {
|
|
|
4833
7338
|
});
|
|
4834
7339
|
}
|
|
4835
7340
|
}, [auth]);
|
|
4836
|
-
|
|
7341
|
+
useEffect11(() => {
|
|
4837
7342
|
let disposed = false;
|
|
4838
7343
|
const run = async () => {
|
|
4839
7344
|
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
@@ -4877,17 +7382,17 @@ var LoginPage = ({
|
|
|
4877
7382
|
const methodsState = useLoginMethods(authOptions);
|
|
4878
7383
|
const [passwordForm] = Form2.useForm();
|
|
4879
7384
|
const [phoneForm] = Form2.useForm();
|
|
4880
|
-
const [activeMethod, setActiveMethod] =
|
|
7385
|
+
const [activeMethod, setActiveMethod] = useState12(
|
|
4881
7386
|
defaultMethod || "password"
|
|
4882
7387
|
);
|
|
4883
|
-
const [phonePurpose, setPhonePurpose] =
|
|
7388
|
+
const [phonePurpose, setPhonePurpose] = useState12(
|
|
4884
7389
|
"login"
|
|
4885
7390
|
);
|
|
4886
|
-
const [phoneChallengeId, setPhoneChallengeId] =
|
|
4887
|
-
const [passwordChallenge, setPasswordChallenge] =
|
|
4888
|
-
const [submitting, setSubmitting] =
|
|
4889
|
-
const [sendingCode, setSendingCode] =
|
|
4890
|
-
const [error, setError] =
|
|
7391
|
+
const [phoneChallengeId, setPhoneChallengeId] = useState12("");
|
|
7392
|
+
const [passwordChallenge, setPasswordChallenge] = useState12(null);
|
|
7393
|
+
const [submitting, setSubmitting] = useState12(false);
|
|
7394
|
+
const [sendingCode, setSendingCode] = useState12(false);
|
|
7395
|
+
const [error, setError] = useState12(null);
|
|
4891
7396
|
const methods = methodsState.methods.filter((method) => method.enabled !== false);
|
|
4892
7397
|
const passwordMethod = findMethod(methods, "password");
|
|
4893
7398
|
const phoneMethod = findMethod(methods, "phone_code");
|
|
@@ -4895,16 +7400,16 @@ var LoginPage = ({
|
|
|
4895
7400
|
const ssoMethod = findMethod(methods, "sso");
|
|
4896
7401
|
const guestMethod = findMethod(methods, "guest");
|
|
4897
7402
|
const allowRegister = methodsState.data?.registration?.mode !== "reject";
|
|
4898
|
-
const tabItems =
|
|
7403
|
+
const tabItems = useMemo13(() => {
|
|
4899
7404
|
const items = [];
|
|
4900
7405
|
if (passwordMethod) {
|
|
4901
7406
|
items.push({
|
|
4902
7407
|
key: "password",
|
|
4903
|
-
label: /* @__PURE__ */
|
|
4904
|
-
/* @__PURE__ */
|
|
4905
|
-
/* @__PURE__ */
|
|
7408
|
+
label: /* @__PURE__ */ jsxs12(Space3, { size: 6, children: [
|
|
7409
|
+
/* @__PURE__ */ jsx14(UserOutlined4, {}),
|
|
7410
|
+
/* @__PURE__ */ jsx14("span", { children: passwordMethod.label || "\u8D26\u53F7\u5BC6\u7801" })
|
|
4906
7411
|
] }),
|
|
4907
|
-
children: /* @__PURE__ */
|
|
7412
|
+
children: /* @__PURE__ */ jsx14(
|
|
4908
7413
|
PasswordLoginForm,
|
|
4909
7414
|
{
|
|
4910
7415
|
challenge: passwordChallenge,
|
|
@@ -4946,11 +7451,11 @@ var LoginPage = ({
|
|
|
4946
7451
|
if (phoneMethod) {
|
|
4947
7452
|
items.push({
|
|
4948
7453
|
key: "phone_code",
|
|
4949
|
-
label: /* @__PURE__ */
|
|
4950
|
-
/* @__PURE__ */
|
|
4951
|
-
/* @__PURE__ */
|
|
7454
|
+
label: /* @__PURE__ */ jsxs12(Space3, { size: 6, children: [
|
|
7455
|
+
/* @__PURE__ */ jsx14(MobileOutlined, {}),
|
|
7456
|
+
/* @__PURE__ */ jsx14("span", { children: phoneMethod.label || "\u624B\u673A\u53F7" })
|
|
4952
7457
|
] }),
|
|
4953
|
-
children: /* @__PURE__ */
|
|
7458
|
+
children: /* @__PURE__ */ jsx14(
|
|
4954
7459
|
PhoneCodeLoginForm,
|
|
4955
7460
|
{
|
|
4956
7461
|
allowRegister,
|
|
@@ -5014,7 +7519,7 @@ var LoginPage = ({
|
|
|
5014
7519
|
sendingCode,
|
|
5015
7520
|
submitting
|
|
5016
7521
|
]);
|
|
5017
|
-
|
|
7522
|
+
useEffect11(() => {
|
|
5018
7523
|
const firstKey = tabItems[0]?.key;
|
|
5019
7524
|
if (firstKey && !tabItems.some((item) => item.key === activeMethod)) {
|
|
5020
7525
|
setActiveMethod(firstKey);
|
|
@@ -5089,7 +7594,7 @@ var LoginPage = ({
|
|
|
5089
7594
|
);
|
|
5090
7595
|
}
|
|
5091
7596
|
}
|
|
5092
|
-
return /* @__PURE__ */
|
|
7597
|
+
return /* @__PURE__ */ jsx14(
|
|
5093
7598
|
"div",
|
|
5094
7599
|
{
|
|
5095
7600
|
className,
|
|
@@ -5101,7 +7606,7 @@ var LoginPage = ({
|
|
|
5101
7606
|
background: "#f6f8fb",
|
|
5102
7607
|
...style
|
|
5103
7608
|
},
|
|
5104
|
-
children: /* @__PURE__ */
|
|
7609
|
+
children: /* @__PURE__ */ jsx14(
|
|
5105
7610
|
Card,
|
|
5106
7611
|
{
|
|
5107
7612
|
style: {
|
|
@@ -5110,54 +7615,54 @@ var LoginPage = ({
|
|
|
5110
7615
|
boxShadow: "0 16px 48px rgba(15, 23, 42, 0.10)"
|
|
5111
7616
|
},
|
|
5112
7617
|
styles: { body: { padding: 28 } },
|
|
5113
|
-
children: /* @__PURE__ */
|
|
5114
|
-
/* @__PURE__ */
|
|
5115
|
-
/* @__PURE__ */
|
|
5116
|
-
subtitle ? /* @__PURE__ */
|
|
7618
|
+
children: /* @__PURE__ */ jsxs12(Space3, { direction: "vertical", size: 20, style: { width: "100%" }, children: [
|
|
7619
|
+
/* @__PURE__ */ jsxs12("div", { children: [
|
|
7620
|
+
/* @__PURE__ */ jsx14(Typography5.Title, { level: 3, style: { margin: 0 }, children: title || "\u5E94\u7528\u767B\u5F55" }),
|
|
7621
|
+
subtitle ? /* @__PURE__ */ jsx14(Typography5.Text, { type: "secondary", children: subtitle }) : null
|
|
5117
7622
|
] }),
|
|
5118
|
-
methodsState.error ? /* @__PURE__ */
|
|
5119
|
-
|
|
7623
|
+
methodsState.error ? /* @__PURE__ */ jsx14(
|
|
7624
|
+
Alert4,
|
|
5120
7625
|
{
|
|
5121
7626
|
showIcon: true,
|
|
5122
7627
|
type: "error",
|
|
5123
7628
|
message: methodsState.error.message
|
|
5124
7629
|
}
|
|
5125
7630
|
) : null,
|
|
5126
|
-
error ? /* @__PURE__ */
|
|
5127
|
-
methodsState.loading ? /* @__PURE__ */
|
|
5128
|
-
|
|
7631
|
+
error ? /* @__PURE__ */ jsx14(Alert4, { showIcon: true, type: "error", message: error }) : null,
|
|
7632
|
+
methodsState.loading ? /* @__PURE__ */ jsx14(Button8, { block: true, loading: true, children: "\u52A0\u8F7D\u4E2D" }) : tabItems.length > 0 ? /* @__PURE__ */ jsx14(
|
|
7633
|
+
Tabs2,
|
|
5129
7634
|
{
|
|
5130
7635
|
activeKey: activeMethod,
|
|
5131
7636
|
items: tabItems,
|
|
5132
7637
|
onChange: setActiveMethod
|
|
5133
7638
|
}
|
|
5134
|
-
) : /* @__PURE__ */
|
|
5135
|
-
/* @__PURE__ */
|
|
5136
|
-
dingtalkMethod ? /* @__PURE__ */
|
|
5137
|
-
|
|
7639
|
+
) : /* @__PURE__ */ jsx14(Empty6, { description: "\u672A\u542F\u7528\u767B\u5F55\u65B9\u5F0F" }),
|
|
7640
|
+
/* @__PURE__ */ jsxs12(Space3, { direction: "vertical", size: 10, style: { width: "100%" }, children: [
|
|
7641
|
+
dingtalkMethod ? /* @__PURE__ */ jsx14(
|
|
7642
|
+
Button8,
|
|
5138
7643
|
{
|
|
5139
7644
|
block: true,
|
|
5140
|
-
icon: /* @__PURE__ */
|
|
7645
|
+
icon: /* @__PURE__ */ jsx14(QrcodeOutlined, {}),
|
|
5141
7646
|
loading: submitting,
|
|
5142
7647
|
onClick: handleDingTalkLogin,
|
|
5143
7648
|
children: dingtalkMethod.label || "\u9489\u9489\u514D\u767B"
|
|
5144
7649
|
}
|
|
5145
7650
|
) : null,
|
|
5146
|
-
ssoMethod ? /* @__PURE__ */
|
|
5147
|
-
|
|
7651
|
+
ssoMethod ? /* @__PURE__ */ jsx14(
|
|
7652
|
+
Button8,
|
|
5148
7653
|
{
|
|
5149
7654
|
block: true,
|
|
5150
|
-
icon: /* @__PURE__ */
|
|
7655
|
+
icon: /* @__PURE__ */ jsx14(SafetyCertificateOutlined, {}),
|
|
5151
7656
|
loading: submitting,
|
|
5152
7657
|
onClick: handleSsoLogin,
|
|
5153
7658
|
children: ssoMethod.label || "SSO \u767B\u5F55"
|
|
5154
7659
|
}
|
|
5155
7660
|
) : null,
|
|
5156
|
-
guestMethod ? /* @__PURE__ */
|
|
5157
|
-
|
|
7661
|
+
guestMethod ? /* @__PURE__ */ jsx14(
|
|
7662
|
+
Button8,
|
|
5158
7663
|
{
|
|
5159
7664
|
block: true,
|
|
5160
|
-
icon: /* @__PURE__ */
|
|
7665
|
+
icon: /* @__PURE__ */ jsx14(LoginOutlined, {}),
|
|
5161
7666
|
loading: submitting,
|
|
5162
7667
|
onClick: handleGuestLogin,
|
|
5163
7668
|
children: guestMethod.label || "\u8BBF\u5BA2\u8BBF\u95EE"
|
|
@@ -5170,28 +7675,28 @@ var LoginPage = ({
|
|
|
5170
7675
|
}
|
|
5171
7676
|
);
|
|
5172
7677
|
};
|
|
5173
|
-
var PasswordLoginForm = ({ challenge, form, loading, onFinish }) => /* @__PURE__ */
|
|
5174
|
-
/* @__PURE__ */
|
|
7678
|
+
var PasswordLoginForm = ({ challenge, form, loading, onFinish }) => /* @__PURE__ */ jsxs12(Form2, { form, layout: "vertical", requiredMark: false, onFinish, children: [
|
|
7679
|
+
/* @__PURE__ */ jsx14(
|
|
5175
7680
|
Form2.Item,
|
|
5176
7681
|
{
|
|
5177
7682
|
label: "\u8D26\u53F7",
|
|
5178
7683
|
name: "username",
|
|
5179
7684
|
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u8D26\u53F7" }],
|
|
5180
|
-
children: /* @__PURE__ */
|
|
7685
|
+
children: /* @__PURE__ */ jsx14(Input3, { autoComplete: "username" })
|
|
5181
7686
|
}
|
|
5182
7687
|
),
|
|
5183
|
-
/* @__PURE__ */
|
|
7688
|
+
/* @__PURE__ */ jsx14(
|
|
5184
7689
|
Form2.Item,
|
|
5185
7690
|
{
|
|
5186
7691
|
label: "\u5BC6\u7801",
|
|
5187
7692
|
name: "password",
|
|
5188
7693
|
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u5BC6\u7801" }],
|
|
5189
|
-
children: /* @__PURE__ */
|
|
7694
|
+
children: /* @__PURE__ */ jsx14(Input3.Password, { autoComplete: "current-password" })
|
|
5190
7695
|
}
|
|
5191
7696
|
),
|
|
5192
|
-
challenge ? /* @__PURE__ */
|
|
5193
|
-
/* @__PURE__ */
|
|
5194
|
-
|
|
7697
|
+
challenge ? /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
7698
|
+
/* @__PURE__ */ jsx14(
|
|
7699
|
+
Alert4,
|
|
5195
7700
|
{
|
|
5196
7701
|
showIcon: true,
|
|
5197
7702
|
type: "warning",
|
|
@@ -5199,17 +7704,17 @@ var PasswordLoginForm = ({ challenge, form, loading, onFinish }) => /* @__PURE__
|
|
|
5199
7704
|
description: readChallengeQuestion(challenge) || "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801\u540E\u7EE7\u7EED\u767B\u5F55\u3002"
|
|
5200
7705
|
}
|
|
5201
7706
|
),
|
|
5202
|
-
/* @__PURE__ */
|
|
7707
|
+
/* @__PURE__ */ jsx14(
|
|
5203
7708
|
Form2.Item,
|
|
5204
7709
|
{
|
|
5205
7710
|
label: "\u9A8C\u8BC1\u7B54\u6848",
|
|
5206
7711
|
name: "challengeAnswer",
|
|
5207
7712
|
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7B54\u6848" }],
|
|
5208
|
-
children: /* @__PURE__ */
|
|
7713
|
+
children: /* @__PURE__ */ jsx14(Input3, { autoComplete: "one-time-code" })
|
|
5209
7714
|
}
|
|
5210
7715
|
)
|
|
5211
7716
|
] }) : null,
|
|
5212
|
-
/* @__PURE__ */
|
|
7717
|
+
/* @__PURE__ */ jsx14(Button8, { block: true, htmlType: "submit", icon: /* @__PURE__ */ jsx14(LoginOutlined, {}), loading, type: "primary", children: "\u767B\u5F55" })
|
|
5213
7718
|
] });
|
|
5214
7719
|
var PhoneCodeLoginForm = ({
|
|
5215
7720
|
allowRegister,
|
|
@@ -5220,9 +7725,9 @@ var PhoneCodeLoginForm = ({
|
|
|
5220
7725
|
onPurposeChange,
|
|
5221
7726
|
onSendCode,
|
|
5222
7727
|
onFinish
|
|
5223
|
-
}) => /* @__PURE__ */
|
|
5224
|
-
allowRegister ? /* @__PURE__ */
|
|
5225
|
-
|
|
7728
|
+
}) => /* @__PURE__ */ jsxs12(Form2, { form, layout: "vertical", requiredMark: false, onFinish, children: [
|
|
7729
|
+
allowRegister ? /* @__PURE__ */ jsx14(Form2.Item, { style: { marginBottom: 12 }, children: /* @__PURE__ */ jsx14(
|
|
7730
|
+
Tabs2,
|
|
5226
7731
|
{
|
|
5227
7732
|
activeKey: phonePurpose,
|
|
5228
7733
|
items: [
|
|
@@ -5233,26 +7738,26 @@ var PhoneCodeLoginForm = ({
|
|
|
5233
7738
|
size: "small"
|
|
5234
7739
|
}
|
|
5235
7740
|
) }) : null,
|
|
5236
|
-
/* @__PURE__ */
|
|
7741
|
+
/* @__PURE__ */ jsx14(
|
|
5237
7742
|
Form2.Item,
|
|
5238
7743
|
{
|
|
5239
7744
|
label: "\u624B\u673A\u53F7",
|
|
5240
7745
|
name: "phone",
|
|
5241
7746
|
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7" }],
|
|
5242
|
-
children: /* @__PURE__ */
|
|
7747
|
+
children: /* @__PURE__ */ jsx14(Input3, { autoComplete: "tel" })
|
|
5243
7748
|
}
|
|
5244
7749
|
),
|
|
5245
|
-
/* @__PURE__ */
|
|
7750
|
+
/* @__PURE__ */ jsx14(
|
|
5246
7751
|
Form2.Item,
|
|
5247
7752
|
{
|
|
5248
7753
|
label: "\u9A8C\u8BC1\u7801",
|
|
5249
7754
|
name: "code",
|
|
5250
7755
|
rules: [{ required: true, message: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801" }],
|
|
5251
|
-
children: /* @__PURE__ */
|
|
7756
|
+
children: /* @__PURE__ */ jsx14(
|
|
5252
7757
|
Input3,
|
|
5253
7758
|
{
|
|
5254
|
-
addonAfter: /* @__PURE__ */
|
|
5255
|
-
|
|
7759
|
+
addonAfter: /* @__PURE__ */ jsx14(
|
|
7760
|
+
Button8,
|
|
5256
7761
|
{
|
|
5257
7762
|
loading: sendingCode,
|
|
5258
7763
|
onClick: onSendCode,
|
|
@@ -5266,7 +7771,7 @@ var PhoneCodeLoginForm = ({
|
|
|
5266
7771
|
)
|
|
5267
7772
|
}
|
|
5268
7773
|
),
|
|
5269
|
-
/* @__PURE__ */
|
|
7774
|
+
/* @__PURE__ */ jsx14(Button8, { block: true, htmlType: "submit", icon: /* @__PURE__ */ jsx14(MobileOutlined, {}), loading, type: "primary", children: phonePurpose === "register" ? "\u6CE8\u518C" : "\u767B\u5F55" })
|
|
5270
7775
|
] });
|
|
5271
7776
|
var findMethod = (methods, type) => methods.find((method) => method.type === type);
|
|
5272
7777
|
var normalizeError = (error) => error instanceof Error ? error : new Error(String(error || "\u8BF7\u6C42\u5931\u8D25"));
|
|
@@ -5343,7 +7848,7 @@ var getCallbackUrl = () => {
|
|
|
5343
7848
|
};
|
|
5344
7849
|
|
|
5345
7850
|
// packages/sdk/src/runtime/react/openxiangdaProvider.tsx
|
|
5346
|
-
import { Fragment as
|
|
7851
|
+
import { Fragment as Fragment6, jsx as jsx15 } from "react/jsx-runtime";
|
|
5347
7852
|
var RuntimeHttpError = class extends Error {
|
|
5348
7853
|
constructor(snapshot) {
|
|
5349
7854
|
super(snapshot.message);
|
|
@@ -5361,19 +7866,19 @@ var OpenXiangdaProvider = ({
|
|
|
5361
7866
|
fetchImpl,
|
|
5362
7867
|
children
|
|
5363
7868
|
}) => {
|
|
5364
|
-
const resolvedFetch =
|
|
5365
|
-
const resolvedAppType =
|
|
7869
|
+
const resolvedFetch = useMemo14(() => createBoundFetch(fetchImpl), [fetchImpl]);
|
|
7870
|
+
const resolvedAppType = useMemo14(
|
|
5366
7871
|
() => appType || resolveAppTypeFromLocation(),
|
|
5367
7872
|
[appType]
|
|
5368
7873
|
);
|
|
5369
|
-
const [, setAccessTokenState] =
|
|
5370
|
-
const [authState, setAuthState] =
|
|
7874
|
+
const [, setAccessTokenState] = useState13(null);
|
|
7875
|
+
const [authState, setAuthState] = useState13({
|
|
5371
7876
|
status: "unknown",
|
|
5372
7877
|
error: null
|
|
5373
7878
|
});
|
|
5374
|
-
const accessTokenRef =
|
|
5375
|
-
const refreshRequestRef =
|
|
5376
|
-
const applyAccessToken =
|
|
7879
|
+
const accessTokenRef = useRef6(null);
|
|
7880
|
+
const refreshRequestRef = useRef6(null);
|
|
7881
|
+
const applyAccessToken = useCallback10(
|
|
5377
7882
|
(nextAccessToken, options = {}) => {
|
|
5378
7883
|
if (!nextAccessToken && options.clearIfToken && accessTokenRef.current?.token !== options.clearIfToken) {
|
|
5379
7884
|
return accessTokenRef.current;
|
|
@@ -5391,7 +7896,7 @@ var OpenXiangdaProvider = ({
|
|
|
5391
7896
|
},
|
|
5392
7897
|
[]
|
|
5393
7898
|
);
|
|
5394
|
-
const setAccessToken =
|
|
7899
|
+
const setAccessToken = useCallback10(
|
|
5395
7900
|
(nextAccessToken, options = {}) => {
|
|
5396
7901
|
const previousState = accessTokenRef.current;
|
|
5397
7902
|
const nextState = applyAccessToken(nextAccessToken, options);
|
|
@@ -5407,7 +7912,7 @@ var OpenXiangdaProvider = ({
|
|
|
5407
7912
|
},
|
|
5408
7913
|
[applyAccessToken]
|
|
5409
7914
|
);
|
|
5410
|
-
const markUnauthenticated =
|
|
7915
|
+
const markUnauthenticated = useCallback10(
|
|
5411
7916
|
(error) => {
|
|
5412
7917
|
const runtimeError = normalizeRuntimeError(error);
|
|
5413
7918
|
applyAccessToken(null);
|
|
@@ -5415,7 +7920,7 @@ var OpenXiangdaProvider = ({
|
|
|
5415
7920
|
},
|
|
5416
7921
|
[applyAccessToken]
|
|
5417
7922
|
);
|
|
5418
|
-
const refreshAccessToken =
|
|
7923
|
+
const refreshAccessToken = useCallback10(async () => {
|
|
5419
7924
|
if (!resolvedAppType) return null;
|
|
5420
7925
|
if (!refreshRequestRef.current) {
|
|
5421
7926
|
setAuthState((prev) => ({ ...prev, status: "refreshing", error: null }));
|
|
@@ -5476,7 +7981,7 @@ var OpenXiangdaProvider = ({
|
|
|
5476
7981
|
}
|
|
5477
7982
|
return refreshRequestRef.current;
|
|
5478
7983
|
}, [applyAccessToken, resolvedAppType, resolvedFetch, servicePrefix]);
|
|
5479
|
-
const authorizedFetch =
|
|
7984
|
+
const authorizedFetch = useMemo14(
|
|
5480
7985
|
() => createAuthorizedFetch({
|
|
5481
7986
|
appType: resolvedAppType,
|
|
5482
7987
|
baseFetch: resolvedFetch,
|
|
@@ -5486,18 +7991,18 @@ var OpenXiangdaProvider = ({
|
|
|
5486
7991
|
}),
|
|
5487
7992
|
[markUnauthenticated, refreshAccessToken, resolvedAppType, resolvedFetch]
|
|
5488
7993
|
);
|
|
5489
|
-
const getAuthHeaders =
|
|
7994
|
+
const getAuthHeaders = useCallback10(() => {
|
|
5490
7995
|
const state2 = accessTokenRef.current;
|
|
5491
7996
|
if (!state2) return {};
|
|
5492
7997
|
const token = resolveAccessTokenForCurrentRoute(state2);
|
|
5493
7998
|
return token ? { authorization: `Bearer ${token}` } : {};
|
|
5494
7999
|
}, []);
|
|
5495
|
-
const [state, setState] =
|
|
8000
|
+
const [state, setState] = useState13({
|
|
5496
8001
|
data: null,
|
|
5497
8002
|
loading: true,
|
|
5498
8003
|
error: null
|
|
5499
8004
|
});
|
|
5500
|
-
const reload =
|
|
8005
|
+
const reload = useCallback10(async (options = {}) => {
|
|
5501
8006
|
if (!resolvedAppType) {
|
|
5502
8007
|
setState({
|
|
5503
8008
|
data: null,
|
|
@@ -5561,10 +8066,10 @@ var OpenXiangdaProvider = ({
|
|
|
5561
8066
|
}
|
|
5562
8067
|
}
|
|
5563
8068
|
}, [authorizedFetch, resolvedAppType, resolvedFetch, servicePrefix]);
|
|
5564
|
-
|
|
8069
|
+
useEffect12(() => {
|
|
5565
8070
|
void reload();
|
|
5566
8071
|
}, [reload]);
|
|
5567
|
-
const value =
|
|
8072
|
+
const value = useMemo14(
|
|
5568
8073
|
() => ({
|
|
5569
8074
|
...state,
|
|
5570
8075
|
appType: resolvedAppType,
|
|
@@ -5587,7 +8092,7 @@ var OpenXiangdaProvider = ({
|
|
|
5587
8092
|
authState
|
|
5588
8093
|
]
|
|
5589
8094
|
);
|
|
5590
|
-
return /* @__PURE__ */
|
|
8095
|
+
return /* @__PURE__ */ jsx15(OpenXiangdaRuntimeContext.Provider, { value, children });
|
|
5591
8096
|
};
|
|
5592
8097
|
var useOpenXiangda = () => {
|
|
5593
8098
|
const context = useContext2(OpenXiangdaRuntimeContext);
|
|
@@ -5607,7 +8112,7 @@ var OpenXiangdaPageProvider = ({
|
|
|
5607
8112
|
navigation
|
|
5608
8113
|
}) => {
|
|
5609
8114
|
const runtime = useOpenXiangda();
|
|
5610
|
-
const context =
|
|
8115
|
+
const context = useMemo14(() => {
|
|
5611
8116
|
const bootstrap = runtime.data;
|
|
5612
8117
|
const app = toRuntimeRecord(bootstrap?.app);
|
|
5613
8118
|
const user = toRuntimeRecord(bootstrap?.user);
|
|
@@ -5687,7 +8192,7 @@ var OpenXiangdaPageProvider = ({
|
|
|
5687
8192
|
runtime.fetchImpl,
|
|
5688
8193
|
runtime.servicePrefix
|
|
5689
8194
|
]);
|
|
5690
|
-
return /* @__PURE__ */
|
|
8195
|
+
return /* @__PURE__ */ jsx15(PageProvider, { context, children });
|
|
5691
8196
|
};
|
|
5692
8197
|
var useAppMenus = () => {
|
|
5693
8198
|
const runtime = useOpenXiangda();
|
|
@@ -5705,12 +8210,12 @@ var usePermission = () => {
|
|
|
5705
8210
|
};
|
|
5706
8211
|
var useCanAccessRoute = (input) => {
|
|
5707
8212
|
const runtime = useOpenXiangda();
|
|
5708
|
-
const [state, setState] =
|
|
8213
|
+
const [state, setState] = useState13({
|
|
5709
8214
|
data: null,
|
|
5710
8215
|
loading: true,
|
|
5711
8216
|
error: null
|
|
5712
8217
|
});
|
|
5713
|
-
|
|
8218
|
+
useEffect12(() => {
|
|
5714
8219
|
let disposed = false;
|
|
5715
8220
|
const check = async () => {
|
|
5716
8221
|
const permissions = runtime.data?.permissions;
|
|
@@ -5832,16 +8337,16 @@ var PermissionBoundary = ({
|
|
|
5832
8337
|
const access = useCanAccessRoute({ routeCode, menuCode, path });
|
|
5833
8338
|
const fallbackState = createPermissionFallbackState(access, runtime);
|
|
5834
8339
|
if (access.loading) {
|
|
5835
|
-
return /* @__PURE__ */
|
|
8340
|
+
return /* @__PURE__ */ jsx15(Fragment6, { children: renderBoundaryFallback(loadingFallback, fallbackState) });
|
|
5836
8341
|
}
|
|
5837
8342
|
if (!access.canAccess) {
|
|
5838
|
-
return /* @__PURE__ */
|
|
8343
|
+
return /* @__PURE__ */ jsx15(Fragment6, { children: renderBoundaryFallback(fallback, fallbackState) });
|
|
5839
8344
|
}
|
|
5840
|
-
return /* @__PURE__ */
|
|
8345
|
+
return /* @__PURE__ */ jsx15(Fragment6, { children });
|
|
5841
8346
|
};
|
|
5842
8347
|
var useRuntimeAuth = () => {
|
|
5843
8348
|
const runtime = useOpenXiangda();
|
|
5844
|
-
const resolveLoginUrl2 =
|
|
8349
|
+
const resolveLoginUrl2 = useCallback10(
|
|
5845
8350
|
async (options = {}) => {
|
|
5846
8351
|
const redirectUri = options.redirectUri || getCurrentHref4();
|
|
5847
8352
|
const domain = options.domain || getCurrentHostname2();
|
|
@@ -5888,7 +8393,7 @@ var useRuntimeAuth = () => {
|
|
|
5888
8393
|
},
|
|
5889
8394
|
[runtime.baseFetchImpl, runtime.data?.app, runtime.servicePrefix]
|
|
5890
8395
|
);
|
|
5891
|
-
const redirectToLogin =
|
|
8396
|
+
const redirectToLogin = useCallback10(
|
|
5892
8397
|
async (options = {}) => {
|
|
5893
8398
|
const loginUrl = await resolveLoginUrl2(options);
|
|
5894
8399
|
if (typeof window !== "undefined") {
|
|
@@ -5902,7 +8407,7 @@ var useRuntimeAuth = () => {
|
|
|
5902
8407
|
},
|
|
5903
8408
|
[resolveLoginUrl2]
|
|
5904
8409
|
);
|
|
5905
|
-
const logout =
|
|
8410
|
+
const logout = useCallback10(async () => {
|
|
5906
8411
|
const response = await runtime.baseFetchImpl(
|
|
5907
8412
|
buildServiceUrl2(runtime.servicePrefix, "/api/auth/logout"),
|
|
5908
8413
|
{
|
|
@@ -5922,7 +8427,7 @@ var useRuntimeAuth = () => {
|
|
|
5922
8427
|
runtime.setAccessToken(null);
|
|
5923
8428
|
return payload;
|
|
5924
8429
|
}, [runtime.baseFetchImpl, runtime.servicePrefix, runtime.setAccessToken]);
|
|
5925
|
-
const logoutAndRedirect =
|
|
8430
|
+
const logoutAndRedirect = useCallback10(
|
|
5926
8431
|
async (options = {}) => {
|
|
5927
8432
|
try {
|
|
5928
8433
|
await logout();
|
|
@@ -5933,7 +8438,7 @@ var useRuntimeAuth = () => {
|
|
|
5933
8438
|
},
|
|
5934
8439
|
[logout, redirectToLogin]
|
|
5935
8440
|
);
|
|
5936
|
-
return
|
|
8441
|
+
return useMemo14(
|
|
5937
8442
|
() => ({
|
|
5938
8443
|
logout,
|
|
5939
8444
|
logoutAndRedirect,
|
|
@@ -5952,7 +8457,7 @@ var RuntimeAuthGuard = ({
|
|
|
5952
8457
|
}) => {
|
|
5953
8458
|
const runtime = useOpenXiangda();
|
|
5954
8459
|
const auth = useRuntimeAuth();
|
|
5955
|
-
const redirectedRef =
|
|
8460
|
+
const redirectedRef = useRef6(false);
|
|
5956
8461
|
const currentPath = getCurrentPathname();
|
|
5957
8462
|
const excluded = isRuntimeAuthGuardExcluded(
|
|
5958
8463
|
currentPath,
|
|
@@ -5960,7 +8465,7 @@ var RuntimeAuthGuard = ({
|
|
|
5960
8465
|
excludedPaths
|
|
5961
8466
|
);
|
|
5962
8467
|
const shouldRedirect = !disabled && !excluded && !runtime.loading && (runtime.authState.status === "unauthenticated" || runtime.error?.type === "unauthenticated");
|
|
5963
|
-
|
|
8468
|
+
useEffect12(() => {
|
|
5964
8469
|
if (!shouldRedirect || redirectedRef.current) return;
|
|
5965
8470
|
redirectedRef.current = true;
|
|
5966
8471
|
void auth.redirectToLogin({
|
|
@@ -5977,9 +8482,9 @@ var RuntimeAuthGuard = ({
|
|
|
5977
8482
|
redirectOptions.replace,
|
|
5978
8483
|
shouldRedirect
|
|
5979
8484
|
]);
|
|
5980
|
-
if (excluded) return /* @__PURE__ */
|
|
5981
|
-
if (shouldRedirect) return /* @__PURE__ */
|
|
5982
|
-
return /* @__PURE__ */
|
|
8485
|
+
if (excluded) return /* @__PURE__ */ jsx15(Fragment6, { children });
|
|
8486
|
+
if (shouldRedirect) return /* @__PURE__ */ jsx15(Fragment6, { children: fallback });
|
|
8487
|
+
return /* @__PURE__ */ jsx15(Fragment6, { children });
|
|
5983
8488
|
};
|
|
5984
8489
|
var buildServiceUrl2 = (servicePrefix, path) => {
|
|
5985
8490
|
const prefix = servicePrefix.endsWith("/") ? servicePrefix.slice(0, -1) : servicePrefix;
|
|
@@ -6250,7 +8755,7 @@ var buildBrowserRouteInfo = (route) => {
|
|
|
6250
8755
|
hash
|
|
6251
8756
|
};
|
|
6252
8757
|
};
|
|
6253
|
-
var
|
|
8758
|
+
var isSuccessCode6 = (code) => {
|
|
6254
8759
|
if (code === void 0 || code === null || code === "") return true;
|
|
6255
8760
|
const normalized = Number(code);
|
|
6256
8761
|
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
@@ -6258,7 +8763,7 @@ var isSuccessCode5 = (code) => {
|
|
|
6258
8763
|
var isRuntimeEnvelopeFailure = (response, payload) => {
|
|
6259
8764
|
const code = getRecordValue2(payload, "code");
|
|
6260
8765
|
const success = getRecordValue2(payload, "success");
|
|
6261
|
-
return !response.ok || success === false || !
|
|
8766
|
+
return !response.ok || success === false || !isSuccessCode6(code);
|
|
6262
8767
|
};
|
|
6263
8768
|
var isServerErrorCode = (code) => {
|
|
6264
8769
|
const normalized = Number(code);
|
|
@@ -6303,7 +8808,7 @@ var resolveAppTypeFromLocation = () => {
|
|
|
6303
8808
|
};
|
|
6304
8809
|
|
|
6305
8810
|
// packages/sdk/src/runtime/react/publicAccess.tsx
|
|
6306
|
-
import { useCallback as
|
|
8811
|
+
import { useCallback as useCallback11, useEffect as useEffect13, useMemo as useMemo15, useRef as useRef7, useState as useState14 } from "react";
|
|
6307
8812
|
|
|
6308
8813
|
// packages/sdk/src/runtime/core/publicAccess.ts
|
|
6309
8814
|
var PublicAccessClientError = class extends Error {
|
|
@@ -6353,7 +8858,7 @@ var createPublicAccessClient = ({
|
|
|
6353
8858
|
const payload = await readPayload2(response);
|
|
6354
8859
|
const code = getRecordValue3(payload, "code");
|
|
6355
8860
|
const success = getRecordValue3(payload, "success");
|
|
6356
|
-
if (!response.ok || success === false || !
|
|
8861
|
+
if (!response.ok || success === false || !isSuccessCode7(code)) {
|
|
6357
8862
|
throw new PublicAccessClientError(
|
|
6358
8863
|
String(
|
|
6359
8864
|
getRecordValue3(payload, "message") || `Public access session failed: ${response.status}`
|
|
@@ -6391,7 +8896,7 @@ var getRecordValue3 = (value, key) => {
|
|
|
6391
8896
|
if (!value || typeof value !== "object") return void 0;
|
|
6392
8897
|
return value[key];
|
|
6393
8898
|
};
|
|
6394
|
-
var
|
|
8899
|
+
var isSuccessCode7 = (code) => {
|
|
6395
8900
|
if (code === void 0 || code === null || code === "") return true;
|
|
6396
8901
|
const normalized = Number(code);
|
|
6397
8902
|
return Number.isFinite(normalized) ? normalized === 0 || normalized >= 200 && normalized < 300 : false;
|
|
@@ -6419,7 +8924,7 @@ var createRandomIdentifier = (appType) => {
|
|
|
6419
8924
|
};
|
|
6420
8925
|
|
|
6421
8926
|
// packages/sdk/src/runtime/react/publicAccess.tsx
|
|
6422
|
-
import { Fragment as
|
|
8927
|
+
import { Fragment as Fragment7, jsx as jsx16 } from "react/jsx-runtime";
|
|
6423
8928
|
var usePublicAccess = (options = {}) => {
|
|
6424
8929
|
const runtime = useOpenXiangda();
|
|
6425
8930
|
const {
|
|
@@ -6436,14 +8941,14 @@ var usePublicAccess = (options = {}) => {
|
|
|
6436
8941
|
autoStart = true,
|
|
6437
8942
|
...sessionInput
|
|
6438
8943
|
} = options;
|
|
6439
|
-
const [session, setSession] =
|
|
6440
|
-
const [error, setError] =
|
|
6441
|
-
const [loading, setLoading] =
|
|
6442
|
-
const activeSessionRef =
|
|
6443
|
-
const mountedRef =
|
|
8944
|
+
const [session, setSession] = useState14(null);
|
|
8945
|
+
const [error, setError] = useState14(null);
|
|
8946
|
+
const [loading, setLoading] = useState14(Boolean(autoStart));
|
|
8947
|
+
const activeSessionRef = useRef7(null);
|
|
8948
|
+
const mountedRef = useRef7(true);
|
|
6444
8949
|
const sessionInputKey = JSON.stringify(sessionInput);
|
|
6445
|
-
const stableSessionInput =
|
|
6446
|
-
const client =
|
|
8950
|
+
const stableSessionInput = useMemo15(() => sessionInput, [sessionInputKey]);
|
|
8951
|
+
const client = useMemo15(
|
|
6447
8952
|
() => createPublicAccessClient({
|
|
6448
8953
|
appType,
|
|
6449
8954
|
servicePrefix,
|
|
@@ -6451,7 +8956,7 @@ var usePublicAccess = (options = {}) => {
|
|
|
6451
8956
|
}),
|
|
6452
8957
|
[appType, fetchImpl, servicePrefix]
|
|
6453
8958
|
);
|
|
6454
|
-
const startSession =
|
|
8959
|
+
const startSession = useCallback11(
|
|
6455
8960
|
async (input = {}) => {
|
|
6456
8961
|
setLoading(true);
|
|
6457
8962
|
setError(null);
|
|
@@ -6497,11 +9002,11 @@ var usePublicAccess = (options = {}) => {
|
|
|
6497
9002
|
},
|
|
6498
9003
|
[client, reloadRuntime, setAccessToken, stableSessionInput]
|
|
6499
9004
|
);
|
|
6500
|
-
|
|
9005
|
+
useEffect13(() => {
|
|
6501
9006
|
if (!autoStart) return;
|
|
6502
9007
|
void startSession().catch(() => void 0);
|
|
6503
9008
|
}, [autoStart, startSession]);
|
|
6504
|
-
|
|
9009
|
+
useEffect13(
|
|
6505
9010
|
() => {
|
|
6506
9011
|
mountedRef.current = true;
|
|
6507
9012
|
return () => {
|
|
@@ -6530,11 +9035,11 @@ var PublicAccessGate = ({
|
|
|
6530
9035
|
...options
|
|
6531
9036
|
}) => {
|
|
6532
9037
|
const state = usePublicAccess(options);
|
|
6533
|
-
if (state.loading) return /* @__PURE__ */
|
|
9038
|
+
if (state.loading) return /* @__PURE__ */ jsx16(Fragment7, { children: fallback });
|
|
6534
9039
|
if (state.error) {
|
|
6535
|
-
return /* @__PURE__ */
|
|
9040
|
+
return /* @__PURE__ */ jsx16(Fragment7, { children: typeof errorFallback === "function" ? errorFallback(state.error) : errorFallback });
|
|
6536
9041
|
}
|
|
6537
|
-
return /* @__PURE__ */
|
|
9042
|
+
return /* @__PURE__ */ jsx16(Fragment7, { children });
|
|
6538
9043
|
};
|
|
6539
9044
|
var readTicketFromLocation = () => {
|
|
6540
9045
|
if (typeof window === "undefined") return void 0;
|
|
@@ -6542,7 +9047,9 @@ var readTicketFromLocation = () => {
|
|
|
6542
9047
|
};
|
|
6543
9048
|
var readPathFromLocation = () => typeof window === "undefined" ? void 0 : window.location.pathname;
|
|
6544
9049
|
export {
|
|
9050
|
+
AttachmentPreviewList,
|
|
6545
9051
|
AuthClientError,
|
|
9052
|
+
ImagePreviewGrid,
|
|
6546
9053
|
InitiatorApproverSelector,
|
|
6547
9054
|
LoginPage,
|
|
6548
9055
|
OpenXiangdaPageProvider,
|
|
@@ -6568,6 +9075,7 @@ export {
|
|
|
6568
9075
|
useCanAccessRoute,
|
|
6569
9076
|
useCurrentUser,
|
|
6570
9077
|
useDataSource,
|
|
9078
|
+
useFilePreview,
|
|
6571
9079
|
useFormViewPermissions,
|
|
6572
9080
|
useLoginMethods,
|
|
6573
9081
|
useMessage,
|