@pisell/materials 1.0.680 → 1.0.681
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +7 -7
- package/build/lowcode/render/default/view.js +33 -18
- package/build/lowcode/view.js +33 -18
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +4 -4
- package/es/components/dataSourceComponents/fields/Input.Mobile/serve.js +31 -3
- package/es/components/dataSourceComponents/fields/Input.Phone/serve.js +31 -3
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Upload/BaseUpload.js +103 -141
- package/es/components/dataSourceComponents/fields/Upload/WithMode.js +6 -3
- package/es/components/dataSourceComponents/fields/Upload/serve.js +13 -3
- package/es/components/dataSourceComponents/fields/Upload/shopUploadServe.d.ts +56 -0
- package/es/components/dataSourceComponents/fields/Upload/shopUploadServe.js +396 -0
- package/es/components/dataSourceComponents/fields/Upload/type.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/Upload/utils.js +17 -2
- package/es/components/dataSourceComponents/fields/index.d.ts +11 -11
- package/es/components/dataSourceComponents/hooks/usePlatform.d.ts +3 -0
- package/es/components/dataSourceComponents/hooks/usePlatform.js +12 -0
- package/es/components/table/Table/fields/index.d.ts +2 -2
- package/es/components/table/Table/utils.d.ts +1 -1
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +4 -4
- package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.js +37 -3
- package/lib/components/dataSourceComponents/fields/Input.Phone/serve.js +37 -3
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Upload/BaseUpload.js +48 -72
- package/lib/components/dataSourceComponents/fields/Upload/WithMode.js +11 -9
- package/lib/components/dataSourceComponents/fields/Upload/serve.js +11 -2
- package/lib/components/dataSourceComponents/fields/Upload/shopUploadServe.d.ts +56 -0
- package/lib/components/dataSourceComponents/fields/Upload/shopUploadServe.js +247 -0
- package/lib/components/dataSourceComponents/fields/Upload/type.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/Upload/utils.js +17 -2
- package/lib/components/dataSourceComponents/fields/index.d.ts +11 -11
- package/lib/components/dataSourceComponents/hooks/usePlatform.d.ts +3 -0
- package/lib/components/dataSourceComponents/hooks/usePlatform.js +51 -0
- package/lib/components/table/Table/fields/index.d.ts +2 -2
- package/lib/components/table/Table/utils.d.ts +1 -1
- package/lowcode/form-item-upload/meta.ts +11 -0
- package/package.json +2 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import useEngineContext from "../../../hooks/useEngineContext";
|
|
2
|
+
var usePlatform = function usePlatform() {
|
|
3
|
+
var _context$appHelper;
|
|
4
|
+
var context = useEngineContext();
|
|
5
|
+
var platform = (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.constants) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.platform;
|
|
6
|
+
return platform;
|
|
7
|
+
};
|
|
8
|
+
var useIsShop = function useIsShop() {
|
|
9
|
+
var platform = usePlatform();
|
|
10
|
+
return platform === 'shop';
|
|
11
|
+
};
|
|
12
|
+
export { usePlatform, useIsShop };
|
|
@@ -197,12 +197,12 @@ export declare const fieldList: ({
|
|
|
197
197
|
field_icon: string;
|
|
198
198
|
field_name: string;
|
|
199
199
|
field_type: string;
|
|
200
|
-
default_value:
|
|
200
|
+
default_value: boolean;
|
|
201
201
|
} | {
|
|
202
202
|
field_icon: string;
|
|
203
203
|
field_name: string;
|
|
204
204
|
field_type: string;
|
|
205
|
-
default_value:
|
|
205
|
+
default_value: string;
|
|
206
206
|
} | {
|
|
207
207
|
field_icon: string;
|
|
208
208
|
field_name: string;
|
|
@@ -167,7 +167,7 @@ export declare const getSettingKeyArrByMode: ({ filter, columnSetting, dataSourc
|
|
|
167
167
|
sort?: SortType | undefined;
|
|
168
168
|
mode: "" | "localStorage" | "remote";
|
|
169
169
|
currentViewMode: ModeType;
|
|
170
|
-
}) => ("
|
|
170
|
+
}) => ("view_mode" | "filter_setting" | "group_by" | "order_by" | "column_setting" | "gallery_setting")[];
|
|
171
171
|
export declare const omit: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
|
|
172
172
|
export declare const stringify: (obj: Record<string, any>) => string;
|
|
173
173
|
export {};
|
|
@@ -17,7 +17,7 @@ interface UseTablePropsProps {
|
|
|
17
17
|
* @returns
|
|
18
18
|
*/
|
|
19
19
|
declare const useTableProps: (props: UseTablePropsProps) => {
|
|
20
|
-
title: number | boolean |
|
|
20
|
+
title: number | boolean | JSX.Element | React.ReactFragment | (() => React.ReactNode) | null | undefined;
|
|
21
21
|
pagination: {
|
|
22
22
|
total: number;
|
|
23
23
|
current: number;
|
|
@@ -26,7 +26,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
|
|
|
26
26
|
showSizeChanger: boolean;
|
|
27
27
|
};
|
|
28
28
|
columns: import("./useColumns").Column[];
|
|
29
|
-
subTitle: number | boolean |
|
|
29
|
+
subTitle: number | boolean | JSX.Element | React.ReactFragment | (() => React.ReactNode) | null | undefined;
|
|
30
30
|
buttons: any[] | null;
|
|
31
31
|
filter: JSX.Element | null;
|
|
32
32
|
onRow: (record: any) => any;
|
|
@@ -52,7 +52,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
|
|
|
52
52
|
width: number;
|
|
53
53
|
align: "center" | "left" | "right";
|
|
54
54
|
fixed: false | "left" | "right";
|
|
55
|
-
type: "
|
|
55
|
+
type: "link" | "button";
|
|
56
56
|
items: OperationItem[];
|
|
57
57
|
} | undefined;
|
|
58
58
|
operationContent?: {
|
|
@@ -70,7 +70,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
|
|
|
70
70
|
useCustomAction: boolean;
|
|
71
71
|
actionType: string;
|
|
72
72
|
openMode: "modal" | "drawer";
|
|
73
|
-
openContentSize: "small" | "
|
|
73
|
+
openContentSize: "small" | "large" | "middle";
|
|
74
74
|
openTitle: string;
|
|
75
75
|
key: string;
|
|
76
76
|
} | undefined;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/components/dataSourceComponents/fields/Input.Mobile/serve.ts
|
|
@@ -23,8 +33,11 @@ __export(serve_exports, {
|
|
|
23
33
|
useCountries: () => useCountries
|
|
24
34
|
});
|
|
25
35
|
module.exports = __toCommonJS(serve_exports);
|
|
36
|
+
var import_react = require("react");
|
|
26
37
|
var import_ahooks = require("ahooks");
|
|
27
38
|
var import_utils = require("../../../table/utils");
|
|
39
|
+
var import_usePlatform = require("../../hooks/usePlatform");
|
|
40
|
+
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
|
28
41
|
var getCountryDataList = async () => {
|
|
29
42
|
const { data } = await import_utils.request.getRequest().get(`/country:list`, {}, {
|
|
30
43
|
isNocobase: true,
|
|
@@ -39,14 +52,35 @@ var getCountryDataList = async () => {
|
|
|
39
52
|
}));
|
|
40
53
|
};
|
|
41
54
|
var useCountries = () => {
|
|
42
|
-
const
|
|
55
|
+
const isShop = (0, import_usePlatform.useIsShop)();
|
|
56
|
+
const { appHelper } = (0, import_useEngineContext.default)();
|
|
57
|
+
const { data, run } = (0, import_ahooks.useRequest)(getCountryDataList, {
|
|
43
58
|
cacheKey: "phone-countries",
|
|
44
59
|
staleTime: 1e3 * 60 * 5,
|
|
45
60
|
// 5分钟后数据过期
|
|
46
|
-
cacheTime: 1e3 * 60 * 60
|
|
61
|
+
cacheTime: 1e3 * 60 * 60,
|
|
47
62
|
// 1小时后清除缓存
|
|
63
|
+
manual: true
|
|
48
64
|
});
|
|
49
|
-
|
|
65
|
+
(0, import_react.useEffect)(() => {
|
|
66
|
+
if (!isShop) {
|
|
67
|
+
run();
|
|
68
|
+
}
|
|
69
|
+
}, [isShop]);
|
|
70
|
+
const currentData = (0, import_react.useMemo)(() => {
|
|
71
|
+
var _a, _b, _c, _d;
|
|
72
|
+
if (isShop) {
|
|
73
|
+
const codeList = (_d = (_c = (_b = (_a = appHelper == null ? void 0 : appHelper.utils) == null ? void 0 : _a.store) == null ? void 0 : _b.getState()) == null ? void 0 : _c.global) == null ? void 0 : _d.codeList;
|
|
74
|
+
if (codeList) {
|
|
75
|
+
return codeList.map((item) => ({
|
|
76
|
+
...item,
|
|
77
|
+
prefix: `+${item.calling_code}`
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return data;
|
|
82
|
+
}, [isShop, data]);
|
|
83
|
+
return { data: currentData };
|
|
50
84
|
};
|
|
51
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
86
|
0 && (module.exports = {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/components/dataSourceComponents/fields/Input.Phone/serve.ts
|
|
@@ -23,8 +33,11 @@ __export(serve_exports, {
|
|
|
23
33
|
useCountries: () => useCountries
|
|
24
34
|
});
|
|
25
35
|
module.exports = __toCommonJS(serve_exports);
|
|
36
|
+
var import_react = require("react");
|
|
26
37
|
var import_ahooks = require("ahooks");
|
|
27
38
|
var import_utils = require("../../../table/utils");
|
|
39
|
+
var import_usePlatform = require("../../hooks/usePlatform");
|
|
40
|
+
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
|
28
41
|
var getCountryDataList = async () => {
|
|
29
42
|
const { data } = await import_utils.request.getRequest().get(`/country:list`, {}, {
|
|
30
43
|
isNocobase: true,
|
|
@@ -39,14 +52,35 @@ var getCountryDataList = async () => {
|
|
|
39
52
|
}));
|
|
40
53
|
};
|
|
41
54
|
var useCountries = () => {
|
|
42
|
-
const
|
|
55
|
+
const isShop = (0, import_usePlatform.useIsShop)();
|
|
56
|
+
const { appHelper } = (0, import_useEngineContext.default)();
|
|
57
|
+
const { data, run } = (0, import_ahooks.useRequest)(getCountryDataList, {
|
|
43
58
|
cacheKey: "phone-countries",
|
|
44
59
|
staleTime: 1e3 * 60 * 5,
|
|
45
60
|
// 5分钟后数据过期
|
|
46
|
-
cacheTime: 1e3 * 60 * 60
|
|
61
|
+
cacheTime: 1e3 * 60 * 60,
|
|
47
62
|
// 1小时后清除缓存
|
|
63
|
+
manual: true
|
|
48
64
|
});
|
|
49
|
-
|
|
65
|
+
(0, import_react.useEffect)(() => {
|
|
66
|
+
if (!isShop) {
|
|
67
|
+
run();
|
|
68
|
+
}
|
|
69
|
+
}, [isShop]);
|
|
70
|
+
const currentData = (0, import_react.useMemo)(() => {
|
|
71
|
+
var _a, _b, _c, _d;
|
|
72
|
+
if (isShop) {
|
|
73
|
+
const codeList = (_d = (_c = (_b = (_a = appHelper == null ? void 0 : appHelper.utils) == null ? void 0 : _a.store) == null ? void 0 : _b.getState()) == null ? void 0 : _c.global) == null ? void 0 : _d.codeList;
|
|
74
|
+
if (codeList) {
|
|
75
|
+
return codeList.map((item) => ({
|
|
76
|
+
...item,
|
|
77
|
+
prefix: `+${item.calling_code}`
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return data;
|
|
82
|
+
}, [isShop, data]);
|
|
83
|
+
return { data: currentData };
|
|
50
84
|
};
|
|
51
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
86
|
0 && (module.exports = {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
declare const Subdomain: React.FC<import("antd").InputProps & {
|
|
3
3
|
onChange: (value: string) => void;
|
|
4
4
|
onBlur?: ((e: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
5
|
-
rootDomain: "custom" | "
|
|
5
|
+
rootDomain: "custom" | "xzero" | "saas";
|
|
6
6
|
customDomain?: string | undefined;
|
|
7
7
|
value?: string | undefined;
|
|
8
8
|
tenantId: string;
|
|
@@ -44,7 +44,9 @@ var import_pisellUpload = __toESM(require("../../../pisellUpload"));
|
|
|
44
44
|
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
|
45
45
|
var import_locales = require("../../../../locales");
|
|
46
46
|
var import_constants = require("./constants");
|
|
47
|
+
var import_usePlatform = require("../../hooks/usePlatform");
|
|
47
48
|
var import_utils2 = require("./utils");
|
|
49
|
+
var import_shopUploadServe = require("./shopUploadServe");
|
|
48
50
|
var import_fallback = __toESM(require("./fallback.png"));
|
|
49
51
|
var import_index = require("./index.less");
|
|
50
52
|
var BaseUpload = (props) => {
|
|
@@ -67,58 +69,19 @@ var BaseUpload = (props) => {
|
|
|
67
69
|
getHeaders: propsGetHeaders,
|
|
68
70
|
...restProps
|
|
69
71
|
} = props;
|
|
72
|
+
console.log(typeMaxSizeMap, "typeMaxSizeMap");
|
|
73
|
+
const isShop = (0, import_usePlatform.useIsShop)();
|
|
70
74
|
const [fileList, setFileList] = (0, import_react.useState)([]);
|
|
71
75
|
const [previewImage, setPreviewImage] = (0, import_react.useState)("");
|
|
72
76
|
const [previewOpen, setPreviewOpen] = (0, import_react.useState)(false);
|
|
73
77
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
74
78
|
const [editMultilingualFile, setEditMultilingualFile] = (0, import_react.useState)(null);
|
|
75
|
-
const [errorImageMap, setErrorImageMap] = (0, import_react.useState)(
|
|
76
|
-
{}
|
|
77
|
-
);
|
|
78
79
|
const fileListRef = (0, import_react.useRef)([]);
|
|
79
80
|
(0, import_react.useEffect)(() => {
|
|
80
81
|
fileListRef.current = fileList;
|
|
81
82
|
}, [fileList]);
|
|
82
83
|
const { appHelper } = (0, import_useEngineContext.default)();
|
|
83
84
|
const { mediaUploadUrl, getHeaders } = (appHelper == null ? void 0 : appHelper.constants) || {};
|
|
84
|
-
const handleImageError = (0, import_react.useCallback)((file) => {
|
|
85
|
-
setErrorImageMap((prev) => ({
|
|
86
|
-
...prev,
|
|
87
|
-
[file.uid]: true
|
|
88
|
-
}));
|
|
89
|
-
}, []);
|
|
90
|
-
const checkImageUrl = (0, import_react.useCallback)((url) => {
|
|
91
|
-
return new Promise((resolve) => {
|
|
92
|
-
const img = document.createElement("img");
|
|
93
|
-
img.onload = () => resolve(true);
|
|
94
|
-
img.onerror = () => resolve(false);
|
|
95
|
-
img.src = url;
|
|
96
|
-
});
|
|
97
|
-
}, []);
|
|
98
|
-
const getItemUrl = (0, import_react.useCallback)(
|
|
99
|
-
async (file) => {
|
|
100
|
-
var _a, _b;
|
|
101
|
-
if (errorImageMap[file.uid]) {
|
|
102
|
-
return import_fallback.default;
|
|
103
|
-
}
|
|
104
|
-
const url = file.url || ((_b = (_a = file.response) == null ? void 0 : _a.data) == null ? void 0 : _b.url) || "";
|
|
105
|
-
if (!url) return "";
|
|
106
|
-
try {
|
|
107
|
-
const isValid = await checkImageUrl(url);
|
|
108
|
-
if (!isValid) {
|
|
109
|
-
setErrorImageMap((prev) => ({
|
|
110
|
-
...prev,
|
|
111
|
-
[file.uid]: true
|
|
112
|
-
}));
|
|
113
|
-
return import_fallback.default;
|
|
114
|
-
}
|
|
115
|
-
return url;
|
|
116
|
-
} catch (error) {
|
|
117
|
-
return import_fallback.default;
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
[errorImageMap]
|
|
121
|
-
);
|
|
122
85
|
(0, import_react.useEffect)(() => {
|
|
123
86
|
const currentValue = getValueFromFileList(fileListRef.current);
|
|
124
87
|
if (!fileListRef.current.length || !(0, import_utils2.isValueEqual)(value, currentValue)) {
|
|
@@ -127,7 +90,6 @@ var BaseUpload = (props) => {
|
|
|
127
90
|
multiple: !!multiple
|
|
128
91
|
});
|
|
129
92
|
setFileList(newFileList);
|
|
130
|
-
setErrorImageMap({});
|
|
131
93
|
}
|
|
132
94
|
}, [value, enableMultilingual, multiple]);
|
|
133
95
|
const getValueFromFileList = (fileList2) => {
|
|
@@ -419,36 +381,49 @@ var BaseUpload = (props) => {
|
|
|
419
381
|
),
|
|
420
382
|
[restProps.disabled, handleGlobeIconClick]
|
|
421
383
|
);
|
|
422
|
-
const
|
|
423
|
-
(
|
|
424
|
-
|
|
425
|
-
(0, import_react.useEffect)(() => {
|
|
426
|
-
getItemUrl(file).then(setItemUrl);
|
|
427
|
-
}, [file]);
|
|
428
|
-
const newNode = import_react.default.cloneElement(originNode, {
|
|
429
|
-
children: import_react.default.Children.map(originNode.props.children, (child) => {
|
|
430
|
-
if ((child == null ? void 0 : child.type) === "a") {
|
|
431
|
-
return import_react.default.cloneElement(child, {
|
|
432
|
-
children: import_react.default.Children.map(
|
|
433
|
-
child.props.children,
|
|
434
|
-
(grandChild) => {
|
|
435
|
-
if ((grandChild == null ? void 0 : grandChild.type) === "img") {
|
|
436
|
-
return import_react.default.cloneElement(grandChild, {
|
|
437
|
-
src: itemUrl,
|
|
438
|
-
onError: () => handleImageError(file)
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
return grandChild;
|
|
442
|
-
}
|
|
443
|
-
)
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
return child;
|
|
447
|
-
})
|
|
448
|
-
});
|
|
449
|
-
return newNode;
|
|
384
|
+
const customRequest = (0, import_react.useMemo)(() => {
|
|
385
|
+
if (!isShop) {
|
|
386
|
+
return {};
|
|
450
387
|
}
|
|
451
|
-
|
|
388
|
+
const handleUpload = (options) => {
|
|
389
|
+
const { onSuccess, onError, onProgress, file } = options;
|
|
390
|
+
const fileSize = file.size;
|
|
391
|
+
const baseTime = (0, import_utils2.getBaseTime)(fileSize);
|
|
392
|
+
let progress = 0;
|
|
393
|
+
setTimeout(() => {
|
|
394
|
+
onProgress == null ? void 0 : onProgress({ percent: 1 });
|
|
395
|
+
}, 200);
|
|
396
|
+
const timer = setInterval(() => {
|
|
397
|
+
if (progress < 30) {
|
|
398
|
+
progress += 5;
|
|
399
|
+
} else if (progress < 60) {
|
|
400
|
+
progress += 3;
|
|
401
|
+
} else if (progress < 80) {
|
|
402
|
+
progress += 2;
|
|
403
|
+
} else if (progress < 90) {
|
|
404
|
+
progress += 0.5;
|
|
405
|
+
}
|
|
406
|
+
if (progress >= 90) {
|
|
407
|
+
clearInterval(timer);
|
|
408
|
+
}
|
|
409
|
+
onProgress == null ? void 0 : onProgress({ percent: Math.min(90, progress) });
|
|
410
|
+
}, baseTime / 30);
|
|
411
|
+
(0, import_shopUploadServe.uploadFile)(file).then((res) => {
|
|
412
|
+
clearInterval(timer);
|
|
413
|
+
onProgress == null ? void 0 : onProgress({ percent: 95 });
|
|
414
|
+
setTimeout(() => {
|
|
415
|
+
onProgress == null ? void 0 : onProgress({ percent: 100 });
|
|
416
|
+
onSuccess == null ? void 0 : onSuccess(res);
|
|
417
|
+
}, 200);
|
|
418
|
+
}).catch((err) => {
|
|
419
|
+
clearInterval(timer);
|
|
420
|
+
onError == null ? void 0 : onError(err);
|
|
421
|
+
});
|
|
422
|
+
};
|
|
423
|
+
return {
|
|
424
|
+
customRequest: handleUpload
|
|
425
|
+
};
|
|
426
|
+
}, [isShop]);
|
|
452
427
|
const uploadProps = {
|
|
453
428
|
...restProps,
|
|
454
429
|
multiple,
|
|
@@ -483,7 +458,8 @@ var BaseUpload = (props) => {
|
|
|
483
458
|
}),
|
|
484
459
|
headers: (propsGetHeaders == null ? void 0 : propsGetHeaders()) || (getHeaders == null ? void 0 : getHeaders()),
|
|
485
460
|
beforeUpload,
|
|
486
|
-
className: "pisell-data-source-upload"
|
|
461
|
+
className: "pisell-data-source-upload",
|
|
462
|
+
...customRequest
|
|
487
463
|
};
|
|
488
464
|
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_pisellUpload.default, { ...uploadProps, fileList }, fileList.length >= calcMaxCount ? null : renderUploadButton(!!enableMultilingual)), /* @__PURE__ */ import_react.default.createElement(
|
|
489
465
|
import_pisellModal.default,
|
|
@@ -33,33 +33,35 @@ __export(WithMode_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(WithMode_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
|
-
var import_utils = require("
|
|
36
|
+
var import_utils = require("@pisell/utils");
|
|
37
|
+
var import_utils2 = require("../../dataSourceForm/utils");
|
|
37
38
|
var import_ReadPretty = __toESM(require("./ReadPretty"));
|
|
38
39
|
var import_BaseUpload = __toESM(require("./BaseUpload"));
|
|
39
40
|
var import_serve = require("./serve");
|
|
40
|
-
var
|
|
41
|
+
var import_usePlatform = require("../../hooks/usePlatform");
|
|
41
42
|
var Upload = (props) => {
|
|
42
|
-
const
|
|
43
|
+
const isShop = (0, import_usePlatform.useIsShop)();
|
|
44
|
+
const { presetType, mediaConfig: propsMediaConfig, presetTypeString: propsPresetTypeString } = props;
|
|
43
45
|
const { getExtensionsByIds, getMaxSizeByIds } = (0, import_serve.useMediaTypes)();
|
|
44
46
|
const { data: mediaConfig } = (0, import_serve.useMediaConfig)(propsMediaConfig);
|
|
45
|
-
const presetTypeString = getExtensionsByIds(presetType || []);
|
|
47
|
+
const presetTypeString = isShop ? propsPresetTypeString : getExtensionsByIds(presetType || []);
|
|
46
48
|
const maxSizeMap = getMaxSizeByIds(presetType || []);
|
|
47
49
|
const maxCount = (0, import_react.useMemo)(() => {
|
|
48
50
|
const minArr = [];
|
|
49
|
-
if ((0,
|
|
51
|
+
if ((0, import_utils.isNumber)(mediaConfig == null ? void 0 : mediaConfig.upload_onetime_limit)) {
|
|
50
52
|
minArr.push(mediaConfig == null ? void 0 : mediaConfig.upload_onetime_limit);
|
|
51
53
|
}
|
|
52
|
-
if ((0,
|
|
54
|
+
if ((0, import_utils.isNumber)(props.maxCount)) {
|
|
53
55
|
minArr.push(props.maxCount);
|
|
54
56
|
}
|
|
55
57
|
return Math.min(...minArr);
|
|
56
58
|
}, [mediaConfig, props.maxCount]);
|
|
57
59
|
const maxSize = (0, import_react.useMemo)(() => {
|
|
58
60
|
const minArr = [];
|
|
59
|
-
if ((0,
|
|
61
|
+
if ((0, import_utils.isNumber)(mediaConfig == null ? void 0 : mediaConfig.upload_maxsize)) {
|
|
60
62
|
minArr.push(mediaConfig == null ? void 0 : mediaConfig.upload_maxsize);
|
|
61
63
|
}
|
|
62
|
-
if ((0,
|
|
64
|
+
if ((0, import_utils.isNumber)(props.maxSize)) {
|
|
63
65
|
minArr.push(props.maxSize);
|
|
64
66
|
}
|
|
65
67
|
return Math.min(...minArr);
|
|
@@ -75,5 +77,5 @@ var Upload = (props) => {
|
|
|
75
77
|
}
|
|
76
78
|
);
|
|
77
79
|
};
|
|
78
|
-
var UploadWithMode = (0,
|
|
80
|
+
var UploadWithMode = (0, import_utils2.withMode)(Upload, import_ReadPretty.default);
|
|
79
81
|
var WithMode_default = UploadWithMode;
|
|
@@ -34,10 +34,12 @@ __export(serve_exports, {
|
|
|
34
34
|
useMediaTypes: () => useMediaTypes
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(serve_exports);
|
|
37
|
+
var import_react = require("react");
|
|
37
38
|
var import_ahooks = require("ahooks");
|
|
38
39
|
var import_utils = require("./utils");
|
|
39
40
|
var import_utils2 = require("../../../table/utils");
|
|
40
41
|
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
|
42
|
+
var import_usePlatform = require("../../hooks/usePlatform");
|
|
41
43
|
var getMediaTypeList = async () => {
|
|
42
44
|
const { data } = await import_utils2.request.getRequest().get(
|
|
43
45
|
`/media_type:list`,
|
|
@@ -64,13 +66,20 @@ var useMediaConfig = (mediaConfig) => {
|
|
|
64
66
|
};
|
|
65
67
|
};
|
|
66
68
|
var useMediaTypes = () => {
|
|
67
|
-
const
|
|
69
|
+
const isShop = (0, import_usePlatform.useIsShop)();
|
|
70
|
+
const { data, run } = (0, import_ahooks.useRequest)(getMediaTypeList, {
|
|
68
71
|
cacheKey: "media-type",
|
|
69
72
|
staleTime: 1e3 * 60 * 5,
|
|
70
73
|
// 5分钟后数据过期
|
|
71
|
-
cacheTime: 1e3 * 60 * 60
|
|
74
|
+
cacheTime: 1e3 * 60 * 60,
|
|
72
75
|
// 1小时后清除缓存
|
|
76
|
+
manual: true
|
|
73
77
|
});
|
|
78
|
+
(0, import_react.useEffect)(() => {
|
|
79
|
+
if (!isShop) {
|
|
80
|
+
run();
|
|
81
|
+
}
|
|
82
|
+
}, [isShop]);
|
|
74
83
|
const getExtensionsByIds = (ids) => {
|
|
75
84
|
const extensions = [];
|
|
76
85
|
(data || []).forEach((item) => {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { RcFile } from 'antd/es/upload';
|
|
2
|
+
export declare const filetypes: Record<string, any>;
|
|
3
|
+
/**
|
|
4
|
+
* @Title: 获取 阿里云 Signature
|
|
5
|
+
* @Describe:
|
|
6
|
+
* @Author: Wzw
|
|
7
|
+
*/
|
|
8
|
+
export declare const getPolicy: () => Promise<any>;
|
|
9
|
+
export declare const getPolicyFile: () => Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* @Title: 获取图片尺寸
|
|
12
|
+
* @Describe:
|
|
13
|
+
* @Author: Wzw
|
|
14
|
+
* @param {*} async
|
|
15
|
+
*/
|
|
16
|
+
export declare const getImageWidth: (file: any) => Promise<{
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* @Title: 重新生成文件名
|
|
22
|
+
* @Describe:
|
|
23
|
+
* @Author: Wzw
|
|
24
|
+
* @param {string} file
|
|
25
|
+
*/
|
|
26
|
+
export declare const formatFileName: (file?: any) => Promise<string>;
|
|
27
|
+
export declare const uploadFileAli: (file: any) => Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* @Title: base64转file
|
|
30
|
+
* @Describe:
|
|
31
|
+
* @Author: Wzw
|
|
32
|
+
* @param {any} dataurl
|
|
33
|
+
* @param {string} filename
|
|
34
|
+
*/
|
|
35
|
+
export declare const dataURLtoFile: (dataurl: any, filename: string) => File;
|
|
36
|
+
/**
|
|
37
|
+
* @Title: 获取视频封面
|
|
38
|
+
* @Describe:
|
|
39
|
+
* @Author: Wzw
|
|
40
|
+
* @param {any} file
|
|
41
|
+
*/
|
|
42
|
+
export declare const getVideoCover: (file: any) => Promise<unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* @Title: 获取腾讯云 Signature
|
|
45
|
+
* @Describe:
|
|
46
|
+
* @Author: Wzw
|
|
47
|
+
*/
|
|
48
|
+
export declare const getSignature: () => Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* @Title: 上传到腾讯云
|
|
51
|
+
* @Describe:
|
|
52
|
+
* @Author: Wzw
|
|
53
|
+
* @param {any} file
|
|
54
|
+
*/
|
|
55
|
+
export declare const uploadFileTencent: (file: any) => Promise<unknown>;
|
|
56
|
+
export declare const uploadFile: (file: RcFile) => Promise<any>;
|