@hzab/form-render-mobile 1.2.2 → 1.2.3-beta
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
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { axios } from "@hzab/data-model";
|
|
2
2
|
import OssUpload from "@hzab/utils/src/upload/ossUpload";
|
|
3
|
+
import { getFormRenderGlobalServeConfig } from "../../../globalConfig.ts";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 处理文件上传逻辑
|
|
@@ -13,7 +14,7 @@ export async function handleOssUpload(files, opt) {
|
|
|
13
14
|
const ossUpload = new OssUpload({
|
|
14
15
|
axios: opt.axios,
|
|
15
16
|
axiosConf: axiosConf,
|
|
16
|
-
serverUrl: ossUrl || "/api/v1/
|
|
17
|
+
serverUrl: ossUrl || getFormRenderGlobalServeConfig()?.serverUrl || "/api/v1/user/oss/getWebOssConfig",
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
const promise = [];
|
|
@@ -40,14 +41,15 @@ export async function handleOssUpload(files, opt) {
|
|
|
40
41
|
thumbnailParams,
|
|
41
42
|
})
|
|
42
43
|
.then((res) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
let tempUrl = res?.data?.data?.fileUrl;
|
|
45
|
+
if (getFormRenderGlobalServeConfig()?.showThumbnail) {
|
|
46
|
+
tempUrl = {
|
|
47
|
+
fileUrl: res?.data?.data?.fileUrl,
|
|
48
|
+
thumbnailUrl: res?.data?.data?.thumbnailUrl,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
resolve(tempUrl);
|
|
52
|
+
return Promise.resolve(tempUrl);
|
|
51
53
|
})
|
|
52
54
|
.catch(reject);
|
|
53
55
|
}),
|
|
@@ -58,7 +60,9 @@ export async function handleOssUpload(files, opt) {
|
|
|
58
60
|
return Promise.all(promise).then((filePromises) => {
|
|
59
61
|
filePromises?.forEach((item, idx) => {
|
|
60
62
|
_files[idx].ossUrl = item?.fileUrl;
|
|
61
|
-
|
|
63
|
+
if (getFormRenderGlobalServeConfig()?.showThumbnail) {
|
|
64
|
+
_files[idx].thumbnailUrl = item?.thumbnailUrl;
|
|
65
|
+
}
|
|
62
66
|
});
|
|
63
67
|
return Promise.resolve(_files);
|
|
64
68
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { nanoid } from "nanoid";
|
|
2
|
+
import { getFormRenderGlobalServeConfig } from "../../../globalConfig";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 建立一个可以存取该 file 的 url
|
|
@@ -132,7 +133,9 @@ export function handleInputFileList(_fileList, maxCount = 1, opt) {
|
|
|
132
133
|
if (typeof file === "string") {
|
|
133
134
|
const uid = nanoid();
|
|
134
135
|
let thumbnailUrl = "";
|
|
135
|
-
|
|
136
|
+
if (getFormRenderGlobalServeConfig()?.showThumbnail) {
|
|
137
|
+
thumbnailUrl = `${file}${opt?.thumbnailParams ? isSelf(opt?.selfUrlList, file) + opt?.thumbnailParams : ""}`;
|
|
138
|
+
}
|
|
136
139
|
return {
|
|
137
140
|
name: uid,
|
|
138
141
|
uid: uid,
|
|
@@ -2,6 +2,7 @@ import { useState, useEffect } from "react";
|
|
|
2
2
|
import { ImageViewer } from "antd-mobile";
|
|
3
3
|
|
|
4
4
|
import { loadHeaderImage } from "../../common/img";
|
|
5
|
+
import { getFormRenderGlobalServeConfig } from "../../../../globalConfig";
|
|
5
6
|
|
|
6
7
|
import "./index.less";
|
|
7
8
|
|
|
@@ -31,7 +32,12 @@ function ImagePreviewer(props) {
|
|
|
31
32
|
return (
|
|
32
33
|
<div className={`uploader-image-previewer ${props.className || ""}`}>
|
|
33
34
|
<div className="uploader-image-previewer-img-wrap" onClick={onPreview}>
|
|
34
|
-
<img
|
|
35
|
+
<img
|
|
36
|
+
className="uploader-image-previewer-img"
|
|
37
|
+
src={getFormRenderGlobalServeConfig()?.showThumbnail ? thumbnailSrc : imgUrl}
|
|
38
|
+
alt={props.alt}
|
|
39
|
+
onClick={onPreview}
|
|
40
|
+
/>
|
|
35
41
|
</div>
|
|
36
42
|
<ImageViewer
|
|
37
43
|
image={imgUrl}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
window.formRenderGlobalServeConfig = {}
|
|
2
|
+
/** 获取全局配置(url、是否显示缩略图地址) */
|
|
3
|
+
export function getFormRenderGlobalServeConfig() {
|
|
4
|
+
return window.formRenderGlobalServeConfig || {}
|
|
5
|
+
}
|
|
6
|
+
/** 设置全局配置(url、是否显示缩略图地址)*/
|
|
7
|
+
export function setFormRenderGlobalServeConfigs(data) {
|
|
8
|
+
Object.assign(window.formRenderGlobalServeConfig || {}, data);
|
|
9
|
+
return window.formRenderGlobalServeConfig || {}
|
|
10
|
+
}
|
|
11
|
+
/** 设置全局单个配置(url、是否显示缩略图地址)*/
|
|
12
|
+
export function setFormRenderGlobalServeConfig(key, data) {
|
|
13
|
+
window.formRenderGlobalServeConfig[key] = data
|
|
14
|
+
return window.formRenderGlobalServeConfig || {}
|
|
15
|
+
}
|