@deepinnet-components/pc 0.0.14 → 0.0.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.
@@ -17,13 +17,13 @@ import { Form, FormButtonGroup, FormItem, Input } from '@formily/antd-v5';
17
17
  import { createForm, onFieldValueChange } from '@formily/core';
18
18
  import { createSchemaField } from '@formily/react';
19
19
  import { Button, Spin, message } from 'antd';
20
- import md5 from 'md5';
21
20
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
22
21
  import OrgTreeSelect from "../../../OrgTreeSelect";
23
22
  import OrgSelect from "../../../OrgSelect";
24
23
  import RoleSelect from "../../../RoleSelect";
25
24
  import MemberSelect from "../../../MemberSelect";
26
25
  import ValueContext from "../../../context";
26
+ import { hashWithCryptoJS } from "../../../utils";
27
27
  var SchemaField = createSchemaField({
28
28
  components: {
29
29
  FormItem: FormItem,
@@ -164,7 +164,8 @@ var CreateAccount = function CreateAccount(props) {
164
164
  var ApiService = contextValue.ApiService,
165
165
  Components = contextValue.Components,
166
166
  userType = contextValue.userType,
167
- isMultiRole = contextValue.isMultiRole;
167
+ isMultiRole = contextValue.isMultiRole,
168
+ passwordEncryption = contextValue.passwordEncryption;
168
169
  var getAccountDetail = /*#__PURE__*/function () {
169
170
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
170
171
  var params, _yield$ApiService$get, data, _data$departmentFlatD, _data$userMemberBindD;
@@ -277,7 +278,7 @@ var CreateAccount = function CreateAccount(props) {
277
278
  params = {
278
279
  phone: values.phone.trim(),
279
280
  roleCodeList: Array.isArray(values.roleCodeList) ? values.roleCodeList : [values.roleCodeList],
280
- password: md5(values.password.trim()),
281
+ password: hashWithCryptoJS(values.password.trim(), passwordEncryption),
281
282
  // departmentIdList: values.orgArr || [],
282
283
  departmentIdList: [values.orgArr[values.orgArr.length - 1]],
283
284
  userType: userType,
@@ -9,6 +9,7 @@ export interface MainProps {
9
9
  userType?: string;
10
10
  showDataAuth?: boolean;
11
11
  isMultiRole?: boolean;
12
+ passwordEncryption?: string;
12
13
  }
13
14
  declare const Index: React.FC<MainProps>;
14
15
  export default Index;
@@ -57,7 +57,9 @@ var Index = function Index(props) {
57
57
  _props$showDataAuth = props.showDataAuth,
58
58
  showDataAuth = _props$showDataAuth === void 0 ? false : _props$showDataAuth,
59
59
  _props$isMultiRole = props.isMultiRole,
60
- isMultiRole = _props$isMultiRole === void 0 ? true : _props$isMultiRole;
60
+ isMultiRole = _props$isMultiRole === void 0 ? true : _props$isMultiRole,
61
+ _props$passwordEncryp = props.passwordEncryption,
62
+ passwordEncryption = _props$passwordEncryp === void 0 ? 'md5' : _props$passwordEncryp;
61
63
  var _useState = useState(),
62
64
  _useState2 = _slicedToArray(_useState, 2),
63
65
  value = _useState2[0],
@@ -202,7 +204,8 @@ var Index = function Index(props) {
202
204
  navigate: navigate,
203
205
  userType: userType,
204
206
  showDataAuth: showDataAuth,
205
- isMultiRole: isMultiRole
207
+ isMultiRole: isMultiRole,
208
+ passwordEncryption: passwordEncryption
206
209
  });
207
210
  }, []);
208
211
  if (!value) return null;
@@ -1 +1,2 @@
1
1
  export declare function getUrlQuery(): any;
2
+ export declare function hashWithCryptoJS(message: string, algorithm?: 'md5' | 'sha1' | 'sha256' | 'sha512'): string;
@@ -1,3 +1,5 @@
1
+ import CryptoJS from 'crypto-js';
2
+
1
3
  // 获取url参数
2
4
  export function getUrlQuery() {
3
5
  var kvObj = {};
@@ -10,4 +12,21 @@ export function getUrlQuery() {
10
12
  });
11
13
  }
12
14
  return kvObj;
15
+ }
16
+
17
+ // 加密
18
+ export function hashWithCryptoJS(message) {
19
+ var algorithm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'sha256';
20
+ switch (algorithm) {
21
+ case 'md5':
22
+ return CryptoJS.MD5(message).toString();
23
+ case 'sha1':
24
+ return CryptoJS.SHA1(message).toString();
25
+ case 'sha256':
26
+ return CryptoJS.SHA256(message).toString();
27
+ case 'sha512':
28
+ return CryptoJS.SHA512(message).toString();
29
+ default:
30
+ throw new Error("Unsupported algorithm: ".concat(algorithm));
31
+ }
13
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepinnet-components/pc",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -48,11 +48,13 @@
48
48
  "@formily/antd-v5": "^1.2.3",
49
49
  "@formily/core": "^2.3.2",
50
50
  "@formily/react": "^2.3.2",
51
+ "@types/crypto-js": "^4.2.2",
51
52
  "@types/md5": "^2.3.5",
52
53
  "@types/shortid": "^2.2.0",
53
54
  "ahooks": "^3.9.0",
54
55
  "antd": "^5.16.1",
55
56
  "axios": "^1.5.1",
57
+ "crypto-js": "^4.2.0",
56
58
  "dayjs": "^1.11.13",
57
59
  "lodash-es": "^4.17.21",
58
60
  "md5": "^2.3.0",