zmdms-webui 0.0.26 → 0.0.28

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.
@@ -1,15 +1,49 @@
1
1
  import { __assign } from '../_virtual/_tslib.js';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useEffect } from 'react';
3
4
  import { Form, Checkbox } from 'antd';
5
+ import { decrypt, encrypt } from './utils.js';
4
6
  import MemoInput from '../input/input.js';
5
7
  import IconFont from '../icon/index.js';
6
8
  import Button from '../button/button.js';
7
9
 
8
10
  var Item = Form.Item;
11
+ var LOCAL_KEY = "6fr6x";
12
+ var USERNAME_KEY = "PUsvG";
13
+ var USERPWS_KEY = "kVhfO";
14
+ var KEY = "simide";
9
15
  var Login = function (props) {
10
16
  var loginLogo = props.loginLogo, loginBg = props.loginBg, onFinishHandle = props.onFinishHandle, loading = props.loading;
11
17
  var form = Form.useForm()[0];
18
+ useEffect(function () {
19
+ var localData = localStorage.getItem(LOCAL_KEY);
20
+ if (localData) {
21
+ try {
22
+ var parseLocalData = JSON.parse(localData);
23
+ var username = decrypt(parseLocalData[USERNAME_KEY], KEY);
24
+ var password = decrypt(parseLocalData[USERPWS_KEY], KEY);
25
+ if (username && password) {
26
+ form.setFieldsValue({
27
+ username: username,
28
+ password: password,
29
+ remember: true,
30
+ });
31
+ }
32
+ }
33
+ catch (err) {
34
+ console.log(err);
35
+ }
36
+ }
37
+ }, [form]);
12
38
  var onFinish = function (values) {
39
+ var _a;
40
+ // 如果需要记住密码
41
+ if (values.remember) {
42
+ localStorage.setItem(LOCAL_KEY, JSON.stringify((_a = {},
43
+ _a[USERNAME_KEY] = encrypt(values.username, KEY),
44
+ _a[USERPWS_KEY] = encrypt(values.password, KEY),
45
+ _a)));
46
+ }
13
47
  // 内部处理
14
48
  onFinishHandle && onFinishHandle(values);
15
49
  };
@@ -18,12 +52,12 @@ var Login = function (props) {
18
52
  required: true,
19
53
  message: "请输入您的账号",
20
54
  },
21
- ] }, { children: jsx(MemoInput, { size: "large", prefix: jsx(IconFont, { type: "icon-yonghu", style: { fontSize: "14px", color: "rgba(0,0,0,.65)" } }) }) })), jsx(Item, __assign({ label: "\u8BF7\u8F93\u5165\u60A8\u7684\u5BC6\u7801", name: "password", rules: [
55
+ ] }, { children: jsx(MemoInput, { size: "large", autoComplete: "username", prefix: jsx(IconFont, { type: "icon-yonghu", style: { fontSize: "14px", color: "rgba(0,0,0,.65)" } }) }) })), jsx(Item, __assign({ label: "\u8BF7\u8F93\u5165\u60A8\u7684\u5BC6\u7801", name: "password", rules: [
22
56
  {
23
57
  required: true,
24
58
  message: "请输入您的密码",
25
59
  },
26
- ] }, { children: jsx(MemoInput.Password, { size: "large", prefix: jsx(IconFont, { type: "icon-mima", style: { fontSize: "14px", color: "rgba(0,0,0,.65)" } }) }) })), jsx(Item, { children: jsx(Button, __assign({ htmlType: "submit", block: true, className: "form__item--button", loading: loading }, { children: "\u767B\u5F55" })) }), jsxs("div", __assign({ className: "form__item--remember" }, { children: [jsx(Item, __assign({ name: "remember", valuePropName: "checked" }, { children: jsx(Checkbox, { children: "\u8BB0\u4F4F\u5BC6\u7801" }) })), jsx("div", __assign({ className: "form__item--remember-forget" }, { children: "\u5FD8\u8BB0\u5BC6\u7801" }))] }))] })) })));
60
+ ] }, { children: jsx(MemoInput.Password, { size: "large", autoComplete: "current-password", prefix: jsx(IconFont, { type: "icon-mima", style: { fontSize: "14px", color: "rgba(0,0,0,.65)" } }) }) })), jsx(Item, { children: jsx(Button, __assign({ htmlType: "submit", block: true, className: "form__item--button", loading: loading }, { children: "\u767B\u5F55" })) }), jsxs("div", __assign({ className: "form__item--remember" }, { children: [jsx(Item, __assign({ name: "remember", valuePropName: "checked" }, { children: jsx(Checkbox, { children: "\u8BB0\u4F4F\u5BC6\u7801" }) })), jsx("div", __assign({ className: "form__item--remember-forget" }, { children: "\u5FD8\u8BB0\u5BC6\u7801" }))] }))] })) })));
27
61
  };
