@hzab/form-render 1.5.0-beta3 → 1.5.0
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/CHANGELOG.md +1 -0
- package/package.json +1 -1
- package/src/common/schema-handler.ts +4 -4
- package/src/components/LocationPicker/components/ModalContent/index.tsx +0 -1
- package/src/components/Upload/common/customRequest.ts +8 -2
- package/src/components/Upload/common/fileName.ts +11 -2
- package/src/components/Upload/common/handleIOFileList.ts +3 -0
- package/src/components/Upload/common/ossUpload.js +6 -0
- package/src/components/Upload/common/utils.js +17 -0
- package/src/components/Upload/uploader.jsx +6 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -14,7 +14,7 @@ export const nanoid = customAlphabet(alphabet, 20);
|
|
14
14
|
*
|
15
15
|
* 2. `$form` is the current Form Model
|
16
16
|
*
|
17
|
-
* 3. `$deps` is the dependencies value
|
17
|
+
* 3. `$deps` is the dependencies value 仅在 run 中存在
|
18
18
|
*
|
19
19
|
* 4. `$observable` function is used to create an persistent observable state object
|
20
20
|
*
|
@@ -30,7 +30,7 @@ export const nanoid = customAlphabet(alphabet, 20);
|
|
30
30
|
**/
|
31
31
|
|
32
32
|
/** formily 执行函数作用域相关参数 */
|
33
|
-
export const formilyDataKeys = ["$form", "$self", "$observable", "$effect", "$memo", "$props", "$values"
|
33
|
+
export const formilyDataKeys = ["$form", "$self", "$observable", "$effect", "$memo", "$props", "$values"];
|
34
34
|
|
35
35
|
/** 自增容器 */
|
36
36
|
export const arrayList = ["ArrayTable", "ArrayCards"];
|
@@ -127,9 +127,9 @@ export const bindCallback = (opt) => {
|
|
127
127
|
}
|
128
128
|
// 设置一个唯一的函数名,用于从 schema scope 传入 formily 事件执行中
|
129
129
|
const fnKey = "fnKey_" + nanoid();
|
130
|
-
// 设置 schemaScope 中的唯一函数,获取执行函数作用域 $form, $self, $observable, $effect, $memo, $props, $values
|
130
|
+
// 设置 schemaScope 中的唯一函数,获取执行函数作用域 $form, $self, $observable, $effect, $memo, $props, $values 相关参数
|
131
131
|
schemaScope._$tempData[fnKey] = function (params, sourceArgs) {
|
132
|
-
const { $form, $self, $observable, $effect, $memo, $props, $values
|
132
|
+
const { $form, $self, $observable, $effect, $memo, $props, $values } = params;
|
133
133
|
// 处理结果数据,各组件返回数据格式不一致
|
134
134
|
const res = handleChangeValue({
|
135
135
|
...opt,
|
@@ -220,7 +220,6 @@ export const ModalContent = observer((props: any) => {
|
|
220
220
|
function onClickMap(ev) {
|
221
221
|
const { lng: evLon, lat: evLat } = ev.lnglat || {};
|
222
222
|
if (element === "Polypoint") {
|
223
|
-
console.log(evLon, evLat);
|
224
223
|
setPickPoint(evLon, evLat, { changeCenter: true });
|
225
224
|
}
|
226
225
|
}
|
@@ -3,8 +3,14 @@ import LUploadOss from "./ossUpload";
|
|
3
3
|
export const getOfflineUploadRequest = (props) => {
|
4
4
|
return ({ action, data, file, filename, headers, method, onSuccess, onProgress, onError }) => {
|
5
5
|
// TODO: 处理请求逻辑
|
6
|
-
|
7
|
-
|
6
|
+
file.ossPromise = new Promise((resolve) => {
|
7
|
+
resolve(file);
|
8
|
+
})
|
9
|
+
.then((file) => {
|
10
|
+
onSuccess(file);
|
11
|
+
return file;
|
12
|
+
})
|
13
|
+
.catch(onError);
|
8
14
|
};
|
9
15
|
};
|
10
16
|
|
@@ -7,6 +7,9 @@ import { nanoid } from "./nanoid";
|
|
7
7
|
* @returns
|
8
8
|
*/
|
9
9
|
export function getFileName(fileUrl) {
|
10
|
+
if (typeof fileUrl !== "string") {
|
11
|
+
return;
|
12
|
+
}
|
10
13
|
const res = fileUrl?.match(/([^\/]+?)\.[^\/\.]+$/);
|
11
14
|
if (res && res.length > 0) {
|
12
15
|
return res?.[1] || res?.[0];
|
@@ -21,6 +24,9 @@ export function getFileName(fileUrl) {
|
|
21
24
|
* @returns
|
22
25
|
*/
|
23
26
|
export function getFullFileName(fileUrl) {
|
27
|
+
if (typeof fileUrl !== "string") {
|
28
|
+
return;
|
29
|
+
}
|
24
30
|
const res = fileUrl?.match(/[^\/]+?\.[^\/\.]+$/);
|
25
31
|
if (res && res.length > 0) {
|
26
32
|
return res[0];
|
@@ -34,10 +40,13 @@ export function getFullFileName(fileUrl) {
|
|
34
40
|
* @param {*} str
|
35
41
|
* @returns
|
36
42
|
*/
|
37
|
-
export const mergeFileName = function (fileName, str) {
|
43
|
+
export const mergeFileName = function (fileName, str = "") {
|
44
|
+
if (typeof fileName !== "string") {
|
45
|
+
return "";
|
46
|
+
}
|
38
47
|
const name = fileName?.match(/([^\/]+?)\.[^\/]+$/)?.[1] || "";
|
39
48
|
const suffix = fileName?.match(/[^\/]+?\.([^\/]+)$/)?.[1] || "";
|
40
|
-
return `${name}${str}.${suffix}`;
|
49
|
+
return `${name}${str ?? ""}.${suffix}`;
|
41
50
|
};
|
42
51
|
|
43
52
|
/**
|
@@ -97,6 +97,9 @@ export const objStrToObj = function (objStr) {
|
|
97
97
|
* @returns
|
98
98
|
*/
|
99
99
|
export function mergePreviewConfig(uri, previewConfig) {
|
100
|
+
if (typeof uri !== "string") {
|
101
|
+
return uri;
|
102
|
+
}
|
100
103
|
let _uri = uri?.trim();
|
101
104
|
// base64 直接返回
|
102
105
|
if (isBase64Str(_uri)) {
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { axios } from "@hzab/data-model";
|
2
2
|
import { getFileNameByFileObj } from "./fileName";
|
3
|
+
import { formatDirStr, mergeDirStr } from "./utils";
|
3
4
|
|
4
5
|
export function getSignature(opt = {}) {
|
5
6
|
const { serverUrl = "/api/v1/user/oss/getWebOssConfig" } = opt;
|
@@ -12,6 +13,9 @@ export function getSignature(opt = {}) {
|
|
12
13
|
return Promise.resolve(window.__ossSignatureRes);
|
13
14
|
}
|
14
15
|
const { axios: _ax = axios, params = {}, axiosConf } = opt;
|
16
|
+
// 处理 dir 格式,必须为非 / 开头, / 结尾。如: test/
|
17
|
+
params.dir = formatDirStr(params.dir);
|
18
|
+
|
15
19
|
return _ax
|
16
20
|
.get(serverUrl, {
|
17
21
|
...axiosConf,
|
@@ -39,6 +43,8 @@ class OssUpload {
|
|
39
43
|
}
|
40
44
|
|
41
45
|
getSignature(serverUrl = this.serverUrl, opt) {
|
46
|
+
// dir 前缀 oss-upload 文件目录
|
47
|
+
opt.params.dir = mergeDirStr("web-upload/", opt.params.dir);
|
42
48
|
return getSignature({
|
43
49
|
...opt,
|
44
50
|
serverUrl,
|
@@ -1,5 +1,22 @@
|
|
1
1
|
import { nanoid } from "nanoid";
|
2
2
|
|
3
|
+
/**
|
4
|
+
* 格式化 dir 字符串,必须为非 / 开头, / 结尾。如: test/
|
5
|
+
* @param {*} dir
|
6
|
+
* @returns
|
7
|
+
*/
|
8
|
+
export const formatDirStr = function (dir) {
|
9
|
+
return dir?.replace(/^\/(.*)\/*$/, "$1").replace(/(.?=*)\/*$/, "$1/");
|
10
|
+
};
|
11
|
+
|
12
|
+
/**
|
13
|
+
* 合并 dir 字符串
|
14
|
+
* @param {*} dir
|
15
|
+
*/
|
16
|
+
export const mergeDirStr = function (dir1, dir2) {
|
17
|
+
return `${formatDirStr(dir1 || "")}${formatDirStr(dir2 || "")}`;
|
18
|
+
};
|
19
|
+
|
3
20
|
/**
|
4
21
|
* 建立一个可以存取该 file 的 url
|
5
22
|
* @param {Object} file 文件
|
@@ -102,7 +102,12 @@ export function Uploader({ onChange, ...props }) {
|
|
102
102
|
let _file = _files[i]?.originFileObj || _files[i];
|
103
103
|
if (!_file.url) {
|
104
104
|
_file.url = (await _file.ossPromise) || _file.ossUrl || typeof _file === "string" ? _file : "";
|
105
|
-
|
105
|
+
if (typeof _file.url === "string") {
|
106
|
+
_files[i].url = _file.url;
|
107
|
+
} else if (typeof _file?.url?.ossUrl === "string") {
|
108
|
+
_file.url = _file?.url?.ossUrl;
|
109
|
+
_files[i].url = _file?.url?.ossUrl;
|
110
|
+
}
|
106
111
|
}
|
107
112
|
}
|
108
113
|
|