aldehyde 0.2.305 → 0.2.309

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 (75) hide show
  1. package/lib/icon/aliIcon.d.ts +4 -0
  2. package/lib/icon/aliIcon.d.ts.map +1 -0
  3. package/lib/icon/aliIcon.js +6 -0
  4. package/lib/icon/aliIcon.js.map +1 -0
  5. package/lib/layout2/components/theme-button.d.ts +5 -0
  6. package/lib/layout2/components/theme-button.d.ts.map +1 -0
  7. package/lib/layout2/components/theme-button.js +32 -0
  8. package/lib/layout2/components/theme-button.js.map +1 -0
  9. package/lib/layout2/header.d.ts.map +1 -1
  10. package/lib/layout2/header.js +16 -0
  11. package/lib/layout2/header.js.map +1 -1
  12. package/lib/layout3/header.d.ts.map +1 -1
  13. package/lib/layout3/header.js +9 -0
  14. package/lib/layout3/header.js.map +1 -1
  15. package/lib/lowcode-components/base-button/index.d.ts +22 -0
  16. package/lib/lowcode-components/base-button/index.d.ts.map +1 -0
  17. package/lib/lowcode-components/base-button/index.js +78 -0
  18. package/lib/lowcode-components/base-button/index.js.map +1 -0
  19. package/lib/lowcode-components/base-button/index.less +8 -0
  20. package/lib/lowcode-components/base-map/index.d.ts +5 -0
  21. package/lib/lowcode-components/base-map/index.d.ts.map +1 -1
  22. package/lib/lowcode-components/base-map/index.js +32 -3
  23. package/lib/lowcode-components/base-map/index.js.map +1 -1
  24. package/lib/lowcode-components/base-tabs/index.d.ts +28 -0
  25. package/lib/lowcode-components/base-tabs/index.d.ts.map +1 -0
  26. package/lib/lowcode-components/base-tabs/index.js +78 -0
  27. package/lib/lowcode-components/base-tabs/index.js.map +1 -0
  28. package/lib/lowcode-components/base-tabs/index.less +15 -0
  29. package/lib/lowcode-components/effectScatter-map/index.d.ts +5 -0
  30. package/lib/lowcode-components/effectScatter-map/index.d.ts.map +1 -1
  31. package/lib/lowcode-components/effectScatter-map/index.js +34 -3
  32. package/lib/lowcode-components/effectScatter-map/index.js.map +1 -1
  33. package/lib/lowcode-components/effectScatter-map-3d/index.d.ts +7 -0
  34. package/lib/lowcode-components/effectScatter-map-3d/index.d.ts.map +1 -1
  35. package/lib/lowcode-components/effectScatter-map-3d/index.js +51 -7
  36. package/lib/lowcode-components/effectScatter-map-3d/index.js.map +1 -1
  37. package/lib/lowcode-components/index.d.ts +4 -0
  38. package/lib/lowcode-components/index.d.ts.map +1 -1
  39. package/lib/lowcode-components/index.js +3 -1
  40. package/lib/lowcode-components/index.js.map +1 -1
  41. package/lib/lowcode-components/lowcode-view/component/assets.d.ts.map +1 -1
  42. package/lib/lowcode-components/lowcode-view/component/assets.js +16 -0
  43. package/lib/lowcode-components/lowcode-view/component/assets.js.map +1 -1
  44. package/lib/lowcode-components/lowcode-view/component/util.d.ts +2 -0
  45. package/lib/lowcode-components/lowcode-view/component/util.d.ts.map +1 -0
  46. package/lib/lowcode-components/lowcode-view/component/util.js +30 -0
  47. package/lib/lowcode-components/lowcode-view/component/util.js.map +1 -0
  48. package/lib/lowcode-components/lowcode-view/index.d.ts.map +1 -1
  49. package/lib/lowcode-components/lowcode-view/index.js +27 -0
  50. package/lib/lowcode-components/lowcode-view/index.js.map +1 -1
  51. package/lib/module/dtmpl-edit-page.d.ts.map +1 -1
  52. package/lib/module/dtmpl-edit-page.js +4 -1
  53. package/lib/module/dtmpl-edit-page.js.map +1 -1
  54. package/package.json +1 -1
  55. package/src/aldehyde/icon/aliIcon.tsx +8 -0
  56. package/src/aldehyde/layout2/components/theme-button.tsx +47 -0
  57. package/src/aldehyde/layout2/header.tsx +32 -10
  58. package/src/aldehyde/layout3/header.tsx +14 -0
  59. package/src/aldehyde/lowcode-components/base-button/index.less +8 -0
  60. package/src/aldehyde/lowcode-components/base-button/index.tsx +123 -0
  61. package/src/aldehyde/lowcode-components/base-map/index.tsx +31 -3
  62. package/src/aldehyde/lowcode-components/base-tabs/index.less +15 -0
  63. package/src/aldehyde/lowcode-components/base-tabs/index.tsx +136 -0
  64. package/src/aldehyde/lowcode-components/effectScatter-map/index.tsx +32 -4
  65. package/src/aldehyde/lowcode-components/effectScatter-map-3d/index.tsx +51 -8
  66. package/src/aldehyde/lowcode-components/index.ts +6 -2
  67. package/src/aldehyde/lowcode-components/lowcode-view/component/assets.ts +16 -0
  68. package/src/aldehyde/lowcode-components/lowcode-view/component/util.ts +27 -0
  69. package/src/aldehyde/lowcode-components/lowcode-view/index.tsx +30 -1
  70. package/src/aldehyde/module/dtmpl-edit-page.tsx +5 -1
  71. package/lib/layout3/components/user-button.d.ts +0 -5
  72. package/lib/layout3/components/user-button.d.ts.map +0 -1
  73. package/lib/layout3/components/user-button.js +0 -146
  74. package/lib/layout3/components/user-button.js.map +0 -1
  75. package/src/aldehyde/layout3/components/user-button.tsx +0 -189
