aldehyde 0.2.188 → 0.2.190

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.
Files changed (37) hide show
  1. package/lib/controls/action/utils.d.ts.map +1 -1
  2. package/lib/controls/action/utils.js +0 -1
  3. package/lib/controls/action/utils.js.map +1 -1
  4. package/lib/layout/MainPage.d.ts.map +1 -1
  5. package/lib/layout/MainPage.js +0 -1
  6. package/lib/layout/MainPage.js.map +1 -1
  7. package/lib/layout2/LayoutContext.d.ts +6 -0
  8. package/lib/layout2/LayoutContext.d.ts.map +1 -1
  9. package/lib/layout2/LayoutContext.js +36 -1
  10. package/lib/layout2/LayoutContext.js.map +1 -1
  11. package/lib/layout2/header.d.ts.map +1 -1
  12. package/lib/layout2/header.js +13 -8
  13. package/lib/layout2/header.js.map +1 -1
  14. package/lib/layout2/page.d.ts.map +1 -1
  15. package/lib/layout2/page.js +2 -1
  16. package/lib/layout2/page.js.map +1 -1
  17. package/lib/layout2/sider.d.ts.map +1 -1
  18. package/lib/layout2/sider.js +9 -27
  19. package/lib/layout2/sider.js.map +1 -1
  20. package/lib/login/login.js +15 -4
  21. package/lib/login/login.js.map +1 -1
  22. package/lib/login2/Login.d.ts.map +1 -1
  23. package/lib/login2/Login.js +59 -5
  24. package/lib/login2/Login.js.map +1 -1
  25. package/lib/table/query-table.d.ts.map +1 -1
  26. package/lib/table/query-table.js +2 -1
  27. package/lib/table/query-table.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/aldehyde/controls/action/utils.tsx +0 -1
  30. package/src/aldehyde/layout/MainPage.tsx +0 -1
  31. package/src/aldehyde/layout2/LayoutContext.tsx +55 -1
  32. package/src/aldehyde/layout2/header.tsx +19 -16
  33. package/src/aldehyde/layout2/page.tsx +5 -1
  34. package/src/aldehyde/layout2/sider.tsx +11 -43
  35. package/src/aldehyde/login/login.tsx +4 -4
  36. package/src/aldehyde/login2/Login.tsx +86 -9
  37. package/src/aldehyde/table/query-table.tsx +2 -1
@@ -9,7 +9,10 @@ import {
9
9
  } from "./util/menu.util";
10
10
  import { useLocale } from "../locale/useLocale";
11
11
  import { generate } from "@ant-design/colors";
12
- import { useLayoutContext } from "./LayoutContext";
12
+ import {
13
+ MenuItemIdToFirstFloorIdxMapType,
14
+ useLayoutContext,
15
+ } from "./LayoutContext";
13
16
 
