szld-libs 0.2.16 → 0.2.18
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/dist/szld-components.es.js +3145 -3117
- package/dist/szld-components.umd.js +35 -35
- package/es/hooks/useCaptcha.js +27 -3
- package/es/index.js +5 -2
- package/es/utils/hmacSHA512.js +1 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +8 -0
- package/lib/hooks/useCaptcha.js +27 -3
- package/lib/index.js +3 -0
- package/lib/utils/hmacSHA512.js +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +8 -0
- package/package.json +1 -1
package/es/hooks/useCaptcha.js
CHANGED
|
@@ -3,18 +3,42 @@ import { SyncOutlined } from "@ant-design/icons";
|
|
|
3
3
|
import { useRequest } from "ahooks";
|
|
4
4
|
import { Button } from "antd";
|
|
5
5
|
import _ from "lodash";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import { formatResponse } from "../utils/index";
|
|
6
8
|
function useCaptcha(props) {
|
|
7
9
|
const { imgKey = "Img" } = props;
|
|
8
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
data: _data,
|
|
12
|
+
loading,
|
|
13
|
+
error,
|
|
14
|
+
refresh
|
|
15
|
+
} = useRequest(props.request, {
|
|
9
16
|
debounceWait: 300,
|
|
10
17
|
ready: true,
|
|
11
18
|
retryCount: 3
|
|
12
19
|
});
|
|
20
|
+
const data = useMemo(() => formatResponse(_data), [_data]);
|
|
13
21
|
const renderCaptcha = () => {
|
|
14
22
|
if (error) {
|
|
15
|
-
return /* @__PURE__ */ jsx(
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
Button,
|
|
25
|
+
{
|
|
26
|
+
type: "link",
|
|
27
|
+
title: "验证码加载失败,请重试",
|
|
28
|
+
icon: /* @__PURE__ */ jsx(SyncOutlined, {}),
|
|
29
|
+
onClick: refresh,
|
|
30
|
+
children: "点击重试"
|
|
31
|
+
}
|
|
32
|
+
);
|
|
16
33
|
}
|
|
17
|
-
return /* @__PURE__ */ jsx(
|
|
34
|
+
return /* @__PURE__ */ jsx(
|
|
35
|
+
"img",
|
|
36
|
+
{
|
|
37
|
+
src: _.get(data, [imgKey]),
|
|
38
|
+
style: { height: "100%", objectFit: "contain", cursor: "pointer" },
|
|
39
|
+
onClick: refresh
|
|
40
|
+
}
|
|
41
|
+
);
|
|
18
42
|
};
|
|
19
43
|
return { data, renderCaptcha, loading, refresh };
|
|
20
44
|
}
|
package/es/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
3
|
import ReactDOM from "react-dom/client";
|
|
4
4
|
import { BrowserRouter } from "react-router-dom";
|
|
5
|
-
import { EditTable } from "./main";
|
|
5
|
+
import { HmacSHA512, EditTable } from "./main";
|
|
6
6
|
import { Form } from "antd";
|
|
7
7
|
import "./utils/compression-file";
|
|
8
8
|
const Demo = () => {
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
new HmacSHA512("17283");
|
|
11
|
+
}, []);
|
|
9
12
|
Form.useForm();
|
|
10
13
|
const [list, setList] = useState([
|
|
11
14
|
{
|
package/es/utils/hmacSHA512.js
CHANGED
package/es/utils/index.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export declare const arrayDeduplication: (key: string, arr: any[]) => any[];
|
|
|
12
12
|
export declare const JSONParse: (value: string) => any;
|
|
13
13
|
export declare function uuid(): string;
|
|
14
14
|
export declare const forceReload: () => void;
|
|
15
|
+
export declare const formatResponse: (res: any) => any;
|
package/es/utils/index.js
CHANGED
|
@@ -111,11 +111,19 @@ const forceReload = () => {
|
|
|
111
111
|
window.location.reload();
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
|
+
const formatResponse = (res) => {
|
|
115
|
+
if (typeof res === "string") {
|
|
116
|
+
const index = res.indexOf(",");
|
|
117
|
+
return JSON.parse(res.slice(index + 1));
|
|
118
|
+
}
|
|
119
|
+
return res;
|
|
120
|
+
};
|
|
114
121
|
export {
|
|
115
122
|
JSONParse,
|
|
116
123
|
arrayDeduplication,
|
|
117
124
|
filterObject,
|
|
118
125
|
forceReload,
|
|
126
|
+
formatResponse,
|
|
119
127
|
getBase64,
|
|
120
128
|
getFileSuffix,
|
|
121
129
|
getFileType,
|
package/lib/hooks/useCaptcha.js
CHANGED
|
@@ -4,18 +4,42 @@ const icons = require("@ant-design/icons");
|
|
|
4
4
|
const ahooks = require("ahooks");
|
|
5
5
|
const antd = require("antd");
|
|
6
6
|
const _ = require("lodash");
|
|
7
|
+
const react = require("react");
|
|
8
|
+
const index = require("../utils/index");
|
|
7
9
|
function useCaptcha(props) {
|
|
8
10
|
const { imgKey = "Img" } = props;
|
|
9
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
data: _data,
|
|
13
|
+
loading,
|
|
14
|
+
error,
|
|
15
|
+
refresh
|
|
16
|
+
} = ahooks.useRequest(props.request, {
|
|
10
17
|
debounceWait: 300,
|
|
11
18
|
ready: true,
|
|
12
19
|
retryCount: 3
|
|
13
20
|
});
|
|
21
|
+
const data = react.useMemo(() => index.formatResponse(_data), [_data]);
|
|
14
22
|
const renderCaptcha = () => {
|
|
15
23
|
if (error) {
|
|
16
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
25
|
+
antd.Button,
|
|
26
|
+
{
|
|
27
|
+
type: "link",
|
|
28
|
+
title: "验证码加载失败,请重试",
|
|
29
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.SyncOutlined, {}),
|
|
30
|
+
onClick: refresh,
|
|
31
|
+
children: "点击重试"
|
|
32
|
+
}
|
|
33
|
+
);
|
|
17
34
|
}
|
|
18
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
|
+
"img",
|
|
37
|
+
{
|
|
38
|
+
src: _.get(data, [imgKey]),
|
|
39
|
+
style: { height: "100%", objectFit: "contain", cursor: "pointer" },
|
|
40
|
+
onClick: refresh
|
|
41
|
+
}
|
|
42
|
+
);
|
|
19
43
|
};
|
|
20
44
|
return { data, renderCaptcha, loading, refresh };
|
|
21
45
|
}
|
package/lib/index.js
CHANGED
|
@@ -7,6 +7,9 @@ const main = require("./main");
|
|
|
7
7
|
const antd = require("antd");
|
|
8
8
|
require("./utils/compression-file");
|
|
9
9
|
const Demo = () => {
|
|
10
|
+
react.useEffect(() => {
|
|
11
|
+
new main.HmacSHA512("17283");
|
|
12
|
+
}, []);
|
|
10
13
|
antd.Form.useForm();
|
|
11
14
|
const [list, setList] = react.useState([
|
|
12
15
|
{
|
package/lib/utils/hmacSHA512.js
CHANGED
package/lib/utils/index.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export declare const arrayDeduplication: (key: string, arr: any[]) => any[];
|
|
|
12
12
|
export declare const JSONParse: (value: string) => any;
|
|
13
13
|
export declare function uuid(): string;
|
|
14
14
|
export declare const forceReload: () => void;
|
|
15
|
+
export declare const formatResponse: (res: any) => any;
|
package/lib/utils/index.js
CHANGED
|
@@ -113,10 +113,18 @@ const forceReload = () => {
|
|
|
113
113
|
window.location.reload();
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
+
const formatResponse = (res) => {
|
|
117
|
+
if (typeof res === "string") {
|
|
118
|
+
const index = res.indexOf(",");
|
|
119
|
+
return JSON.parse(res.slice(index + 1));
|
|
120
|
+
}
|
|
121
|
+
return res;
|
|
122
|
+
};
|
|
116
123
|
exports.JSONParse = JSONParse;
|
|
117
124
|
exports.arrayDeduplication = arrayDeduplication;
|
|
118
125
|
exports.filterObject = filterObject;
|
|
119
126
|
exports.forceReload = forceReload;
|
|
127
|
+
exports.formatResponse = formatResponse;
|
|
120
128
|
exports.getBase64 = getBase64;
|
|
121
129
|
exports.getFileSuffix = getFileSuffix;
|
|
122
130
|
exports.getFileType = getFileType;
|