@@ -8,8 +8,10 @@ import { DataConfigProps } from "../data";
8
8
  const defData = [{ name: '北京', value: [116.41, 40.19, 100] }];
9
9
 
10
10
  const defOption = {
11
+ animationDurationUpdate: 0, // 重要:禁用动画更新,防止缩放卡顿和不同步
11
12
  tooltip: {
12
13
  trigger: 'item',
14
+ triggerOn: "mousemove",
13
15
  },
14
16
  geo: [
15
17
  { // 边框 map
@@ -154,7 +156,7 @@ const handleData = (data: { config: { [key: string]: string }, value: { [key: st
154
156
  name: config.v1,
155
157
  data: temVal.map(v => {
156
158
  const lonLat = v["v2"].split(",") || []; // 坐标经纬度;value:[经度,纬度,数值]
157
- return { name: v["d1"], value: [lonLat[0], lonLat[1], v["v1"]] };
159
+ return { name: v["d1"], value: [lonLat[0], lonLat[1], v["v1"]], itemData: { config, value: v } };
158
160
  })
159
161
  };
160
162
  });
@@ -162,7 +164,7 @@ const handleData = (data: { config: { [key: string]: string }, value: { [key: st
162
164
  };
163
165
 
164
166
  export interface ComponentStyle {
165
- tooltip?: { show: boolean };
167
+ tooltip?: { show: boolean, triggerOn: string, type: string, customize: { [key: string]: any } };
166
168
  effectScatter?: { [key: string]: any };
167
169
  areaColor?: string;
168
170
  backgroundColor?: string;
@@ -170,6 +172,8 @@ export interface ComponentStyle {
170
172
  borderWidth?: number;
171
173
  borderType?: string;
172
174
  label?: { [key: string]: any };
175
+ roam?: boolean;
176
+ zoom?: number;
173
177
  }
174
178
 
175
179
  export interface ComponentProps {
@@ -218,6 +222,20 @@ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>
218
222
  useEffect(() => {
219
223
  echarts.registerMap('china', chinaJson as any);
220
224
  chart.current = echarts.init(chartRef.current, null, { renderer: "svg" });
225
+ chart.current.on('georoam', () => { // 地图拖拽时,同步其他层级地图的缩放和中心点
226
+ const currentOption = chart.current.getOption();
227
+ // 获取主 geo (数组中的第一个) 当前的缩放和中心点
228
+ const masterZoom = currentOption.geo[0].zoom;
229
+ const masterCenter = currentOption.geo[0].center;
230
+ // 遍历并同步所有其他的 geo 组件(从第二个开始)
231
+ for (let i = 1; i < currentOption.geo.length; i++) {
232
+ currentOption.geo[i].zoom = masterZoom; // 同步缩放等级
233
+ currentOption.geo[i].center = masterCenter; // 同步中心位置
234
+ }
235
+ // 使用 setOption 更新所有从 geo 的配置
236
+ // 注意:这里只更新需要变化的 geo 数组,避免不必要的重绘
237
+ chart.current.setOption({ geo: currentOption.geo });
238
+ });
221
239
  window.addEventListener('resize', handleResize);
222
240
  return () => {
223
241
  handleDestroy();
@@ -260,24 +278,49 @@ const Index = forwardRef((props: ComponentProps, ref: ForwardedRef<ComponentRef>
260
278
  }
261
279
  }, [dataConfig?.sourceType, dataConfig?.sourceId]);
262
280
 
281
+ // 自定义弹窗渲染
282
+ const customizeTooltipConfig = (config) => {
283
+ const { title, width, height, padding, backgroundColor, backgroundImage, content } = config;
284
+ return {
285
+ padding: 0,
286
+ borderWidth: 0,
287
+ enterable: true,
288
+ backgroundColor: "rgba(0,0,0,0)",
289
+ formatter: (params) => {
290
+ const itemData = params.data.itemData;
291
+ const dom = document.createElement("div");
292
+ const bgImg = `background-image: url(${backgroundImage});background-size: 100% 100%;background-repeat: no-repeat;background-position: center;`;
293
+ dom.style = `width:${width}px;height:${height}px;${backgroundImage ? bgImg : `background:${backgroundColor}`}`;
294
+ dom.innerHTML = `<div style="padding:${padding}px;width:100%;height:100%">
295
+ ${title?.text ? `<div style="width:100%;margin-bottom:4px; font-size: ${title.fontSize}px; color: ${title.color}; text-align: ${title.position}">${title?.text}</div>` : ""}
296
+ ${content?.value?.map(r => itemData?.config?.[r] && `<div style="width:100%;display:flex;justify-content:space-between;align-items:center; font-size: ${content.fontSize}px; color: ${content.color};">
297
+ <div style="width:60%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${itemData?.config?.[r] || ""}</div>
298
+ <div style="width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:right">${itemData?.value?.[r] || ""}</div>
299
+ </div>`)?.filter(Boolean)?.join("")}
300
+ </div>`;
301
+ return dom;
302
+ }
303
+ }
304
+ };
305
+
263
306
  const renderChart = () => {
264
- const { tooltip, areaColor, backgroundColor, borderColor, borderWidth, borderType, label, effectScatter } = config
307
+ const { roam, zoom, tooltip, areaColor, backgroundColor, borderColor, borderWidth, borderType, label, effectScatter } = config;
265
308
  const option = _.cloneDeep(defOption);
266
309
  // 编辑态无数据显示默认数据
267
310
  const temData = isDesignMode && !data?.length ? defData : data;
268
- option.tooltip = { trigger: "item", ...tooltip };
311
+ option.tooltip = { trigger: "item", ...tooltip, ...(tooltip.type === "customize" ? customizeTooltipConfig(tooltip.customize || {}) : {}) };
269
312
  option.geo = option.geo.map((r, index) => {
270
313
  switch (index) {
271
314
  case 0:
272
- return { ...r, label, itemStyle: { ...r.itemStyle, borderWidth, borderColor, shadowColor: borderColor, borderType } };
315
+ return { ...r, roam, zoom, label, itemStyle: { ...r.itemStyle, borderWidth, borderColor, shadowColor: borderColor, borderType } };
273
316
  case 1:
274
- return { ...r, itemStyle: { areaColor } };
317
+ return { ...r, roam: false, zoom, itemStyle: { areaColor } };
275
318
  case 2:
276
319
  case 3:
277
320
  case 4:
278
- return { ...r, itemStyle: { ...r.itemStyle, areaColor: backgroundColor } };
321
+ return { ...r, roam: false, zoom, itemStyle: { ...r.itemStyle, areaColor: backgroundColor } };
279
322
  default:
280
- return r;
323
+ return { ...r, roam: false, zoom };
281
324
  }
282
325
  }) as any;
283
326
  option.series = option.series.map((item: any) => ({ ...item, ...effectScatter, data: temData }));
@@ -47,6 +47,8 @@ import LineBarChart from "./line-bar-chart";
47
47
  import Column3dChart from "./column-3d-chart";
48
48
  import StrokeAnimation from "./stroke-animation";
49
49
  import EffectScatterMap3D from "./effectScatter-map-3d";
50
+ import BaseButton from "./base-button";
51
+ import BaseTabs from "./base-tabs";
50
52
 
51
53
 
52
54
  type CompoundedComponent = {
@@ -98,7 +100,9 @@ type CompoundedComponent = {
98
100
  LineBarChart?: typeof LineBarChart,
99
101
  Column3dChart?: typeof Column3dChart,
100
102
  StrokeAnimation?: typeof StrokeAnimation,
101
- EffectScatterMap3D?: typeof EffectScatterMap3D
103
+ EffectScatterMap3D?: typeof EffectScatterMap3D,
104
+ BaseButton?: typeof BaseButton,
105
+ BaseTabs?: typeof BaseTabs
102
106
  };
103
107
 
104
108
  const LowcodeComponents: CompoundedComponent = {
@@ -110,7 +114,7 @@ const LowcodeComponents: CompoundedComponent = {
110
114
  Decoration1, Decoration2, Decoration3, Decoration4, Decoration5,
111
115
  Decoration6, Decoration7, Decoration8, Decoration9, Decoration10, Decoration11,
112
116
  BaseTable, TextScroller, CapsuleBarChart, CircularProgressChart, ActTable, ProgressChart,
113
- LineBarChart, Column3dChart, StrokeAnimation, EffectScatterMap3D
117
+ LineBarChart, Column3dChart, StrokeAnimation, EffectScatterMap3D, BaseButton, BaseTabs
114
118
  };
115
119
 
116
120
  export default LowcodeComponents;
@@ -48,6 +48,8 @@ import LineBarChart from "../../line-bar-chart";
48
48
  import Column3dChart from "../../column-3d-chart";
49
49
  import StrokeAnimation from "../../stroke-animation";
50
50
  import EffectScatterMap3D from "../../effectScatter-map-3d";
51
+ import BaseButton from "../../base-button";
52
+ import BaseTabs from "../../base-tabs";
51
53
 
52
54
  interface ComponentItemConfig {
53
55
  baseInfo: BaseInfoType, // 基础信息
@@ -419,5 +421,19 @@ export const compsConfig: { [key: string]: ComponentItemConfig } = {
419
421
  compName: "立体散点地图",
420
422
  compKey: "EffectScatterMap3D"
421
423
  }
424
+ },
425
+ BaseButton: {
426
+ componentNode: BaseButton,
427
+ baseInfo: {
428
+ compName: "基础按钮",
429
+ compKey: "BaseButton"
430
+ }
431
+ },
432
+ BaseTabs: {
433
+ componentNode: BaseTabs,
434
+ baseInfo: {
435
+ compName: "选项卡",
436
+ compKey: "BaseTabs"
437
+ }
422
438
  }
423
439
  };
@@ -0,0 +1,27 @@
1
+
2
+ export const merge = (originalData: any, newData: any): any => {
3
+ if (!originalData && newData)
4
+ return newData;
5
+ if (originalData && !newData)
6
+ return originalData;
7
+ Object.keys(newData).forEach(key => {
8
+ const newValue = newData[key];
9
+ if (originalData.hasOwnProperty(key)) {
10
+ if (Array.isArray(newValue)) {
11
+ originalData[key] = newValue;
12
+ } else if (newValue
13
+ && typeof newValue === "object"
14
+ && Object.keys(newValue).length > 0
15
+ && originalData[key]
16
+ && typeof originalData[key] === "object"
17
+ && !!originalData[key]) {
18
+ merge(originalData[key], newValue);
19
+ } else {
20
+ originalData[key] = newValue;
21
+ }
22
+ } else {
23
+ originalData[key] = newValue;
24
+ }
25
+ });
26
+ return originalData;
27
+ }
@@ -1,12 +1,14 @@
1
1
  import React, { CSSProperties, useEffect, useState, useRef } from 'react'
2
2
  import { useParams } from 'react-router-dom';
3
+ import isEqual from "lodash/isEqual";
3
4
  import Loading from "./component/loading";
4
5
  import layerBuilder from "./component/layer-builder";
5
6
  import './component/font/FontGlobal.css';
6
7
  import ScreenFit from "./component/screen-fit";
7
- import { LayerManagerDataType, CanvasConfig } from "./interface";
8
+ import { LayerManagerDataType, CanvasConfig, ILayerItem } from "./interface";
8
9
  import HcserviceV3 from "../../tmpl/hcservice-v3";
9
10
  import abstractDesignerLoader from "./component/abstract-designer-loader";
11
+ import { merge } from "./component/util";
10
12
  import "./index.less";
11
13
 
12
14
  const fromBase64 = (base64: string) => {
@@ -56,6 +58,33 @@ const LowcodeView = (props: Props) => {
56
58
  setLoading(false);
57
59
  }
58
60
 
61
+ // 更新画面,显隐
62
+ const updateLayer = (items: ILayerItem[]) => {
63
+ const { layerConfigs } = layerManager;
64
+ const temObj = {}
65
+ for (const item of items) {
66
+ const oldItem = layerConfigs[item.id + ""];
67
+ if (!isEqual(oldItem, item)) {
68
+ const temData = { ...merge(oldItem, item) };
69
+ temObj[item.id + ""] = temData;
70
+ }
71
+ }
72
+ setLayerManager({ ...layerManager, layerConfigs: { ...layerConfigs, ...temObj } });
73
+ }
74
+
75
+ useEffect(() => {
76
+ if (layerManager?.layerConfigs) {
77
+ // @ts-ignore
78
+ window.LC_VIEW = {
79
+ layerManager: { ...layerManager, updateLayer }
80
+ }
81
+ }
82
+ return () => {
83
+ // @ts-ignore
84
+ window.LC_VIEW = undefined;
85
+ }
86
+ }, [layerManager]);
87
+
59
88
  useEffect(() => {
60
89
  if (ddpageId) {
61
90
  getViewData();
@@ -325,7 +325,11 @@ export default class DtmplEditPage extends React.PureComponent<
325
325
 
326
326
  let title1 = title ? title : dtmplConfig ? dtmplConfig.title : "";
327
327
  const { translate } = this.context;
328
- title1=translate("${" + title1 + "}");
328
+ //判断是不是 字符串
329
+ if (typeof title1 === "string"){
330
+ title1=translate("${" + title1 + "}");
331
+ }
332
+
329
333
 
330
334
  //根据 parentFormInstance 完善 dtmplConfig
331
335
  if(parentFormInstance && dtmplConfig){//
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- import { ButtonProps } from "antd";
3
- declare const UserButton: React.FC<ButtonProps>;
4
- export default UserButton;
5
- //# sourceMappingURL=user-button.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-button.d.ts","sourceRoot":"","sources":["../../../../../src/aldehyde/layout3/components/user-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAU9D,OAAO,EAAU,WAAW,EAAgC,MAAM,MAAM,CAAC;AAmBzE,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA6JrC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,146 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import React, { useEffect, useState } from "react";
11
- import { CaretDownOutlined, ClearOutlined, LoginOutlined, LogoutOutlined, MenuFoldOutlined, MenuUnfoldOutlined, SettingOutlined, UnlockOutlined, UserOutlined, } from "@ant-design/icons";
12
- import { Button, Dropdown } from "antd";
13
- import HcserviceV3 from "../../tmpl/hcservice-v3";
14
- import UserInfoBar from "../../layout/menu/userinfo-bar";
15
- import { useLocale } from "../../locale/useLocale";
16
- import { NavLink, useNavigate } from "react-router-dom";
17
- import ResetPassword from "../../layout/menu/reset-password";
18
- import HCDataSource from "../../tmpl/hc-data-source";
19
- import { useSessionStorageState } from 'ahooks';
20
- import Units from "../../units";
21
- const UserButton = (props) => {
22
- // translate
23
- const { translate, changeSiderCollapsed, getSiderCollapsed } = useLocale();
24
- const [keepAliveTabs, setKeepAliveTabs] = useSessionStorageState('keepAliveTabs', {
25
- defaultValue: [],
26
- });
27
- // navigation
28
- const navigate = useNavigate();
29
- // 用户配置信息
30
- const [userConfig, setUserConfig] = useState({
31
- id: undefined,
32
- name: undefined,
33
- });
34
- const initUserConfig = () => __awaiter(void 0, void 0, void 0, function* () {
35
- const userInfo = yield Units.getUserInfo();
36
- setUserConfig(userInfo);
37
- });
38
- useEffect(() => { }, [userConfig]);
39
- // 上下文配置信息
40
- const [globalContext, setGlobalContext] = useState();
41
- const initContext = () => __awaiter(void 0, void 0, void 0, function* () {
42
- let context = yield HcserviceV3.getContextSourceValue();
43
- setGlobalContext(context);
44
- });
45
- useEffect(() => {
46
- initContext();
47
- }, []);
48
- // 用户是否登录
49
- const [isLogin, setIsLogin] = useState(false);
50
- useEffect(() => {
51
- if ((userConfig === null || userConfig === void 0 ? void 0 : userConfig.name) !== undefined && (userConfig === null || userConfig === void 0 ? void 0 : userConfig.name) !== null)
52
- setIsLogin(true);
53
- else
54
- setIsLogin(false);
55
- }, [userConfig]);
56
- useEffect(() => {
57
- initUserConfig();
58
- }, []);
59
- // logout
60
- const logout = () => __awaiter(void 0, void 0, void 0, function* () {
61
- setKeepAliveTabs([]);
62
- yield HcserviceV3.logout2();
63
- navigate("/login2");
64
- });
65
- // dropdown menu
66
- const onClick = ({ key }) => { };
67
- const dropdownMenuList = [
68
- {
69
- label: React.createElement(NavLink, { to: "/login2" }, translate("${登录}")),
70
- key: "login",
71
- icon: React.createElement(LoginOutlined, null),
72
- show: () => {
73
- return !isLogin;
74
- },
75
- },
76
- {
77
- label: (React.createElement(UserInfoBar, { gtmplSourceId: userConfig === null || userConfig === void 0 ? void 0 : userConfig.gtmplSourceId, editable: userConfig === null || userConfig === void 0 ? void 0 : userConfig.changePersonalInfoable, userCode: userConfig === null || userConfig === void 0 ? void 0 : userConfig.id })),
78
- key: "userInfo",
79
- icon: React.createElement(UserOutlined, null),
80
- show: () => {
81
- return isLogin && (userConfig === null || userConfig === void 0 ? void 0 : userConfig.viewPersonalInfoable);
82
- },
83
- },
84
- {
85
- label: React.createElement(NavLink, { to: "/context-setter" }, translate("${全局配置}")),
86
- key: "globalContext",
87
- icon: React.createElement(SettingOutlined, null),
88
- show: () => {
89
- return (isLogin && Array.isArray(globalContext) && globalContext.length > 0);
90
- },
91
- },
92
- {
93
- label: React.createElement(ResetPassword, null),
94
- key: "resetPwd",
95
- icon: React.createElement(UnlockOutlined, null),
96
- show: () => {
97
- return isLogin && userConfig.changePasswordable;
98
- },
99
- },
100
- {
101
- label: (React.createElement("span", { onClick: () => HCDataSource.reload([]) }, translate("${清空缓存}"))),
102
- key: "cleanCache",
103
- icon: React.createElement(ClearOutlined, null),
104
- show: () => {
105
- return isLogin && userConfig.cleanCachable;
106
- },
107
- }, {
108
- label: (React.createElement("span", { onClick: () => changeSiderCollapsed() }, getSiderCollapsed() ? translate("${显示侧边栏}") : translate("${隐藏侧边栏}"))),
109
- key: "collapseSider",
110
- icon: React.createElement("span", null, getSiderCollapsed() ? React.createElement(MenuUnfoldOutlined, null) : React.createElement(MenuFoldOutlined, null)),
111
- show: () => {
112
- return isLogin;
113
- },
114
- },
115
- {
116
- label: React.createElement("span", { onClick: logout }, translate("${退出}")),
117
- key: "logout",
118
- icon: React.createElement(LogoutOutlined, null),
119
- show: () => {
120
- return isLogin;
121
- },
122
- },
123
- ];
124
- const cleanDropdownMenuList = dropdownMenuList
125
- .filter((item) => {
126
- if (!item.show)
127
- return true;
128
- return item.show();
129
- })
130
- .map(({ label, key, icon }) => {
131
- return {
132
- label,
133
- key,
134
- icon,
135
- };
136
- });
137
- return (React.createElement(Dropdown, { overlayClassName: "localeButton", menu: { items: cleanDropdownMenuList, onClick } },
138
- React.createElement(Button, Object.assign({ type: "text", icon: React.createElement(CaretDownOutlined, null), style: {
139
- width: "100%",
140
- height: "100%",
141
- borderRadius: 0,
142
- color: "#fff",
143
- } }, props), isLogin ? userConfig === null || userConfig === void 0 ? void 0 : userConfig.name : translate("${请登录}"))));
144
- };
145
- export default UserButton;
146
- //# sourceMappingURL=user-button.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-button.js","sourceRoot":"","sources":["../../../../../src/aldehyde/layout3/components/user-button.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAa,SAAS,EAAE,QAAQ,EAAE,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c,EAC/B,IAAI,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,OAAO,EAAE;QAE/C,oBAAC,MAAM,kBACL,IAAI,EAAC,MAAM,EACX,IAAI,EAAE,oBAAC,iBAAiB,OAAG,EAC3B,KAAK,EAAE;gBACL,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;gBACd,YAAY,EAAE,CAAC;gBACf,KAAK,EAAE,MAAM;aACd,IACG,KAAK,GAER,OAAO,CAAC,CAAC,CAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAC1C,CACA,CACZ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,189 +0,0 @@
1
- import React, { ReactNode, useEffect, useState } from "react";
2
- import {
3
- CaretDownOutlined,
4
- ClearOutlined,
5
- LoginOutlined,
6
- LogoutOutlined, MenuFoldOutlined, MenuUnfoldOutlined,
7
- SettingOutlined,
8
- UnlockOutlined,
9
- UserOutlined,
10
- } from "@ant-design/icons";
11
- import { Button, ButtonProps, Dropdown, GetProp, MenuProps } from "antd";
12
- import HcserviceV3 from "../../tmpl/hcservice-v3";
13
- import { UserInfo } from "../../tmpl/interface";
14
- import UserInfoBar from "../../layout/menu/userinfo-bar";
15
- import { useLocale } from "../../locale/useLocale";
16
- import { NavLink, useNavigate } from "react-router-dom";
17
- import ResetPassword from "../../layout/menu/reset-password";
18
- import HCDataSource from "../../tmpl/hc-data-source";
19
- import { useSessionStorageState } from 'ahooks';
20
- import {KeepAliveTab} from "../../hooks/use-tabs";
21
- import Units from "../../units";
22
-
23
- type DropDownMenuType = {
24
- label: string | number | ReactNode;
25
- key: string;
26
- icon?: ReactNode;
27
- show?: () => boolean;
28
- };
29
-
30
- const UserButton: React.FC<ButtonProps> = (props) => {
31
- // translate
32
- const { translate,changeSiderCollapsed,getSiderCollapsed } = useLocale();
33
- const [keepAliveTabs, setKeepAliveTabs] = useSessionStorageState<KeepAliveTab[]>('keepAliveTabs', {
34
- defaultValue: [],
35
- });
36
- // navigation
37
- const navigate = useNavigate();
38
-
39
- // 用户配置信息
40
- const [userConfig, setUserConfig] = useState<UserInfo>({
41
- id: undefined,
42
- name: undefined,
43
- });
44
- const initUserConfig = async () => {
45
- const userInfo: UserInfo = await Units.getUserInfo();
46
- setUserConfig(userInfo);
47
- };
48
- useEffect(() => {}, [userConfig]);
49
-
50
- // 上下文配置信息
51
- const [globalContext, setGlobalContext] = useState<any[]>();
52
- const initContext = async () => {
53
- let context = await HcserviceV3.getContextSourceValue();
54
- setGlobalContext(context);
55
- };
56
- useEffect(() => {
57
- initContext();
58
- }, []);
59
-
60
- // 用户是否登录
61
- const [isLogin, setIsLogin] = useState<boolean>(false);
62
- useEffect(() => {
63
- if (userConfig?.name !== undefined && userConfig?.name !== null)
64
- setIsLogin(true);
65
- else setIsLogin(false);
66
- }, [userConfig]);
67
- useEffect(() => {
68
- initUserConfig();
69
- }, []);
70
-
71
- // logout
72
- const logout = async () => {
73
- setKeepAliveTabs([]);
74
- await HcserviceV3.logout2();
75
- navigate("/login2");
76
- };
77
-
78
- // dropdown menu
79
- const onClick: MenuProps["onClick"] = ({ key }) => {};
80
- const dropdownMenuList: DropDownMenuType[] = [
81
- {
82
- label: <NavLink to="/login2">{translate("${登录}")}</NavLink>,
83
- key: "login",
84
- icon: <LoginOutlined />,
85
- show: () => {
86
- return !isLogin;
87
- },
88
- },
89
- {
90
- label: (
91
- <UserInfoBar
92
- gtmplSourceId={userConfig?.gtmplSourceId}
93
- editable={userConfig?.changePersonalInfoable}
94
- userCode={userConfig?.id}
95
- />
96
- ),
97
- key: "userInfo",
98
- icon: <UserOutlined />,
99
- show: () => {
100
- return isLogin && userConfig?.viewPersonalInfoable;
101
- },
102
- },
103
- {
104
- label: <NavLink to="/context-setter">{translate("${全局配置}")}</NavLink>,
105
- key: "globalContext",
106
- icon: <SettingOutlined />,
107
- show: () => {
108
- return (
109
- isLogin && Array.isArray(globalContext) && globalContext.length > 0
110
- );
111
- },
112
- },
113
- {
114
- label: <ResetPassword></ResetPassword>,
115
- key: "resetPwd",
116
- icon: <UnlockOutlined />,
117
- show: () => {
118
- return isLogin && userConfig.changePasswordable;
119
- },
120
- },
121
- {
122
- label: (
123
- <span onClick={() => HCDataSource.reload([])}>
124
- {translate("${清空缓存}")}
125
- </span>
126
- ),
127
- key: "cleanCache",
128
- icon: <ClearOutlined />,
129
- show: () => {
130
- return isLogin && userConfig.cleanCachable;
131
- },
132
- },{
133
- label: (
134
- <span onClick={() => changeSiderCollapsed()}>
135
- {getSiderCollapsed()?translate("${显示侧边栏}"):translate("${隐藏侧边栏}")}
136
- </span>
137
- ),
138
- key: "collapseSider",
139
- icon: <span>{getSiderCollapsed()? <MenuUnfoldOutlined /> :<MenuFoldOutlined /> }</span>,
140
- show: () => {
141
- return isLogin ;
142
- },
143
- },
144
- {
145
- label: <span onClick={logout}>{translate("${退出}")}</span>,
146
- key: "logout",
147
- icon: <LogoutOutlined />,
148
- show: () => {
149
- return isLogin;
150
- },
151
- },
152
-
153
- ];
154
- const cleanDropdownMenuList: GetProp<MenuProps, "items"> = dropdownMenuList
155
- .filter((item) => {
156
- if (!item.show) return true;
157
- return item.show();
158
- })
159
- .map(({ label, key, icon }) => {
160
- return {
161
- label,
162
- key,
163
- icon,
164
- };
165
- });
166
-
167
- return (
168
- <Dropdown
169
- overlayClassName="localeButton"
170
- menu={{ items: cleanDropdownMenuList, onClick }}
171
- >
172
- <Button
173
- type="text"
174
- icon={<CaretDownOutlined />}
175
- style={{
176
- width: "100%",
177
- height: "100%",
178
- borderRadius: 0,
179
- color: "#fff",
180
- }}
181
- {...props}
182
- >
183
- {isLogin ? userConfig?.name : translate("${请登录}")}
184
- </Button>
185
- </Dropdown>
186
- );
187
- };
188
-
189
- export default UserButton;