14
17
  type SiderPropsType = {
15
18
  menuList: MenuType[];
@@ -18,8 +21,6 @@ type SiderPropsType = {
18
21
 
19
22
  type MenuItem = Required<MenuProps>["items"][number];
20
23
 
21
- type MenuItemIdToFirstFloorIdxMapType = { [key: string]: number };
22
-
23
24
  type SecoundFloorMenuList = MenuType[][];
24
25
 
25
26
  const items: MenuItem[] = [
@@ -149,35 +150,6 @@ const items: MenuItem[] = [
149
150
  },
150
151
  ];
151
152
 
152
- /**
153
- * @param menuList 自定义的menu
154
- * @param isRoot 是否为根节点
155
- * @param rootIdx 根节点层级
156
- * @param mp menu item 对应的根节点 map
157
- * @returns menu item 对应的根节点 map
158
- * @desc 获取 menu item 每一项对应其根节点的 map
159
- */
160
- const getMenuItemIdToFirstFloorIdxMap = (
161
- menuList: MenuType[],
162
- isRoot: boolean,
163
- rootIdx?: number,
164
- mp: MenuItemIdToFirstFloorIdxMapType = {}
165
- ): MenuItemIdToFirstFloorIdxMapType => {
166
- for (let i = 0; i < menuList.length; i++) {
167
- const menuItem = menuList[i];
168
- if (isRoot)
169
- Array.isArray(menuItem.children) &&
170
- getMenuItemIdToFirstFloorIdxMap(menuItem.children, false, i, mp);
171
- else {
172
- mp[menuItem.id] = rootIdx;
173
- Array.isArray(menuItem.children) &&
174
- getMenuItemIdToFirstFloorIdxMap(menuItem.children, false, rootIdx, mp);
175
- }
176
- }
177
-
178
- return mp;
179
- };
180
-
181
153
  /**
182
154
  * @param menuList 自定义的menu
183
155
  * @returns 下标为 n 对应第 n 个根节点对应的第二层级menu
@@ -207,7 +179,7 @@ const getSecoundFloorMenuList = (
207
179
  const { useToken } = theme;
208
180
 
209
181
  const Sider: React.FC<SiderPropsType> = ({ menuList, style }) => {
210
- const { setDocumentTitle } = useLayoutContext();
182
+ const { setDocumentTitle, menuItemIdToFirstFloorIdxMap } = useLayoutContext();
211
183
 
212
184
  // token
213
185
  const {
@@ -218,15 +190,8 @@ const Sider: React.FC<SiderPropsType> = ({ menuList, style }) => {
218
190
  // translate
219
191
  const { translate, getLocale } = useLocale();
220
192
 
221
- const menuItemIdToFirstFloorIdxMap = useRef<
222
- MenuItemIdToFirstFloorIdxMapType
223
- >();
224
193
  const secoundFloorMenuList = useRef<SecoundFloorMenuList>([]);
225
194
  useEffect(() => {
226
- menuItemIdToFirstFloorIdxMap.current = getMenuItemIdToFirstFloorIdxMap(
227
- menuList,
228
- true
229
- );
230
195
  secoundFloorMenuList.current = getSecoundFloorMenuList(menuList);
231
196
  }, [menuList]);
232
197
 
@@ -295,9 +260,7 @@ const Sider: React.FC<SiderPropsType> = ({ menuList, style }) => {
295
260
  if (!targetId) return;
296
261
 
297
262
  const curSiderMenuList =
298
- secoundFloorMenuList.current[
299
- menuItemIdToFirstFloorIdxMap.current[targetId]
300
- ];
263
+ secoundFloorMenuList.current[menuItemIdToFirstFloorIdxMap[targetId]];
301
264
 
302
265
  if (curSiderMenuList) {
303
266
  setMenu(getMenuWithSecoundFloor(curSiderMenuList));
@@ -312,6 +275,11 @@ const Sider: React.FC<SiderPropsType> = ({ menuList, style }) => {
312
275
  setMenu(getMenuWithSecoundFloor(secoundFloorMenuList.current[0]));
313
276
  setSelectedKeys([]);
314
277
  }
278
+ setDocumentTitle("");
279
+ } else {
280
+ const documentTitle =
281
+ menuList[menuItemIdToFirstFloorIdxMap[sourceId]]?.label;
282
+ setDocumentTitle(translate("${" + documentTitle + "}"));
315
283
  }
316
284
  }, [menuList, sourceId, getLocale()]);
317
285
 
@@ -86,8 +86,8 @@ class Login extends React.PureComponent<LoginProps, LoginState> {
86
86
  await this.formRef.current
87
87
  .validateFields()
88
88
  .then(async (values) => {
89
- if (needKaptcha && !vertify)
90
- return this.setState({ showSlideVertify: true });
89
+ // if (needKaptcha && !vertify)
90
+ // return this.setState({ showSlideVertify: false });
91
91
 
92
92
  const { programCode } = this.props;
93
93
  let json = { username: values.username, password: values.password };
@@ -178,7 +178,7 @@ class Login extends React.PureComponent<LoginProps, LoginState> {
178
178
  prefix={<LockOutlined className="site-form-item-icon" />}
179
179
  />
180
180
  </Form.Item>
181
- {/* {needKaptcha ? (
181
+ {needKaptcha ? (
182
182
  <Row gutter={8}>
183
183
  <Col span={12}>
184
184
  <Form.Item
@@ -212,7 +212,7 @@ class Login extends React.PureComponent<LoginProps, LoginState> {
212
212
  </Row>
213
213
  ) : (
214
214
  ""
215
- )} */}
215
+ )}
216
216
  <Form.Item>
217
217
  <Button
218
218
  type="primary"
@@ -1,9 +1,10 @@
1
- import { Button, Form, Input } from "antd";
1
+ import {Button, Col, Form, Input, Row} from "antd";
2
2
  import React, { useEffect, useState } from "react";
3
3
  import HCserviceV3 from "../tmpl/hcservice-v3";
4
4
  import { useLocale } from "../locale/useLocale";
5
5
  import { useParams } from "react-router-dom";
6
6
  import Units from "../units";
7
+ import {SafetyCertificateOutlined} from "@ant-design/icons";
7
8
 
