@ecoding/components.antd 0.1.14 → 0.1.15
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/lib/core/async-cascader/index.js +2 -1
- package/lib/core/async-select/index.js +2 -1
- package/lib/core/async-transfer/index.js +2 -1
- package/lib/core/quill/index.js +2 -1
- package/lib/core/single-file-upload/index.js +2 -1
- package/lib/core/single-img-upload/index.js +2 -1
- package/lib/helpers/http.d.ts +8 -2
- package/lib/helpers/http.js +26 -12
- package/package.json +2 -2
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import React, { useCallback, useEffect, useState, memo, useMemo } from "react";
|
|
11
11
|
import { Cascader } from "antd";
|
|
12
12
|
import { LoadingOutlined } from "@ant-design/icons";
|
|
13
|
-
import {
|
|
13
|
+
import { http } from "../../helpers/http";
|
|
14
14
|
import { isSomething } from "@ecoding/helper.is";
|
|
15
15
|
import { jsonFormatNewKey } from "@ecoding/helper.json";
|
|
16
16
|
const setSourceChilren = (source, key, res) => {
|
|
@@ -30,6 +30,7 @@ const setSourceChilren = (source, key, res) => {
|
|
|
30
30
|
return source;
|
|
31
31
|
};
|
|
32
32
|
const AsyncCascader = memo((props) => {
|
|
33
|
+
const r = http.getRequest();
|
|
33
34
|
const [loading, setLoading] = useState(true);
|
|
34
35
|
const [options, setOptions] = useState([]);
|
|
35
36
|
const interfaceUrls = useMemo(() => props.ifaces || [], []);
|
|
@@ -10,11 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import React, { useEffect, useState, memo, useMemo } from "react";
|
|
11
11
|
import { Select } from "antd";
|
|
12
12
|
import { LoadingOutlined } from "@ant-design/icons";
|
|
13
|
-
import {
|
|
13
|
+
import { http } from "../../helpers/http";
|
|
14
14
|
import { isSomething } from "@ecoding/helper.is";
|
|
15
15
|
import { jsonFormatNewKey } from "@ecoding/helper.json";
|
|
16
16
|
const { Option } = Select;
|
|
17
17
|
const AsyncSlect = memo((props) => {
|
|
18
|
+
const r = http.getRequest();
|
|
18
19
|
const [loading, setLoading] = useState(true);
|
|
19
20
|
const [options, setOptions] = useState([]);
|
|
20
21
|
const iface = useMemo(() => props.iface, []);
|
|
@@ -11,10 +11,11 @@ import React, { useEffect, useState, memo, useMemo, useCallback } from "react";
|
|
|
11
11
|
import { Transfer } from "antd";
|
|
12
12
|
import zhCN from "antd/lib/locale/zh_CN";
|
|
13
13
|
import { LoadingOutlined } from "@ant-design/icons";
|
|
14
|
-
import {
|
|
14
|
+
import { http } from "../../helpers/http";
|
|
15
15
|
import { isSomething } from "@ecoding/helper.is";
|
|
16
16
|
import { jsonFormatNewKey } from "@ecoding/helper.json";
|
|
17
17
|
const AsyncTransfer = memo((props) => {
|
|
18
|
+
const r = http.getRequest();
|
|
18
19
|
const [loading, setLoading] = useState(true);
|
|
19
20
|
const [dataSource, setDataSource] = useState(props.dataSource || []);
|
|
20
21
|
const [targetKeys, setTargetKeys] = useState([]);
|
package/lib/core/quill/index.js
CHANGED
|
@@ -10,9 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import React, { useMemo, useCallback, useState, useRef, lazy } from "react";
|
|
11
11
|
import { Upload, message } from "antd";
|
|
12
12
|
import Toast from "../../core/toast";
|
|
13
|
-
import {
|
|
13
|
+
import { http } from "../../helpers/http";
|
|
14
14
|
const ReactQuill = lazy(() => import(/* webpackChunkName: "ReactQuill" */ /* webpackPrefetch: true */ "react-quill"));
|
|
15
15
|
const Quill = (props) => {
|
|
16
|
+
const r = http.getRequest();
|
|
16
17
|
const upRef = useRef();
|
|
17
18
|
const quillRef = useRef();
|
|
18
19
|
const [urlParams, setUrlParams] = useState("");
|
|
@@ -12,8 +12,9 @@ import { Upload, message, Button } from "antd";
|
|
|
12
12
|
import { UploadOutlined } from "@ant-design/icons";
|
|
13
13
|
import { buildURL } from "@ecoding/helper.url";
|
|
14
14
|
import Toast from "../../core/toast";
|
|
15
|
-
import {
|
|
15
|
+
import { http } from "../../helpers/http";
|
|
16
16
|
const SingleFileUpload = (props) => {
|
|
17
|
+
const r = http.getRequest();
|
|
17
18
|
const [urlParams, setUrlParams] = useState({});
|
|
18
19
|
const action = useMemo(() => {
|
|
19
20
|
return /^http|^\/\//i.test(props.action) ? buildURL(props.action, urlParams) : buildURL(`${r.domain}${props.action}`, urlParams);
|
|
@@ -12,8 +12,9 @@ import { Upload, message, Space } from "antd";
|
|
|
12
12
|
import { LoadingOutlined, PlusOutlined, DeleteOutlined } from "@ant-design/icons";
|
|
13
13
|
import { buildURL } from "@ecoding/helper.url";
|
|
14
14
|
import Toast from "../../core/toast";
|
|
15
|
-
import {
|
|
15
|
+
import { http } from "../../helpers/http";
|
|
16
16
|
const ImgUpload = (props) => {
|
|
17
|
+
const r = http.getRequest();
|
|
17
18
|
const [loading, setLoading] = useState(false);
|
|
18
19
|
const [imageUrl, setImageUrl] = useState(props.value || "");
|
|
19
20
|
const [urlParams, setUrlParams] = useState({});
|
package/lib/helpers/http.d.ts
CHANGED
package/lib/helpers/http.js
CHANGED
|
@@ -2,15 +2,29 @@ import axios from "axios";
|
|
|
2
2
|
import Loading from "../core/loading";
|
|
3
3
|
import Toast from "../core/toast";
|
|
4
4
|
import R from "@ecoding/helper.request.hook";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
5
|
+
class Http {
|
|
6
|
+
setOutRequest(r) {
|
|
7
|
+
this.__outRequest = r;
|
|
8
|
+
}
|
|
9
|
+
getRequest() {
|
|
10
|
+
if (this.__outRequest) {
|
|
11
|
+
return this.__outRequest;
|
|
12
|
+
}
|
|
13
|
+
if (this.__request) {
|
|
14
|
+
return this.__request;
|
|
15
|
+
}
|
|
16
|
+
this.__request = new R(axios);
|
|
17
|
+
this.__request.setDomain("");
|
|
18
|
+
this.__request.setFinallyHook(() => {
|
|
19
|
+
Loading.hide();
|
|
20
|
+
});
|
|
21
|
+
this.__request.setErrorUiHook((err) => {
|
|
22
|
+
Toast.error({
|
|
23
|
+
duration: 20000,
|
|
24
|
+
title: err.message || err.msg
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return this.__request;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export const http = new Http();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/components.antd",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"author": "cxc",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"react-quill": "^2.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "abc00f66d218168dc8cdb8a29cee4e833d335a98"
|
|
46
46
|
}
|