@deepinnet-components/pc 0.0.26 → 0.0.27

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.
@@ -18,12 +18,12 @@ import { createForm, onFieldValueChange } from '@formily/core';
18
18
  import { createSchemaField } from '@formily/react';
19
19
  import { Button, Spin, message } from 'antd';
20
20
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
21
- import OrgTreeSelect from "../../../OrgTreeSelect";
21
+ import MemberSelect from "../../../MemberSelect";
22
22
  import OrgSelect from "../../../OrgSelect";
23
+ import OrgTreeSelect from "../../../OrgTreeSelect";
23
24
  import RoleSelect from "../../../RoleSelect";
24
- import MemberSelect from "../../../MemberSelect";
25
25
  import ValueContext from "../../../context";
26
- import { hashWithCryptoJS } from "../../../utils";
26
+ import { hashWithCryptoJS, sm4Encrypt } from "../../../utils";
27
27
  var SchemaField = createSchemaField({
28
28
  components: {
29
29
  FormItem: FormItem,
@@ -109,16 +109,14 @@ var schema = {
109
109
  'x-validator': [{
110
110
  required: true,
111
111
  message: '请输入密码'
112
- }
113
- // {
114
- // validator: (val: any) => {
115
- // const regex = /^(?=.*[a-z])(?=.*[A-Z]).{8,}$/
116
- // if (val && !regex.test(val)) {
117
- // return '请输入包含大小写字母且长度不低于8位的密码'
118
- // }
119
- // },
120
- // },
121
- ],
112
+ }, {
113
+ validator: function validator(val) {
114
+ var regex = /^(?=(?:.*[a-z]))(?=(?:.*[A-Z]))(?=(?:.*\d)).{8,}$|^(?=(?:.*[a-z]))(?=(?:.*[A-Z]))(?=(?:.*[^A-Za-z0-9])).{8,}$|^(?=(?:.*[a-z]))(?=(?:.*\d))(?=(?:.*[^A-Za-z0-9])).{8,}$|^(?=(?:.*[A-Z]))(?=(?:.*\d))(?=(?:.*[^A-Za-z0-9])).{8,}$/;
115
+ if (val && !regex.test(val)) {
116
+ return '密码需至少包含大、小写字母、数字以及特殊符号3种,且不少于8位';
117
+ }
118
+ }
119
+ }],
122
120
  'x-reactions': [{
123
121
  when: '{{addOrEdit === "add"}}',
124
122
  fulfill: {
@@ -165,7 +163,8 @@ var CreateAccount = function CreateAccount(props) {
165
163
  Components = contextValue.Components,
166
164
  userType = contextValue.userType,
167
165
  isMultiRole = contextValue.isMultiRole,
168
- passwordEncryption = contextValue.passwordEncryption;
166
+ passwordEncryption = contextValue.passwordEncryption,
167
+ passwordEncryptionNeedSalt = contextValue.passwordEncryptionNeedSalt;
169
168
  var getAccountDetail = /*#__PURE__*/function () {
170
169
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
171
170
  var params, _yield$ApiService$get, data, _data$departmentFlatD, _data$userMemberBindD;
@@ -253,7 +252,7 @@ var CreateAccount = function CreateAccount(props) {
253
252
  var canSubmit = useRef(true);
254
253
  var handleSubmit = /*#__PURE__*/function () {
255
254
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
256
- var values, params, _yield$ApiService$sav, success, _params, _yield$ApiService$sav2, _success;
255
+ var values, params, _sm4Encrypt, key, encryptedData, _yield$ApiService$sav, success, _params, _yield$ApiService$sav2, _success;
257
256
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
258
257
  while (1) switch (_context2.prev = _context2.next) {
259
258
  case 0:
@@ -268,7 +267,7 @@ var CreateAccount = function CreateAccount(props) {
268
267
  case 4:
269
268
  values = _context2.sent;
270
269
  if (!(addOrEdit === 'add')) {
271
- _context2.next = 18;
270
+ _context2.next = 19;
272
271
  break;
273
272
  }
274
273
  _context2.prev = 6;
@@ -281,10 +280,15 @@ var CreateAccount = function CreateAccount(props) {
281
280
  userType: userType,
282
281
  bindMemberId: values.bindMemberId
283
282
  };
283
+ if (passwordEncryptionNeedSalt) {
284
+ _sm4Encrypt = sm4Encrypt(params.password), key = _sm4Encrypt.key, encryptedData = _sm4Encrypt.encryptedData;
285
+ params.password = encryptedData;
286
+ params.key = key;
287
+ }
284
288
  setLoading(true);
285
- _context2.next = 11;
289
+ _context2.next = 12;
286
290
  return ApiService.saveAccount(params);
287
- case 11:
291
+ case 12:
288
292
  _yield$ApiService$sav = _context2.sent;
289
293
  success = _yield$ApiService$sav.success;
290
294
  if (success) {
@@ -292,17 +296,17 @@ var CreateAccount = function CreateAccount(props) {
292
296
  onClose === null || onClose === void 0 || onClose();
293
297
  onSuccess === null || onSuccess === void 0 || onSuccess();
294
298
  }
295
- case 14:
296
- _context2.prev = 14;
299
+ case 15:
300
+ _context2.prev = 15;
297
301
  setLoading(false);
298
302
  canSubmit.current = true;
299
- return _context2.finish(14);
300
- case 18:
303
+ return _context2.finish(15);
304
+ case 19:
301
305
  if (!(addOrEdit === 'edit')) {
302
- _context2.next = 31;
306
+ _context2.next = 32;
303
307
  break;
304
308
  }
305
- _context2.prev = 19;
309
+ _context2.prev = 20;
306
310
  _params = {
307
311
  accountNo: actionRow.accountNo,
308
312
  roleCodeList: Array.isArray(values.roleCodeList) ? values.roleCodeList : [values.roleCodeList],
@@ -312,9 +316,9 @@ var CreateAccount = function CreateAccount(props) {
312
316
  bindMemberId: values.bindMemberId
313
317
  };
314
318
  setLoading(true);
315
- _context2.next = 24;
319
+ _context2.next = 25;
316
320
  return ApiService.saveAccount(_params);
317
- case 24:
321
+ case 25:
318
322
  _yield$ApiService$sav2 = _context2.sent;
319
323
  _success = _yield$ApiService$sav2.success;
320
324
  if (_success) {
@@ -322,16 +326,16 @@ var CreateAccount = function CreateAccount(props) {
322
326
  onClose === null || onClose === void 0 || onClose();
323
327
  onSuccess === null || onSuccess === void 0 || onSuccess();
324
328
  }
325
- case 27:
326
- _context2.prev = 27;
329
+ case 28:
330
+ _context2.prev = 28;
327
331
  setLoading(false);
328
332
  canSubmit.current = true;
329
- return _context2.finish(27);
330
- case 31:
333
+ return _context2.finish(28);
334
+ case 32:
331
335
  case "end":
332
336
  return _context2.stop();
333
337
  }
334
- }, _callee2, null, [[6,, 14, 18], [19,, 27, 31]]);
338
+ }, _callee2, null, [[6,, 15, 19], [20,, 28, 32]]);
335
339
  }));
336
340
  return function handleSubmit() {
337
341
  return _ref2.apply(this, arguments);
@@ -10,6 +10,7 @@ export interface MainProps {
10
10
  showDataAuth?: boolean;
11
11
  isMultiRole?: boolean;
12
12
  passwordEncryption?: string;
13
+ passwordEncryptionNeedSalt?: boolean;
13
14
  hideDeleteAccountBtn?: boolean;
14
15
  hideMemberType?: Boolean;
15
16
  showMemberPilot?: Boolean;
@@ -60,6 +60,8 @@ var Index = function Index(props) {
60
60
  isMultiRole = _props$isMultiRole === void 0 ? true : _props$isMultiRole,
61
61
  _props$passwordEncryp = props.passwordEncryption,
62
62
  passwordEncryption = _props$passwordEncryp === void 0 ? 'md5' : _props$passwordEncryp,
63
+ _props$passwordEncryp2 = props.passwordEncryptionNeedSalt,
64
+ passwordEncryptionNeedSalt = _props$passwordEncryp2 === void 0 ? false : _props$passwordEncryp2,
63
65
  _props$hideDeleteAcco = props.hideDeleteAccountBtn,
64
66
  hideDeleteAccountBtn = _props$hideDeleteAcco === void 0 ? false : _props$hideDeleteAcco,
65
67
  _props$hideMemberType = props.hideMemberType,
@@ -212,6 +214,7 @@ var Index = function Index(props) {
212
214
  showDataAuth: showDataAuth,
213
215
  isMultiRole: isMultiRole,
214
216
  passwordEncryption: passwordEncryption,
217
+ passwordEncryptionNeedSalt: passwordEncryptionNeedSalt,
215
218
  hideDeleteAccountBtn: hideDeleteAccountBtn,
216
219
  hideMemberType: hideMemberType,
217
220
  showMemberPilot: showMemberPilot
@@ -1,2 +1,6 @@
1
1
  export declare function getUrlQuery(): any;
2
2
  export declare function hashWithCryptoJS(message: string, algorithm?: 'md5' | 'sha1' | 'sha256' | 'sha512'): string;
3
+ export declare function sm4Encrypt(data: string): {
4
+ key: string;
5
+ encryptedData: string;
6
+ };
@@ -1,4 +1,5 @@
1
1
  import CryptoJS from 'crypto-js';
2
+ import { SM4 } from 'gm-crypto';
2
3
 
3
4
  // 获取url参数
4
5
  export function getUrlQuery() {
@@ -29,4 +30,25 @@ export function hashWithCryptoJS(message) {
29
30
  default:
30
31
  throw new Error("Unsupported algorithm: ".concat(algorithm));
31
32
  }
33
+ }
34
+
35
+ // 生成32位的16进制数
36
+ function generate32HexDigits() {
37
+ var result = '';
38
+ for (var i = 0; i < 32; i++) {
39
+ result += Math.floor(Math.random() * 16).toString(16);
40
+ }
41
+ return result;
42
+ }
43
+
44
+ // SM4 国标对称加密
45
+ export function sm4Encrypt(data) {
46
+ var key = generate32HexDigits();
47
+ return {
48
+ key: key,
49
+ encryptedData: SM4.encrypt(data, key, {
50
+ inputEncoding: 'utf8',
51
+ outputEncoding: 'base64'
52
+ })
53
+ };
32
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepinnet-components/pc",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -56,6 +56,7 @@
56
56
  "axios": "^1.5.1",
57
57
  "crypto-js": "^4.2.0",
58
58
  "dayjs": "^1.11.13",
59
+ "gm-crypto": "^0.1.12",
59
60
  "lodash-es": "^4.17.21",
60
61
  "md5": "^2.3.0",
61
62
  "react-router-dom": "^7.6.2",