8
9
  type LoginPropType = {
9
10
  onFinish?: (token: string) => void;
@@ -15,6 +16,7 @@ type LoginPropType = {
15
16
  type FormType = {
16
17
  username: string;
17
18
  password: string;
19
+ kaptchaText:string;
18
20
  };
19
21
 
20
22
  const Login = (props: LoginPropType) => {
@@ -28,15 +30,18 @@ const Login = (props: LoginPropType) => {
28
30
  const { programCode: routeProgramCode } = useParams();
29
31
  useEffect(() => {
30
32
  if (routeProgramCode === undefined) return;
31
-
32
33
  Units.setProgramCode(routeProgramCode);
33
34
  }, [routeProgramCode]);
35
+ const [loading, setLoading] = useState<boolean>(false);
36
+ const [needKaptcha, setNeedKaptcha] = useState<boolean>(false);
37
+ const [kaptchaImg, setKaptchaImg] = useState<string>(null);
38
+ const [kaptchaToken, setKaptchaToken] = useState<string>(null);
34
39
 
35
- // form
40
+ // form
36
41
  const [form] = Form.useForm<FormType>();
37
42
  const submit = async () => {
38
43
  try {
39
- const { username, password } = await form.validateFields();
44
+ const { username, password,kaptchaText } = await form.validateFields();
40
45
 
41
46
  setLoading(true);
42
47
  const { programCode, onFinish } = props;
@@ -46,13 +51,16 @@ const Login = (props: LoginPropType) => {
46
51
  );
47
52
  const res = await HCserviceV3.login(
48
53
  { username, password },
49
- "",
50
- "",
54
+ kaptchaToken,
55
+ kaptchaText,
51
56
  pubkey,
52
57
  programCode ? programCode : routeProgramCode
53
58
  );
54
59
  if (res.status === "success") {
55
60
  onFinish(res.token);
61
+ }else if (res.status === "error") {
62
+ setNeedKaptcha(true);
63
+ await getKaptchaToken();
56
64
  }
57
65
  setLoading(false);
58
66
  } catch (err) {
@@ -60,9 +68,22 @@ const Login = (props: LoginPropType) => {
60
68
  }
61
69
  };
62
70
 
63
- // button
64
- const [loading, setLoading] = useState<boolean>(false);
71
+ const getKaptchaToken = async () => {
65
72
 
73
+ let res = await HCserviceV3.getKaptchaToken(routeProgramCode);
74
+ if (res) {
75
+ let kaptchaImg;
76
+ if (res.img && res.img.indexOf("data:") == 0) {
77
+ kaptchaImg = res.img;
78
+ } else {
79
+ kaptchaImg = `data:image/png;base64,${res.img}`;
80
+ }
81
+ setKaptchaImg(kaptchaImg);
82
+ setKaptchaToken(res.kaptchaToken);
83
+ }
84
+ };
85
+
86
+ // button
66
87
  return (
67
88
  <Form
68
89
  name="login"
@@ -102,6 +123,62 @@ const Login = (props: LoginPropType) => {
102
123
  }}
103
124
  />
104
125
  </Form.Item>
126
+ {needKaptcha ? (
127
+ <Row gutter={8}>
128
+ <Col span={16}>
129
+ <Form.Item
130
+ style={{
131
+ borderRadius: "50px",
132
+ background: "#EEF3FB",
133
+ height: "50px",
134
+ fontSize: "15px",
135
+ lineHeight: "15px",
136
+ }}
137
+ name="kaptchaText"
138
+ rules={[
139
+ {
140
+ required: true,
141
+ message: translate("${请输入}${验证码}!"),
142
+ },
143
+ ]}
144
+ >
145
+ <Input
146
+ style={{
147
+ borderRadius: "50px",
148
+ background: "#EEF3FB",
149
+ height: "50px",
150
+ fontSize: "15px",
151
+ lineHeight: "15px",
152
+ }}
153
+ prefix={
154
+ <SafetyCertificateOutlined className="site-form-item-icon" />
155
+ }
156
+ placeholder={translate("${验证码}")}
157
+ //onKeyDown={this.handleKeyDown}
158
+ />
159
+ </Form.Item>
160
+ </Col>
161
+ <Col span={8}>
162
+ <img
163
+ style={{
164
+ borderRadius: "30px",
165
+ background: "#EEF3FB",
166
+ height: "50px",
167
+ fontSize: "15px",
168
+ lineHeight: "15px",
169
+ cursor: "pointer"
170
+ }}
171
+ // height={50}
172
+ width={110}
173
+ title={translate("${点击刷新}")}
174
+ onClick={getKaptchaToken}
175
+ src={kaptchaImg}
176
+ ></img>
177
+ </Col>
178
+ </Row>
179
+ ) : (
180
+ ""
181
+ )}
105
182
 
106
183
  <Form.Item wrapperCol={{ span: 24 }}>
107
184
  <Button
@@ -116,7 +193,7 @@ const Login = (props: LoginPropType) => {
116
193
  lineHeight: "15px",
117
194
  }}
118
195
  >
119
- 登录
196
+ {translate("登录")}
120
197
  </Button>
121
198
  </Form.Item>
122
199
  </Form>
@@ -259,7 +259,7 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
259
259
  };
260
260
  const { queryKey } = this.props;
261
261
  await this.loadData(queryKey.key, pageInfo);
262
- // onChangePage(pageNo, pageSize);
262
+ onChangePage(pageNo, pageSize);
263
263
  };
264
264
 
265
265
  queryTotal = async () => {
@@ -1073,6 +1073,7 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
1073
1073
  tableProps,
1074
1074
  groupIColumns,
1075
1075
  } = this.props;
1076
+ debugger
1076
1077
  const { touchEnd, total, loading, virtualEndPageNo } = this.state;
1077
1078
  const { translate } = this.context;
1078
1079