aldehyde 0.2.494 → 0.2.495
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.
- package/lib/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +63 -63
- package/lib/draw-canvas-edit/components/asset-bar/index.less +35 -35
- package/lib/draw-canvas-edit/components/main-header/index.less +23 -23
- package/lib/layout2/page.d.ts +2 -1
- package/lib/layout2/page.d.ts.map +1 -1
- package/lib/layout2/page.js +19 -8
- package/lib/layout2/page.js.map +1 -1
- package/lib/layout2/type/layout-type.d.ts +1 -0
- package/lib/layout2/type/layout-type.d.ts.map +1 -1
- package/lib/lowcode-components/base-table/index.less +61 -61
- package/lib/lowcode-components/base-text/index.less +19 -19
- package/lib/lowcode-components/data-number/index.less +10 -10
- package/lib/lowcode-components/date-time/index.less +4 -4
- package/lib/lowcode-components/four-angle-glow-border/index.less +49 -49
- package/lib/lowcode-components/lowcode-view/component/font/FontGlobal.css +26 -26
- package/lib/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -13
- package/lib/lowcode-components/text-scroller/index.less +28 -28
- package/lib/module/ltmpl-table.d.ts +7 -0
- package/lib/module/ltmpl-table.d.ts.map +1 -1
- package/lib/module/ltmpl-table.js +12 -16
- package/lib/module/ltmpl-table.js.map +1 -1
- package/lib/routable/dtmpl-route.d.ts.map +1 -1
- package/lib/routable/dtmpl-route.js +8 -2
- package/lib/routable/dtmpl-route.js.map +1 -1
- package/lib/routable/import-route.d.ts.map +1 -1
- package/lib/routable/import-route.js +9 -1
- package/lib/routable/import-route.js.map +1 -1
- package/lib/routable/ltmpl-route.d.ts.map +1 -1
- package/lib/routable/ltmpl-route.js +13 -6
- package/lib/routable/ltmpl-route.js.map +1 -1
- package/lib/routable/splitview-ltmpl-route.d.ts.map +1 -1
- package/lib/routable/splitview-ltmpl-route.js +11 -10
- package/lib/routable/splitview-ltmpl-route.js.map +1 -1
- package/lib/routable/ttmpl-route.d.ts.map +1 -1
- package/lib/routable/ttmpl-route.js +9 -2
- package/lib/routable/ttmpl-route.js.map +1 -1
- package/lib/table/act-table.d.ts +1 -0
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js +31 -9
- package/lib/table/act-table.js.map +1 -1
- package/lib/table/page-chart.js +1 -1
- package/lib/table/page-chart.js.map +1 -1
- package/lib/table/row-table.d.ts +6 -0
- package/lib/table/row-table.d.ts.map +1 -1
- package/lib/table/row-table.js +21 -6
- package/lib/table/row-table.js.map +1 -1
- package/lib/tmpl/interface.d.ts +1 -0
- package/lib/tmpl/interface.d.ts.map +1 -1
- package/lib/tree/act-tree.d.ts +1 -0
- package/lib/tree/act-tree.d.ts.map +1 -1
- package/lib/tree/act-tree.js +6 -7
- package/lib/tree/act-tree.js.map +1 -1
- package/lib/tree/tree-utils.d.ts +1 -1
- package/lib/tree/tree-utils.d.ts.map +1 -1
- package/lib/tree/tree-utils.js +4 -4
- package/lib/tree/tree-utils.js.map +1 -1
- package/lib/units/index.d.ts +4 -0
- package/lib/units/index.d.ts.map +1 -1
- package/lib/units/index.js +10 -3
- package/lib/units/index.js.map +1 -1
- package/package.json +1 -1
- package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.css +63 -63
- package/src/aldehyde/controls/icon-selector/icon/phonenode-menu-icon/iconfont.json +93 -93
- package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.less +35 -35
- package/src/aldehyde/draw-canvas-edit/components/asset-bar/index.tsx +110 -110
- package/src/aldehyde/draw-canvas-edit/components/main-header/index.less +23 -23
- package/src/aldehyde/draw-canvas-edit/components/main-header/index.tsx +263 -263
- package/src/aldehyde/draw-canvas-edit/components/render/draws/index.ts +7 -7
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/base-graph.ts +241 -241
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/circle.ts +699 -699
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/curve.ts +500 -500
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/index.ts +5 -5
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/line.ts +493 -493
- package/src/aldehyde/draw-canvas-edit/components/render/graphs/rect.ts +680 -680
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/drag-handlers.ts +68 -68
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/graph-handlers.ts +113 -113
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/index.ts +9 -9
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/key-move-handlers.ts +49 -49
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/link-handlers.ts +45 -45
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/shutcut-handlers.ts +45 -45
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/text-handlers.ts +81 -81
- package/src/aldehyde/draw-canvas-edit/components/render/handlers/zoom-handlers.ts +59 -59
- package/src/aldehyde/draw-canvas-edit/components/render/tools/align-tool.ts +89 -89
- package/src/aldehyde/draw-canvas-edit/components/render/tools/asset-tool.ts +154 -154
- package/src/aldehyde/draw-canvas-edit/components/render/tools/link-tool.ts +222 -222
- package/src/aldehyde/draw-canvas-edit/components/render/tools/z-index-tool.ts +224 -224
- package/src/aldehyde/draw-canvas-edit/components/render/utils/a-star.ts +116 -116
- package/src/aldehyde/draw-canvas-edit/components/render/utils/bezier-scene-func.ts +72 -72
- package/src/aldehyde/draw-canvas-edit/components/setting-form/imag-upload.tsx +119 -119
- package/src/aldehyde/layout2/page.tsx +17 -9
- package/src/aldehyde/layout2/type/layout-type.ts +1 -0
- package/src/aldehyde/layout4/imgs/user.svg +26 -26
- package/src/aldehyde/lowcode-components/base-color-block/index.tsx +31 -31
- package/src/aldehyde/lowcode-components/base-table/index.less +61 -61
- package/src/aldehyde/lowcode-components/base-text/index.less +19 -19
- package/src/aldehyde/lowcode-components/data-number/index.less +10 -10
- package/src/aldehyde/lowcode-components/date-time/index.less +4 -4
- package/src/aldehyde/lowcode-components/date-time/index.tsx +64 -64
- package/src/aldehyde/lowcode-components/four-angle-glow-border/index.less +49 -49
- package/src/aldehyde/lowcode-components/four-angle-glow-border/index.tsx +53 -53
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-controller.ts +64 -64
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-definition.ts +77 -77
- package/src/aldehyde/lowcode-components/lowcode-view/component/abstract-designer-loader.ts +36 -36
- package/src/aldehyde/lowcode-components/lowcode-view/component/component-container.tsx +91 -91
- package/src/aldehyde/lowcode-components/lowcode-view/component/font/FontGlobal.css +26 -26
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/controller.ts +36 -36
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/definition.ts +53 -53
- package/src/aldehyde/lowcode-components/lowcode-view/component/group-layer/index.tsx +15 -15
- package/src/aldehyde/lowcode-components/lowcode-view/component/layer-builder.tsx +98 -98
- package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.less +13 -13
- package/src/aldehyde/lowcode-components/lowcode-view/component/screen-fit/index.tsx +121 -121
- package/src/aldehyde/lowcode-components/placeholder-component/index.tsx +81 -81
- package/src/aldehyde/lowcode-components/text-scroller/index.less +28 -28
- package/src/aldehyde/lowcode-components/text-scroller/index.tsx +173 -173
- package/src/aldehyde/module/ltmpl-table.tsx +14 -15
- package/src/aldehyde/routable/dtmpl-route.tsx +14 -8
- package/src/aldehyde/routable/import-route.tsx +12 -5
- package/src/aldehyde/routable/ltmpl-route.tsx +14 -9
- package/src/aldehyde/routable/splitview-ltmpl-route.tsx +11 -8
- package/src/aldehyde/routable/ttmpl-route.tsx +13 -8
- package/src/aldehyde/table/act-table.tsx +28 -9
- package/src/aldehyde/table/page-chart.tsx +1 -1
- package/src/aldehyde/table/row-table.tsx +29 -6
- package/src/aldehyde/tmpl/interface.tsx +1 -0
- package/src/aldehyde/tree/act-tree.tsx +8 -6
- package/src/aldehyde/tree/tree-utils.tsx +4 -4
- package/src/aldehyde/units/index.tsx +11 -3
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
export interface GroupLayerStyleProps {
|
|
4
|
-
children?: React.ReactNode;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default class GroupLayer extends React.PureComponent<GroupLayerStyleProps> {
|
|
8
|
-
state = {
|
|
9
|
-
load: true
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
render() {
|
|
13
|
-
const { load } = this.state;
|
|
14
|
-
return load ? <div style={{ position: 'absolute' }}>{this.props.children}</div> : "";
|
|
15
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface GroupLayerStyleProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default class GroupLayer extends React.PureComponent<GroupLayerStyleProps> {
|
|
8
|
+
state = {
|
|
9
|
+
load: true
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
render() {
|
|
13
|
+
const { load } = this.state;
|
|
14
|
+
return load ? <div style={{ position: 'absolute' }}>{this.props.children}</div> : "";
|
|
15
|
+
}
|
|
16
16
|
}
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import { createElement, ReactElement } from "react";
|
|
2
|
-
import cloneDeep from "lodash/cloneDeep";
|
|
3
|
-
import ComponentContainer from "./component-container";
|
|
4
|
-
import { ILayerItem, LayerManagerDataType, } from "../interface";
|
|
5
|
-
import GroupLayer from "./group-layer";
|
|
6
|
-
|
|
7
|
-
export enum LayerOrder {
|
|
8
|
-
ASC,
|
|
9
|
-
DESC,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
class LayerBuilder {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 解析函数
|
|
16
|
-
*/
|
|
17
|
-
public parser = (layerManager: LayerManagerDataType, order: LayerOrder = LayerOrder.DESC): ILayerItem[] => {
|
|
18
|
-
const { layerHeader, layerConfigs } = layerManager;
|
|
19
|
-
const layerMap = cloneDeep(layerConfigs);
|
|
20
|
-
let sourceLayerArr: ILayerItem[] = [];
|
|
21
|
-
|
|
22
|
-
const iterateLayers = (currentLayer: ILayerItem, res: ILayerItem[]): void => {
|
|
23
|
-
if (currentLayer) {
|
|
24
|
-
res.push(currentLayer);
|
|
25
|
-
if (currentLayer.childHeader) {
|
|
26
|
-
let childLayer = layerMap[currentLayer.childHeader];
|
|
27
|
-
iterateLayers(childLayer, res);
|
|
28
|
-
}
|
|
29
|
-
let next = currentLayer.next;
|
|
30
|
-
while (next) {
|
|
31
|
-
const nextLayer = layerMap[next!];
|
|
32
|
-
if (nextLayer?.childHeader)
|
|
33
|
-
iterateLayers(layerMap[nextLayer.childHeader], res);
|
|
34
|
-
nextLayer && res.push(nextLayer);
|
|
35
|
-
next = nextLayer?.next;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
iterateLayers(layerMap[layerHeader!], sourceLayerArr);
|
|
41
|
-
|
|
42
|
-
if (order === LayerOrder.ASC)
|
|
43
|
-
sourceLayerArr = sourceLayerArr.reverse();
|
|
44
|
-
|
|
45
|
-
// 构建树结构
|
|
46
|
-
const resData: ILayerItem[] = [];
|
|
47
|
-
for (const layerItem of sourceLayerArr) {
|
|
48
|
-
if (!layerItem?.pid) {
|
|
49
|
-
// 根节点
|
|
50
|
-
resData.push(layerItem);
|
|
51
|
-
} else {
|
|
52
|
-
// 非根节点,将其加入父节点的 children 中
|
|
53
|
-
const parent = layerMap[layerItem.pid];
|
|
54
|
-
if (parent) {
|
|
55
|
-
parent.children = parent.children || [];
|
|
56
|
-
parent.children.push(layerItem);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return resData;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
private order: number = 1;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 构建设计器主画布组件
|
|
67
|
-
* @param layerMap
|
|
68
|
-
*/
|
|
69
|
-
public buildCanvasComponents = (layerManager: LayerManagerDataType): ReactElement[] => {
|
|
70
|
-
const res: ReactElement[] = [];
|
|
71
|
-
//渲染顺序,先渲染顶层容器,再逐步渲染底层的子容器
|
|
72
|
-
this.parser(layerManager, LayerOrder.ASC).forEach((item: ILayerItem) => {
|
|
73
|
-
res.push(this.buildComponents(layerManager, item));
|
|
74
|
-
});
|
|
75
|
-
//重置排序编号
|
|
76
|
-
this.order = 1;
|
|
77
|
-
return res;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private buildComponents = (layerManager: LayerManagerDataType, layer: ILayerItem): ReactElement => {
|
|
81
|
-
const { type, children } = layer;
|
|
82
|
-
const { layerConfigs } = layerManager;
|
|
83
|
-
const targetLayer = layerConfigs[layer.id!];
|
|
84
|
-
//给每个图层重新设置排序编号,用于在图层移动的过程中提供更好的体验
|
|
85
|
-
if (targetLayer)
|
|
86
|
-
targetLayer.order = this.order++;
|
|
87
|
-
if (type === 'group') {
|
|
88
|
-
//先生成子元素再包裹groupItem
|
|
89
|
-
const childDomArr: ReactElement[] = children?.map((item: ILayerItem) => this.buildComponents(layerManager, item));
|
|
90
|
-
return createElement(GroupLayer, { key: layer.id }, ...childDomArr);
|
|
91
|
-
} else {
|
|
92
|
-
return createElement(ComponentContainer, { layer, key: layer.id, layerManager });
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const layerBuilder = new LayerBuilder();
|
|
1
|
+
import { createElement, ReactElement } from "react";
|
|
2
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
3
|
+
import ComponentContainer from "./component-container";
|
|
4
|
+
import { ILayerItem, LayerManagerDataType, } from "../interface";
|
|
5
|
+
import GroupLayer from "./group-layer";
|
|
6
|
+
|
|
7
|
+
export enum LayerOrder {
|
|
8
|
+
ASC,
|
|
9
|
+
DESC,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class LayerBuilder {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 解析函数
|
|
16
|
+
*/
|
|
17
|
+
public parser = (layerManager: LayerManagerDataType, order: LayerOrder = LayerOrder.DESC): ILayerItem[] => {
|
|
18
|
+
const { layerHeader, layerConfigs } = layerManager;
|
|
19
|
+
const layerMap = cloneDeep(layerConfigs);
|
|
20
|
+
let sourceLayerArr: ILayerItem[] = [];
|
|
21
|
+
|
|
22
|
+
const iterateLayers = (currentLayer: ILayerItem, res: ILayerItem[]): void => {
|
|
23
|
+
if (currentLayer) {
|
|
24
|
+
res.push(currentLayer);
|
|
25
|
+
if (currentLayer.childHeader) {
|
|
26
|
+
let childLayer = layerMap[currentLayer.childHeader];
|
|
27
|
+
iterateLayers(childLayer, res);
|
|
28
|
+
}
|
|
29
|
+
let next = currentLayer.next;
|
|
30
|
+
while (next) {
|
|
31
|
+
const nextLayer = layerMap[next!];
|
|
32
|
+
if (nextLayer?.childHeader)
|
|
33
|
+
iterateLayers(layerMap[nextLayer.childHeader], res);
|
|
34
|
+
nextLayer && res.push(nextLayer);
|
|
35
|
+
next = nextLayer?.next;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
iterateLayers(layerMap[layerHeader!], sourceLayerArr);
|
|
41
|
+
|
|
42
|
+
if (order === LayerOrder.ASC)
|
|
43
|
+
sourceLayerArr = sourceLayerArr.reverse();
|
|
44
|
+
|
|
45
|
+
// 构建树结构
|
|
46
|
+
const resData: ILayerItem[] = [];
|
|
47
|
+
for (const layerItem of sourceLayerArr) {
|
|
48
|
+
if (!layerItem?.pid) {
|
|
49
|
+
// 根节点
|
|
50
|
+
resData.push(layerItem);
|
|
51
|
+
} else {
|
|
52
|
+
// 非根节点,将其加入父节点的 children 中
|
|
53
|
+
const parent = layerMap[layerItem.pid];
|
|
54
|
+
if (parent) {
|
|
55
|
+
parent.children = parent.children || [];
|
|
56
|
+
parent.children.push(layerItem);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return resData;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
private order: number = 1;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 构建设计器主画布组件
|
|
67
|
+
* @param layerMap
|
|
68
|
+
*/
|
|
69
|
+
public buildCanvasComponents = (layerManager: LayerManagerDataType): ReactElement[] => {
|
|
70
|
+
const res: ReactElement[] = [];
|
|
71
|
+
//渲染顺序,先渲染顶层容器,再逐步渲染底层的子容器
|
|
72
|
+
this.parser(layerManager, LayerOrder.ASC).forEach((item: ILayerItem) => {
|
|
73
|
+
res.push(this.buildComponents(layerManager, item));
|
|
74
|
+
});
|
|
75
|
+
//重置排序编号
|
|
76
|
+
this.order = 1;
|
|
77
|
+
return res;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private buildComponents = (layerManager: LayerManagerDataType, layer: ILayerItem): ReactElement => {
|
|
81
|
+
const { type, children } = layer;
|
|
82
|
+
const { layerConfigs } = layerManager;
|
|
83
|
+
const targetLayer = layerConfigs[layer.id!];
|
|
84
|
+
//给每个图层重新设置排序编号,用于在图层移动的过程中提供更好的体验
|
|
85
|
+
if (targetLayer)
|
|
86
|
+
targetLayer.order = this.order++;
|
|
87
|
+
if (type === 'group') {
|
|
88
|
+
//先生成子元素再包裹groupItem
|
|
89
|
+
const childDomArr: ReactElement[] = children?.map((item: ILayerItem) => this.buildComponents(layerManager, item));
|
|
90
|
+
return createElement(GroupLayer, { key: layer.id }, ...childDomArr);
|
|
91
|
+
} else {
|
|
92
|
+
return createElement(ComponentContainer, { layer, key: layer.id, layerManager });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const layerBuilder = new LayerBuilder();
|
|
99
99
|
export default layerBuilder;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
.react-screen-box {
|
|
2
|
-
background-size: 100% 100%;
|
|
3
|
-
width: 100%;
|
|
4
|
-
height: 100%;
|
|
5
|
-
overflow: hidden;
|
|
6
|
-
|
|
7
|
-
.screen-wrapper {
|
|
8
|
-
transition-property: all;
|
|
9
|
-
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
10
|
-
transition-duration: 300ms;
|
|
11
|
-
position: relative;
|
|
12
|
-
transform-origin: left top;
|
|
13
|
-
}
|
|
1
|
+
.react-screen-box {
|
|
2
|
+
background-size: 100% 100%;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
|
|
7
|
+
.screen-wrapper {
|
|
8
|
+
transition-property: all;
|
|
9
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
10
|
+
transition-duration: 300ms;
|
|
11
|
+
position: relative;
|
|
12
|
+
transform-origin: left top;
|
|
13
|
+
}
|
|
14
14
|
}
|
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
/* eslint-disable no-unused-expressions */
|
|
2
|
-
import React, { ReactNode, useEffect, useRef, useState } from 'react'
|
|
3
|
-
import debounce from "lodash/debounce";
|
|
4
|
-
import './index.less';
|
|
5
|
-
import { AdaptationType } from "../../interface";
|
|
6
|
-
|
|
7
|
-
interface ScreenFitProps {
|
|
8
|
-
children?: ReactNode,
|
|
9
|
-
width: number | string,
|
|
10
|
-
height: number | string,
|
|
11
|
-
bodyOverflowHidden?: boolean,
|
|
12
|
-
delay?: number,
|
|
13
|
-
mode?: AdaptationType,
|
|
14
|
-
scaleChange?: (xScale: number, yScale: number) => void,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export default function ScreenFit(props: ScreenFitProps) {
|
|
19
|
-
const { width, height, bodyOverflowHidden = true, delay = 200, scaleChange } = props
|
|
20
|
-
let bodyOverflow: string
|
|
21
|
-
const elRef = useRef<HTMLDivElement>(null);
|
|
22
|
-
const canvasRef = useRef(null);
|
|
23
|
-
const [size, setSize] = useState({ width, height, originalHeight: 0, originalWidth: 0 })
|
|
24
|
-
|
|
25
|
-
let observer: ResizeObserver;
|
|
26
|
-
|
|
27
|
-
function updateSize() {
|
|
28
|
-
if (size.width && size.height) {
|
|
29
|
-
elRef.current.style.width = `${size.width}px`
|
|
30
|
-
elRef.current.style.height = `${size.height}px`
|
|
31
|
-
} else {
|
|
32
|
-
elRef.current.style.width = `${size.originalWidth}px`
|
|
33
|
-
elRef.current.style.height = `${size.originalHeight}px`
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function updateScale() {
|
|
38
|
-
// 获取真实视口尺寸
|
|
39
|
-
const currentWidth = canvasRef.current?.clientWidth || 0;
|
|
40
|
-
const currentHeight = canvasRef.current?.clientHeight || 0;
|
|
41
|
-
// 获取大屏最终的宽高
|
|
42
|
-
const realWidth = size.width || size.originalWidth;
|
|
43
|
-
const realHeight = size.height || size.originalHeight;
|
|
44
|
-
// 计算缩放比例
|
|
45
|
-
const widthScale = currentWidth / +realWidth;
|
|
46
|
-
const heightScale = currentHeight / +realHeight;
|
|
47
|
-
switch (props.mode) {
|
|
48
|
-
case 'full-screen':
|
|
49
|
-
// 若要铺满全屏,则按照各自比例缩放
|
|
50
|
-
elRef.current.style.transform = `scale(${widthScale},${heightScale})`;
|
|
51
|
-
scaleChange?.(widthScale, heightScale);
|
|
52
|
-
break;
|
|
53
|
-
case 'full-x':
|
|
54
|
-
elRef.current.style.transform = `scale(${widthScale})`;
|
|
55
|
-
canvasRef.current.style.height = `${Number(realHeight) * widthScale}px`;
|
|
56
|
-
scaleChange?.(widthScale, widthScale);
|
|
57
|
-
break;
|
|
58
|
-
case 'full-y':
|
|
59
|
-
elRef.current.style.transform = `scale(${heightScale})`;
|
|
60
|
-
canvasRef.current.style.width = `${Number(realWidth) * heightScale}px`;
|
|
61
|
-
scaleChange?.(heightScale, heightScale);
|
|
62
|
-
if (currentWidth > (+realWidth * heightScale)) {
|
|
63
|
-
elRef.current.style.margin = `0px ${(currentWidth - +realWidth * heightScale) / 2}px`;
|
|
64
|
-
} else {
|
|
65
|
-
elRef.current.style.margin = "0px";
|
|
66
|
-
}
|
|
67
|
-
break;
|
|
68
|
-
default:
|
|
69
|
-
// 按照宽高最小比例进行缩放
|
|
70
|
-
const scale = Math.min(widthScale, heightScale);
|
|
71
|
-
elRef.current.style.transform = `scale(${scale},${scale})`;
|
|
72
|
-
const domWidth = elRef.current.clientWidth;
|
|
73
|
-
const domHeight = elRef.current.clientHeight;
|
|
74
|
-
const mx = Math.max((currentWidth - domWidth * scale) / 2, 0);
|
|
75
|
-
const my = Math.max((currentHeight - domHeight * scale) / 2, 0);
|
|
76
|
-
elRef.current.style.margin = `${my}px ${mx}px`;
|
|
77
|
-
scaleChange?.(scale, scale);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const onResize = debounce(() => {
|
|
83
|
-
if (!elRef.current && !canvasRef.current) return;
|
|
84
|
-
updateSize();
|
|
85
|
-
updateScale();
|
|
86
|
-
}, delay)
|
|
87
|
-
|
|
88
|
-
function initState() {
|
|
89
|
-
if (bodyOverflowHidden) {
|
|
90
|
-
bodyOverflow = document.body.style.overflow;
|
|
91
|
-
document.body.style.overflow = 'hidden';
|
|
92
|
-
}
|
|
93
|
-
observer = new ResizeObserver(() => onResize());
|
|
94
|
-
observer.observe(canvasRef.current);
|
|
95
|
-
setSize({
|
|
96
|
-
...size,
|
|
97
|
-
originalWidth: window.screen.width,
|
|
98
|
-
originalHeight: window.screen.height
|
|
99
|
-
})
|
|
100
|
-
updateSize();
|
|
101
|
-
updateScale();
|
|
102
|
-
window.addEventListener('resize', onResize);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
initState();
|
|
107
|
-
return () => {
|
|
108
|
-
observer.disconnect();
|
|
109
|
-
window.removeEventListener('resize', onResize);
|
|
110
|
-
if (bodyOverflowHidden)
|
|
111
|
-
document.body.style.overflow = bodyOverflow;
|
|
112
|
-
}
|
|
113
|
-
}, [])
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<div ref={canvasRef} className={'react-screen-box'} >
|
|
117
|
-
<div className={'screen-wrapper'} ref={elRef}>
|
|
118
|
-
{props.children}
|
|
119
|
-
</div>
|
|
120
|
-
</div>
|
|
121
|
-
)
|
|
1
|
+
/* eslint-disable no-unused-expressions */
|
|
2
|
+
import React, { ReactNode, useEffect, useRef, useState } from 'react'
|
|
3
|
+
import debounce from "lodash/debounce";
|
|
4
|
+
import './index.less';
|
|
5
|
+
import { AdaptationType } from "../../interface";
|
|
6
|
+
|
|
7
|
+
interface ScreenFitProps {
|
|
8
|
+
children?: ReactNode,
|
|
9
|
+
width: number | string,
|
|
10
|
+
height: number | string,
|
|
11
|
+
bodyOverflowHidden?: boolean,
|
|
12
|
+
delay?: number,
|
|
13
|
+
mode?: AdaptationType,
|
|
14
|
+
scaleChange?: (xScale: number, yScale: number) => void,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export default function ScreenFit(props: ScreenFitProps) {
|
|
19
|
+
const { width, height, bodyOverflowHidden = true, delay = 200, scaleChange } = props
|
|
20
|
+
let bodyOverflow: string
|
|
21
|
+
const elRef = useRef<HTMLDivElement>(null);
|
|
22
|
+
const canvasRef = useRef(null);
|
|
23
|
+
const [size, setSize] = useState({ width, height, originalHeight: 0, originalWidth: 0 })
|
|
24
|
+
|
|
25
|
+
let observer: ResizeObserver;
|
|
26
|
+
|
|
27
|
+
function updateSize() {
|
|
28
|
+
if (size.width && size.height) {
|
|
29
|
+
elRef.current.style.width = `${size.width}px`
|
|
30
|
+
elRef.current.style.height = `${size.height}px`
|
|
31
|
+
} else {
|
|
32
|
+
elRef.current.style.width = `${size.originalWidth}px`
|
|
33
|
+
elRef.current.style.height = `${size.originalHeight}px`
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function updateScale() {
|
|
38
|
+
// 获取真实视口尺寸
|
|
39
|
+
const currentWidth = canvasRef.current?.clientWidth || 0;
|
|
40
|
+
const currentHeight = canvasRef.current?.clientHeight || 0;
|
|
41
|
+
// 获取大屏最终的宽高
|
|
42
|
+
const realWidth = size.width || size.originalWidth;
|
|
43
|
+
const realHeight = size.height || size.originalHeight;
|
|
44
|
+
// 计算缩放比例
|
|
45
|
+
const widthScale = currentWidth / +realWidth;
|
|
46
|
+
const heightScale = currentHeight / +realHeight;
|
|
47
|
+
switch (props.mode) {
|
|
48
|
+
case 'full-screen':
|
|
49
|
+
// 若要铺满全屏,则按照各自比例缩放
|
|
50
|
+
elRef.current.style.transform = `scale(${widthScale},${heightScale})`;
|
|
51
|
+
scaleChange?.(widthScale, heightScale);
|
|
52
|
+
break;
|
|
53
|
+
case 'full-x':
|
|
54
|
+
elRef.current.style.transform = `scale(${widthScale})`;
|
|
55
|
+
canvasRef.current.style.height = `${Number(realHeight) * widthScale}px`;
|
|
56
|
+
scaleChange?.(widthScale, widthScale);
|
|
57
|
+
break;
|
|
58
|
+
case 'full-y':
|
|
59
|
+
elRef.current.style.transform = `scale(${heightScale})`;
|
|
60
|
+
canvasRef.current.style.width = `${Number(realWidth) * heightScale}px`;
|
|
61
|
+
scaleChange?.(heightScale, heightScale);
|
|
62
|
+
if (currentWidth > (+realWidth * heightScale)) {
|
|
63
|
+
elRef.current.style.margin = `0px ${(currentWidth - +realWidth * heightScale) / 2}px`;
|
|
64
|
+
} else {
|
|
65
|
+
elRef.current.style.margin = "0px";
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
// 按照宽高最小比例进行缩放
|
|
70
|
+
const scale = Math.min(widthScale, heightScale);
|
|
71
|
+
elRef.current.style.transform = `scale(${scale},${scale})`;
|
|
72
|
+
const domWidth = elRef.current.clientWidth;
|
|
73
|
+
const domHeight = elRef.current.clientHeight;
|
|
74
|
+
const mx = Math.max((currentWidth - domWidth * scale) / 2, 0);
|
|
75
|
+
const my = Math.max((currentHeight - domHeight * scale) / 2, 0);
|
|
76
|
+
elRef.current.style.margin = `${my}px ${mx}px`;
|
|
77
|
+
scaleChange?.(scale, scale);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const onResize = debounce(() => {
|
|
83
|
+
if (!elRef.current && !canvasRef.current) return;
|
|
84
|
+
updateSize();
|
|
85
|
+
updateScale();
|
|
86
|
+
}, delay)
|
|
87
|
+
|
|
88
|
+
function initState() {
|
|
89
|
+
if (bodyOverflowHidden) {
|
|
90
|
+
bodyOverflow = document.body.style.overflow;
|
|
91
|
+
document.body.style.overflow = 'hidden';
|
|
92
|
+
}
|
|
93
|
+
observer = new ResizeObserver(() => onResize());
|
|
94
|
+
observer.observe(canvasRef.current);
|
|
95
|
+
setSize({
|
|
96
|
+
...size,
|
|
97
|
+
originalWidth: window.screen.width,
|
|
98
|
+
originalHeight: window.screen.height
|
|
99
|
+
})
|
|
100
|
+
updateSize();
|
|
101
|
+
updateScale();
|
|
102
|
+
window.addEventListener('resize', onResize);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
initState();
|
|
107
|
+
return () => {
|
|
108
|
+
observer.disconnect();
|
|
109
|
+
window.removeEventListener('resize', onResize);
|
|
110
|
+
if (bodyOverflowHidden)
|
|
111
|
+
document.body.style.overflow = bodyOverflow;
|
|
112
|
+
}
|
|
113
|
+
}, [])
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div ref={canvasRef} className={'react-screen-box'} >
|
|
117
|
+
<div className={'screen-wrapper'} ref={elRef}>
|
|
118
|
+
{props.children}
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
)
|
|
122
122
|
}
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
import React, { ForwardedRef, forwardRef, useMemo, useImperativeHandle, useState } from 'react';
|
|
3
|
-
import Units from "../../units/index";
|
|
4
|
-
import { useLocale } from "../../locale/useLocale";
|
|
5
|
-
|
|
6
|
-
const defStyle = {
|
|
7
|
-
color: '#9a9a9a',
|
|
8
|
-
height: '100%',
|
|
9
|
-
display: 'flex',
|
|
10
|
-
justifyContent: 'center',
|
|
11
|
-
alignItems: 'center',
|
|
12
|
-
border: '1px solid #9a9a9a',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export interface ComponentProps {
|
|
16
|
-
style: { key: string; compsIds?: string[]; },
|
|
17
|
-
isDesignMode?: boolean; // 是否编辑模式
|
|
18
|
-
initSearchParams?: { [key: string]: any }; // 全局初始化外部参数,例:传参包含设备id,则在查询时带上设备id
|
|
19
|
-
setSearchParams: (data: any) => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface CompImageonentRef {
|
|
23
|
-
updateConfig: (newConfig: ComponentProps) => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const PlaceholderComponent = forwardRef((props: ComponentProps, ref: ForwardedRef<CompImageonentRef>) => {
|
|
27
|
-
const { isDesignMode, setSearchParams, style } = props;
|
|
28
|
-
const { translate } = useLocale();
|
|
29
|
-
const [key, setKey] = useState<string>(style?.key);
|
|
30
|
-
const [initSearchParams, setInitSearchParams] = useState<{ [key: string]: any }>();
|
|
31
|
-
const [compsIds, setCompsIds] = useState<string[]>(style?.compsIds || []);
|
|
32
|
-
|
|
33
|
-
useImperativeHandle(ref, () => ({
|
|
34
|
-
updateConfig: (newConfig) => {
|
|
35
|
-
setKey(newConfig.style?.key);
|
|
36
|
-
setInitSearchParams(newConfig.initSearchParams || {});
|
|
37
|
-
setCompsIds(newConfig.style?.compsIds || []);
|
|
38
|
-
},
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const handleParams = (params: { [key: string]: any }) => {
|
|
43
|
-
if (!compsIds?.length) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
setSearchParams(val => {
|
|
47
|
-
const temObj = {};
|
|
48
|
-
for (const compId of compsIds) {
|
|
49
|
-
if (val[compId]) { // 全局搜索参数中存在当前组件的搜索参数,则合并
|
|
50
|
-
val[compId] = { ...val[compId], ...params }
|
|
51
|
-
} else {
|
|
52
|
-
temObj[compId] = params;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return { ...val, ...temObj };
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const renderComponent = useMemo(() => {
|
|
61
|
-
const temComponent = Units.getCustomComponent(key);
|
|
62
|
-
if (temComponent) {
|
|
63
|
-
return React.createElement(temComponent, { params: initSearchParams, handleParams });
|
|
64
|
-
}
|
|
65
|
-
return <div style={defStyle}>{translate("${没有找到自定义组件}")}</div>;
|
|
66
|
-
}, [key, initSearchParams]);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div style={{ width: '100%', height: '100%' }}>
|
|
70
|
-
{isDesignMode || !key ?
|
|
71
|
-
<div style={defStyle}>
|
|
72
|
-
<div>{translate("${占位组件}")}</div>
|
|
73
|
-
</div> :
|
|
74
|
-
<div style={{ width: '100%', height: '100%', overflow: "auto" }}>
|
|
75
|
-
{renderComponent}
|
|
76
|
-
</div>
|
|
77
|
-
}
|
|
78
|
-
</div>
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
1
|
+
|
|
2
|
+
import React, { ForwardedRef, forwardRef, useMemo, useImperativeHandle, useState } from 'react';
|
|
3
|
+
import Units from "../../units/index";
|
|
4
|
+
import { useLocale } from "../../locale/useLocale";
|
|
5
|
+
|
|
6
|
+
const defStyle = {
|
|
7
|
+
color: '#9a9a9a',
|
|
8
|
+
height: '100%',
|
|
9
|
+
display: 'flex',
|
|
10
|
+
justifyContent: 'center',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
border: '1px solid #9a9a9a',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export interface ComponentProps {
|
|
16
|
+
style: { key: string; compsIds?: string[]; },
|
|
17
|
+
isDesignMode?: boolean; // 是否编辑模式
|
|
18
|
+
initSearchParams?: { [key: string]: any }; // 全局初始化外部参数,例:传参包含设备id,则在查询时带上设备id
|
|
19
|
+
setSearchParams: (data: any) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CompImageonentRef {
|
|
23
|
+
updateConfig: (newConfig: ComponentProps) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const PlaceholderComponent = forwardRef((props: ComponentProps, ref: ForwardedRef<CompImageonentRef>) => {
|
|
27
|
+
const { isDesignMode, setSearchParams, style } = props;
|
|
28
|
+
const { translate } = useLocale();
|
|
29
|
+
const [key, setKey] = useState<string>(style?.key);
|
|
30
|
+
const [initSearchParams, setInitSearchParams] = useState<{ [key: string]: any }>();
|
|
31
|
+
const [compsIds, setCompsIds] = useState<string[]>(style?.compsIds || []);
|
|
32
|
+
|
|
33
|
+
useImperativeHandle(ref, () => ({
|
|
34
|
+
updateConfig: (newConfig) => {
|
|
35
|
+
setKey(newConfig.style?.key);
|
|
36
|
+
setInitSearchParams(newConfig.initSearchParams || {});
|
|
37
|
+
setCompsIds(newConfig.style?.compsIds || []);
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const handleParams = (params: { [key: string]: any }) => {
|
|
43
|
+
if (!compsIds?.length) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
setSearchParams(val => {
|
|
47
|
+
const temObj = {};
|
|
48
|
+
for (const compId of compsIds) {
|
|
49
|
+
if (val[compId]) { // 全局搜索参数中存在当前组件的搜索参数,则合并
|
|
50
|
+
val[compId] = { ...val[compId], ...params }
|
|
51
|
+
} else {
|
|
52
|
+
temObj[compId] = params;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return { ...val, ...temObj };
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const renderComponent = useMemo(() => {
|
|
61
|
+
const temComponent = Units.getCustomComponent(key);
|
|
62
|
+
if (temComponent) {
|
|
63
|
+
return React.createElement(temComponent, { params: initSearchParams, handleParams });
|
|
64
|
+
}
|
|
65
|
+
return <div style={defStyle}>{translate("${没有找到自定义组件}")}</div>;
|
|
66
|
+
}, [key, initSearchParams]);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div style={{ width: '100%', height: '100%' }}>
|
|
70
|
+
{isDesignMode || !key ?
|
|
71
|
+
<div style={defStyle}>
|
|
72
|
+
<div>{translate("${占位组件}")}</div>
|
|
73
|
+
</div> :
|
|
74
|
+
<div style={{ width: '100%', height: '100%', overflow: "auto" }}>
|
|
75
|
+
{renderComponent}
|
|
76
|
+
</div>
|
|
77
|
+
}
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
82
|
export default PlaceholderComponent;
|