28
62
  Login.displayName = "ZTXK_WEBUI_Login";
29
63
 
@@ -0,0 +1,26 @@
1
+ // 加密函数
2
+ function encrypt(message, key) {
3
+ var encryptedMessage = "";
4
+ var keyLength = key.length;
5
+ for (var i = 0; i < message.length; i++) {
6
+ var char = message.charAt(i);
7
+ var keyChar = key.charAt(i % keyLength);
8
+ var encryptedChar = String.fromCharCode(char.charCodeAt(0) + keyChar.charCodeAt(0));
9
+ encryptedMessage += encryptedChar;
10
+ }
11
+ return encryptedMessage;
12
+ }
13
+ // 解密函数
14
+ function decrypt(encryptedMessage, key) {
15
+ var decryptedMessage = "";
16
+ var keyLength = key.length;
17
+ for (var i = 0; i < encryptedMessage.length; i++) {
18
+ var char = encryptedMessage.charAt(i);
19
+ var keyChar = key.charAt(i % keyLength);
20
+ var decryptedChar = String.fromCharCode(char.charCodeAt(0) - keyChar.charCodeAt(0));
21
+ decryptedMessage += decryptedChar;
22
+ }
23
+ return decryptedMessage;
24
+ }
25
+
26
+ export { decrypt, encrypt };
@@ -1,7 +1,9 @@
1
1
  import { __assign } from '../_virtual/_tslib.js';
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { useCallback } from 'react';
3
4
  import { unescapeString } from 'zmdms-utils';
4
5
  import MemoSelect from './select.js';
6
+ import { Divider } from 'antd';
5
7
 
6
8
  function useRenderChildren(props) {
7
9
  var list = props.list, defaultList = props.defaultList, _a = props.dataKey, dataKey = _a === void 0 ? "id" : _a, _b = props.titleKey, titleKey = _b === void 0 ? "name" : _b, joinKey = props.joinKey, joinStr = props.joinStr, lineFeedKey = props.lineFeedKey, lineFeedStr = props.lineFeedStr, showAll = props.showAll, children = props.children, disabledValues = props.disabledValues;
@@ -84,6 +86,11 @@ function useRenderChildren(props) {
84
86
  resultList: resultList,
85
87
  renderChildren: renderChildren,
86
88
  };
89
+ }
90
+ function useDropdownRender(renderDom) {
91
+ return useCallback(function (menu) {
92
+ return (jsxs(Fragment, { children: [menu, jsx(Divider, { style: { marginTop: 0, marginBottom: "4px" } }), jsx("div", __assign({ style: { padding: "0 4px" } }, { children: renderDom }))] }));
93
+ }, [renderDom]);
87
94
  }
88
95
 
89
- export { useRenderChildren };
96
+ export { useDropdownRender, useRenderChildren };
@@ -50,6 +50,10 @@ interface ISelectProps extends SelectProps {
50
50
  * 是否支持远程搜索
51
51
  */
52
52
  isRemoteSearch?: boolean;
53
+ /**
54
+ * 是否需要添加底部按钮
55
+ */
56
+ dropdownButton?: React.ReactNode;
53
57
  }
54
58
  type ISECRET_COMBOBOX_MODE_DO_NOT_USE = typeof Select.SECRET_COMBOBOX_MODE_DO_NOT_USE;
55
59
  type IOption = typeof Select.Option;
@@ -2,7 +2,7 @@ import { __rest, __assign } from '../_virtual/_tslib.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { memo, forwardRef, useCallback } from 'react';
4
4
  import { Select as Select$1 } from 'antd';
5
- import { useRenderChildren } from './hooks.js';
5
+ import { useRenderChildren, useDropdownRender } from './hooks.js';
6
6
  import debounce from 'lodash/debounce';
7
7
 
8
8
  function textContent(children) {
@@ -24,7 +24,7 @@ function textContent(children) {
24
24
  return textContent(children);
25
25
  }
26
26
  var Select = function (props, ref) {
27
- var list = props.list, defaultList = props.defaultList, _a = props.dataKey, dataKey = _a === void 0 ? "id" : _a, _b = props.titleKey, titleKey = _b === void 0 ? "name" : _b, joinKey = props.joinKey, _c = props.joinStr, joinStr = _c === void 0 ? "-" : _c, lineFeedKey = props.lineFeedKey, _d = props.lineFeedStr, lineFeedStr = _d === void 0 ? "-" : _d, showAll = props.showAll, children = props.children, disabledValues = props.disabledValues, _e = props.dropdownMatchSelectWidth, dropdownMatchSelectWidth = _e === void 0 ? 100 : _e, onChange = props.onChange, onSearch = props.onSearch, isRemoteSearch = props.isRemoteSearch, resetProps = __rest(props, ["list", "defaultList", "dataKey", "titleKey", "joinKey", "joinStr", "lineFeedKey", "lineFeedStr", "showAll", "children", "disabledValues", "dropdownMatchSelectWidth", "onChange", "onSearch", "isRemoteSearch"]);
27
+ var list = props.list, defaultList = props.defaultList, _a = props.dataKey, dataKey = _a === void 0 ? "id" : _a, _b = props.titleKey, titleKey = _b === void 0 ? "name" : _b, joinKey = props.joinKey, _c = props.joinStr, joinStr = _c === void 0 ? "-" : _c, lineFeedKey = props.lineFeedKey, _d = props.lineFeedStr, lineFeedStr = _d === void 0 ? "-" : _d, showAll = props.showAll, children = props.children, disabledValues = props.disabledValues, _e = props.dropdownMatchSelectWidth, dropdownMatchSelectWidth = _e === void 0 ? 100 : _e, onChange = props.onChange, onSearch = props.onSearch, isRemoteSearch = props.isRemoteSearch, dropdownButton = props.dropdownButton, dropdownRender = props.dropdownRender, resetProps = __rest(props, ["list", "defaultList", "dataKey", "titleKey", "joinKey", "joinStr", "lineFeedKey", "lineFeedStr", "showAll", "children", "disabledValues", "dropdownMatchSelectWidth", "onChange", "onSearch", "isRemoteSearch", "dropdownButton", "dropdownRender"]);
28
28
  /**
29
29
  * 渲染子元素
30
30
  */
@@ -41,6 +41,10 @@ var Select = function (props, ref) {
41
41
  children: children,
42
42
  disabledValues: disabledValues,
43
43
  }), renderChildren = _f.renderChildren, resultList = _f.resultList;
44
+ /**
45
+ * 底部渲染按钮
46
+ */
47
+ var dropdownButtonHandle = useDropdownRender(dropdownButton);
44
48
  /**
45
49
  * onChange方法代理
46
50
  */
@@ -97,7 +101,11 @@ var Select = function (props, ref) {
97
101
  var text = textContent(option === null || option === void 0 ? void 0 : option.children);
98
102
  return (text === null || text === void 0 ? void 0 : text.toLowerCase().indexOf(input.toLowerCase().trim())) >= 0;
99
103
  };
100
- return (jsx(Select$1, __assign({ showArrow: true, dropdownMatchSelectWidth: dropdownMatchSelectWidth, onChange: onChangeHandle, showSearch: true, onSearch: onDebounceSearchHandle, filterOption: isRemoteSearch ? false : filterOptionHandle }, resetProps, { ref: ref }, { children: renderChildren() })));
104
+ return (jsx(Select$1, __assign({ showArrow: true, dropdownMatchSelectWidth: dropdownMatchSelectWidth, onChange: onChangeHandle, showSearch: true, onSearch: onDebounceSearchHandle, filterOption: isRemoteSearch ? false : filterOptionHandle, dropdownRender: dropdownRender
105
+ ? dropdownRender
106
+ : dropdownButton
107
+ ? dropdownButtonHandle
108
+ : undefined }, resetProps, { ref: ref }, { children: renderChildren() })));
101
109
  };
102
110
  var MemoSelect = memo(forwardRef(Select));
103
111
  MemoSelect.displayName = "ZTXK_WEBUI_Select";