@aks-dev/easyui 1.0.199 → 1.0.200
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/dist/index.js +32 -20
- package/package.json +2 -2
- package/types/index.d.ts +0 -18
- package/types/index.d.ts.map +1 -1
- package/dist/components/AnimationModal/AnimationModal.js +0 -151
- package/dist/components/Badge/Badge.js +0 -35
- package/dist/components/DottedLine/DottedLine.js +0 -50
- package/dist/components/Echarts/EchartsView.js +0 -151
- package/dist/components/Echarts/helper.js +0 -64
- package/dist/components/MenuView/MenuView.js +0 -184
- package/dist/components/Modal/Modal.js +0 -8
- package/dist/components/MutiPictureView/MutiPictureView.js +0 -239
- package/dist/components/PictureViewer/PictureViewer.js +0 -54
- package/dist/components/RefreshList/RefreshList.js +0 -155
- package/dist/components/RichText/RichText.js +0 -56
- package/dist/components/StickHeaderView/StickHeaderView.js +0 -37
- package/dist/components/TableCell/TableCell.js +0 -97
- package/dist/components/TextInputArea/TextInputArea.js +0 -65
- package/dist/components/WithLoadingContainer/WithLoadingContainer.js +0 -77
- package/types/components/AnimationModal/AnimationModal.d.ts +0 -27
- package/types/components/AnimationModal/AnimationModal.d.ts.map +0 -1
- package/types/components/Badge/Badge.d.ts +0 -8
- package/types/components/Badge/Badge.d.ts.map +0 -1
- package/types/components/DottedLine/DottedLine.d.ts +0 -10
- package/types/components/DottedLine/DottedLine.d.ts.map +0 -1
- package/types/components/Echarts/EchartsView.d.ts +0 -12
- package/types/components/Echarts/EchartsView.d.ts.map +0 -1
- package/types/components/Echarts/helper.d.ts +0 -10
- package/types/components/Echarts/helper.d.ts.map +0 -1
- package/types/components/MenuView/MenuView.d.ts +0 -21
- package/types/components/MenuView/MenuView.d.ts.map +0 -1
- package/types/components/Modal/Modal.d.ts +0 -2
- package/types/components/Modal/Modal.d.ts.map +0 -1
- package/types/components/MutiPictureView/MutiPictureView.d.ts +0 -50
- package/types/components/MutiPictureView/MutiPictureView.d.ts.map +0 -1
- package/types/components/PictureViewer/PictureViewer.d.ts +0 -17
- package/types/components/PictureViewer/PictureViewer.d.ts.map +0 -1
- package/types/components/RefreshList/RefreshList.d.ts +0 -45
- package/types/components/RefreshList/RefreshList.d.ts.map +0 -1
- package/types/components/RichText/RichText.d.ts +0 -12
- package/types/components/RichText/RichText.d.ts.map +0 -1
- package/types/components/StickHeaderView/StickHeaderView.d.ts +0 -15
- package/types/components/StickHeaderView/StickHeaderView.d.ts.map +0 -1
- package/types/components/TableCell/TableCell.d.ts +0 -24
- package/types/components/TableCell/TableCell.d.ts.map +0 -1
- package/types/components/TextInputArea/TextInputArea.d.ts +0 -17
- package/types/components/TextInputArea/TextInputArea.d.ts.map +0 -1
- package/types/components/WithLoadingContainer/WithLoadingContainer.d.ts +0 -23
- package/types/components/WithLoadingContainer/WithLoadingContainer.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -6,25 +6,37 @@
|
|
|
6
6
|
* @FilePath: /@aks-dev/easyui/src/index.ts
|
|
7
7
|
*/
|
|
8
8
|
/// 组件
|
|
9
|
-
export
|
|
9
|
+
// export { Badge } from "./components/Badge/Badge";
|
|
10
|
+
// export type { BadgeProps } from "./components/Badge/Badge";
|
|
10
11
|
export { Hud, showLoading, hideLoading, showToast, showAlertModal, showAlertBottomModal, showAlertSheetModal, showPopoverView, hidePopoverView, showScanner, hideScanner, } from "./components/Hud/Hud";
|
|
11
|
-
export
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export { default as
|
|
21
|
-
export { default as
|
|
22
|
-
export {
|
|
23
|
-
|
|
12
|
+
// export { Modal } from "./components/Modal/Modal";
|
|
13
|
+
// export type { ModalProps } from "./components/Modal/Modal";
|
|
14
|
+
// export { default as MutiPictureView } from "./components/MutiPictureView/MutiPictureView";
|
|
15
|
+
// export { PictureViewer } from "./components/PictureViewer/PictureViewer";
|
|
16
|
+
// export {
|
|
17
|
+
// default as RefreshList,
|
|
18
|
+
// RefreshState,
|
|
19
|
+
// RefreshText,
|
|
20
|
+
// } from "./components/RefreshList/RefreshList";
|
|
21
|
+
// export { default as TableCell } from "./components/TableCell/TableCell";
|
|
22
|
+
// export { default as TextInputArea } from "./components/TextInputArea/TextInputArea";
|
|
23
|
+
// export {
|
|
24
|
+
// default as WithLoadingContainer,
|
|
25
|
+
// Status,
|
|
26
|
+
// } from "./components/WithLoadingContainer/WithLoadingContainer";
|
|
27
|
+
// export { default as StickHeaderView } from "./components/StickHeaderView/StickHeaderView";
|
|
28
|
+
// export {
|
|
29
|
+
// default as EchartsView,
|
|
30
|
+
// echarts,
|
|
31
|
+
// } from "./components/Echarts/EchartsView";
|
|
32
|
+
// export { default as RichText } from "./components/RichText/RichText";
|
|
33
|
+
// export { default as DottedLine } from "./components/DottedLine/DottedLine";
|
|
34
|
+
// export { default as MenuView } from "./components/MenuView/MenuView";
|
|
35
|
+
// export { AnimationModal } from "./components/AnimationModal/AnimationModal";
|
|
24
36
|
/// 全局适配
|
|
25
|
-
export * from "./screen";
|
|
26
|
-
/// 工具
|
|
27
|
-
import * as utils from "./utils";
|
|
28
|
-
/// 桥接
|
|
29
|
-
import * as jsbridge from "./jsbridge";
|
|
30
|
-
export { utils, jsbridge };
|
|
37
|
+
// export * from "./screen";
|
|
38
|
+
// /// 工具
|
|
39
|
+
// import * as utils from "./utils";
|
|
40
|
+
// /// 桥接
|
|
41
|
+
// import * as jsbridge from "./jsbridge";
|
|
42
|
+
// export { utils, jsbridge };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aks-dev/easyui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.200",
|
|
4
4
|
"description": "工具箱",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"release": "yarn semantic-release",
|
|
14
14
|
"cp": "cp -r -v src/assets dist/assets",
|
|
15
15
|
"rsync": "rsync -av --include='*/' --exclude='*.tsx' --exclude='demo.tsx' --exclude='*.ts' src/ dist/",
|
|
16
|
-
"build": "tsc && rsync -rv --include='*/' --exclude='*.tsx' --exclude='demo.tsx' --exclude='*.ts' src/ dist/",
|
|
16
|
+
"build": "tsc --importHelpers && rsync -rv --include='*/' --exclude='*.tsx' --exclude='demo.tsx' --exclude='*.ts' src/ dist/",
|
|
17
17
|
"types": "tsc --emitDeclarationOnly --declaration --declarationMap --declarationDir ./types",
|
|
18
18
|
"dev": "tsc --watch",
|
|
19
19
|
"test:ts": "tsc --noEmit"
|
package/types/index.d.ts
CHANGED
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
export * from "./components/Badge/Badge";
|
|
2
1
|
export { Hud, showLoading, hideLoading, showToast, showAlertModal, showAlertBottomModal, showAlertSheetModal, showPopoverView, hidePopoverView, showScanner, hideScanner, } from "./components/Hud/Hud";
|
|
3
|
-
export * from "./components/Modal/Modal";
|
|
4
|
-
export { default as MutiPictureView } from "./components/MutiPictureView/MutiPictureView";
|
|
5
|
-
export { PictureViewer } from "./components/PictureViewer/PictureViewer";
|
|
6
|
-
export { default as RefreshList, RefreshState, RefreshText, } from "./components/RefreshList/RefreshList";
|
|
7
|
-
export { default as TableCell } from "./components/TableCell/TableCell";
|
|
8
|
-
export { default as TextInputArea } from "./components/TextInputArea/TextInputArea";
|
|
9
|
-
export { default as WithLoadingContainer, Status, } from "./components/WithLoadingContainer/WithLoadingContainer";
|
|
10
|
-
export { default as StickHeaderView } from "./components/StickHeaderView/StickHeaderView";
|
|
11
|
-
export { default as EchartsView, echarts, } from "./components/Echarts/EchartsView";
|
|
12
|
-
export { default as RichText } from "./components/RichText/RichText";
|
|
13
|
-
export { default as DottedLine } from "./components/DottedLine/DottedLine";
|
|
14
|
-
export { default as MenuView } from "./components/MenuView/MenuView";
|
|
15
|
-
export { AnimationModal } from "./components/AnimationModal/AnimationModal";
|
|
16
|
-
export * from "./screen";
|
|
17
|
-
import * as utils from "./utils";
|
|
18
|
-
import * as jsbridge from "./jsbridge";
|
|
19
|
-
export { utils, jsbridge };
|
|
20
2
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,GAAG,EACH,WAAW,EACX,WAAW,EACX,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: shiguo
|
|
3
|
-
* @Date: 2022-05-17 15:22:06
|
|
4
|
-
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2023-09-27 15:17:15
|
|
6
|
-
* @FilePath: /@aks-dev/easyui/lib/AnimationModal/AnimationModal.tsx
|
|
7
|
-
*/
|
|
8
|
-
import * as React from "react";
|
|
9
|
-
import { View, Animated, Easing, PanResponder, StyleSheet, useWindowDimensions, BackHandler, } from "react-native";
|
|
10
|
-
import * as utils from "../../utils/lazy";
|
|
11
|
-
// type State = {
|
|
12
|
-
// display: 'flex' | 'none';
|
|
13
|
-
// }
|
|
14
|
-
// type StateReducerProps = (state: State, action: Partial<State>) => State
|
|
15
|
-
export const AnimationModal = React.forwardRef((props, ref) => {
|
|
16
|
-
const { animationType = "from-bottom", mask = false } = props || {};
|
|
17
|
-
const { height } = useWindowDimensions();
|
|
18
|
-
// const [state, dispatch] = React.useReducer<StateReducerProps>(
|
|
19
|
-
// (state, action) => ({ ...state, ...action }),
|
|
20
|
-
// {
|
|
21
|
-
// display: 'none'
|
|
22
|
-
// })
|
|
23
|
-
const [display, setDisplay] = useCallbackState("none");
|
|
24
|
-
const animatedValue = React.useRef(new Animated.Value(0)).current;
|
|
25
|
-
const timing = (value) => {
|
|
26
|
-
Animated.timing(animatedValue, {
|
|
27
|
-
toValue: value,
|
|
28
|
-
duration: 350,
|
|
29
|
-
useNativeDriver: true,
|
|
30
|
-
easing: Easing.ease,
|
|
31
|
-
}).start(({ finished }) => {
|
|
32
|
-
/* 动画完成的回调函数 */
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
const viewRef = React.useRef(null);
|
|
36
|
-
const layoutRef = React.useRef({ h0: 0, h1: 0 });
|
|
37
|
-
const getLayoutPromise = () => {
|
|
38
|
-
return new Promise((resovle, reject) => {
|
|
39
|
-
viewRef.current?.measure((...args) => {
|
|
40
|
-
if (args.length == 6) {
|
|
41
|
-
layoutRef.current.h1 = args[3];
|
|
42
|
-
}
|
|
43
|
-
resovle(args);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
const init = React.useCallback(() => ({ show, hide, setData, getData }), []);
|
|
48
|
-
React.useImperativeHandle(ref, init, []);
|
|
49
|
-
const dataRef = React.useRef(null);
|
|
50
|
-
const setData = (data) => {
|
|
51
|
-
dataRef.current = data;
|
|
52
|
-
return init();
|
|
53
|
-
};
|
|
54
|
-
const getData = () => dataRef.current;
|
|
55
|
-
const show = () => {
|
|
56
|
-
setDisplay("flex", async () => {
|
|
57
|
-
await utils.sleep(50);
|
|
58
|
-
await getLayoutPromise();
|
|
59
|
-
timing(-layoutRef.current?.h1);
|
|
60
|
-
});
|
|
61
|
-
return init();
|
|
62
|
-
};
|
|
63
|
-
const hide = () => {
|
|
64
|
-
timing(0);
|
|
65
|
-
setTimeout(() => {
|
|
66
|
-
setDisplay("none");
|
|
67
|
-
}, 300);
|
|
68
|
-
return init();
|
|
69
|
-
};
|
|
70
|
-
React.useEffect(() => {
|
|
71
|
-
let addEventListener = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
72
|
-
return display == "flex";
|
|
73
|
-
});
|
|
74
|
-
return () => {
|
|
75
|
-
addEventListener.remove();
|
|
76
|
-
};
|
|
77
|
-
}, [display]);
|
|
78
|
-
return (<View style={Object.assign({
|
|
79
|
-
display: display,
|
|
80
|
-
}, styles.container, props.style)} {...PanResponder.create({
|
|
81
|
-
onStartShouldSetPanResponder: (e, gestureState) => {
|
|
82
|
-
let pageY = e.nativeEvent.pageY;
|
|
83
|
-
let topY = height - layoutRef.current.h1;
|
|
84
|
-
if (pageY <= topY && !mask) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
88
|
-
},
|
|
89
|
-
onPanResponderGrant: (e, gestureState) => {
|
|
90
|
-
// console.log({e})
|
|
91
|
-
let pageY = e.nativeEvent.pageY;
|
|
92
|
-
let topY = height - layoutRef.current.h1;
|
|
93
|
-
if (pageY <= topY && !mask) {
|
|
94
|
-
e.stopPropagation();
|
|
95
|
-
hide();
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
}).panHandlers}>
|
|
99
|
-
<Animated.View style={Object.assign({}, styles.wrapper, {
|
|
100
|
-
transform: [{ translateY: animatedValue }],
|
|
101
|
-
})}
|
|
102
|
-
// onLayout={e => {
|
|
103
|
-
// let target: LayoutRectangle = e.nativeEvent.layout
|
|
104
|
-
// layoutRef.current.h1 = target.height
|
|
105
|
-
// }}
|
|
106
|
-
ref={viewRef}>
|
|
107
|
-
{props.children}
|
|
108
|
-
</Animated.View>
|
|
109
|
-
</View>);
|
|
110
|
-
});
|
|
111
|
-
const styles = StyleSheet.create({
|
|
112
|
-
container: {
|
|
113
|
-
position: "absolute",
|
|
114
|
-
left: 0,
|
|
115
|
-
right: 0,
|
|
116
|
-
top: 0,
|
|
117
|
-
bottom: 0,
|
|
118
|
-
zIndex: 999,
|
|
119
|
-
// display: 'flex',
|
|
120
|
-
flexDirection: "column",
|
|
121
|
-
backgroundColor: "#00000055",
|
|
122
|
-
overflow: "hidden",
|
|
123
|
-
},
|
|
124
|
-
wrapper: {
|
|
125
|
-
position: "absolute",
|
|
126
|
-
display: "flex",
|
|
127
|
-
flexDirection: "column",
|
|
128
|
-
// backgroundColor: 'pink',
|
|
129
|
-
width: "100%",
|
|
130
|
-
top: "100%",
|
|
131
|
-
},
|
|
132
|
-
empty: {
|
|
133
|
-
flex: 1,
|
|
134
|
-
position: "relative",
|
|
135
|
-
// backgroundColor: 'cyan'
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
const useCallbackState = (od) => {
|
|
139
|
-
const cbRef = React.useRef(undefined);
|
|
140
|
-
const [data, setData] = React.useState(od);
|
|
141
|
-
React.useEffect(() => {
|
|
142
|
-
cbRef.current && cbRef.current(data);
|
|
143
|
-
}, [data]);
|
|
144
|
-
return [
|
|
145
|
-
data,
|
|
146
|
-
(d, callback) => {
|
|
147
|
-
cbRef.current = callback;
|
|
148
|
-
setData(d);
|
|
149
|
-
},
|
|
150
|
-
];
|
|
151
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: shiguo
|
|
3
|
-
* @Date: 2022-04-21 14:40:29
|
|
4
|
-
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-07-08 15:40:21
|
|
6
|
-
* @FilePath: /@aks-dev/easyui/lib/Badge/Badge.tsx
|
|
7
|
-
*/
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { View, Text } from "react-native";
|
|
10
|
-
import { px2dp } from "../../screen/px2dp";
|
|
11
|
-
import { px2sp } from "../../screen/px2sp";
|
|
12
|
-
export const Badge = (props) => {
|
|
13
|
-
if (isNaN(+props.count) || Number(props.count) == 0)
|
|
14
|
-
return <View />;
|
|
15
|
-
return (<View style={[
|
|
16
|
-
{
|
|
17
|
-
flexGrow: 0,
|
|
18
|
-
flexShrink: 1,
|
|
19
|
-
zIndex: 1,
|
|
20
|
-
// paddingHorizontal: px2dp(0),
|
|
21
|
-
height: px2dp(16),
|
|
22
|
-
minWidth: px2dp(16),
|
|
23
|
-
borderRadius: px2dp(8),
|
|
24
|
-
justifyContent: "center",
|
|
25
|
-
alignItems: "center",
|
|
26
|
-
backgroundColor: "red",
|
|
27
|
-
},
|
|
28
|
-
props.style,
|
|
29
|
-
]}>
|
|
30
|
-
<Text style={{ fontSize: px2sp(12), color: "white", textAlign: "center" }}>
|
|
31
|
-
{" "}
|
|
32
|
-
{Number(props.count) > 99 ? "+99" : props.count}{" "}
|
|
33
|
-
</Text>
|
|
34
|
-
</View>);
|
|
35
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: shiguo
|
|
3
|
-
* @Date: 2022-07-12 15:30:19
|
|
4
|
-
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-07-12 15:33:06
|
|
6
|
-
* @FilePath: /@aks-dev/easyui/lib/DottedLine/DottedLine.tsx
|
|
7
|
-
*/
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { StyleSheet, View } from "react-native";
|
|
10
|
-
export default (props) => {
|
|
11
|
-
const { vertical = false, dottedColor, dottedCount = 200, ...rest } = props;
|
|
12
|
-
const arrs = Array.from({ length: dottedCount }, (k, v) => v);
|
|
13
|
-
return (<View style={{
|
|
14
|
-
...styles.container,
|
|
15
|
-
flexDirection: vertical ? "column" : "row",
|
|
16
|
-
...rest.style,
|
|
17
|
-
}}>
|
|
18
|
-
{arrs.map((item, index) => {
|
|
19
|
-
return (<View key={`dotted-${index}`} style={{
|
|
20
|
-
...(vertical ? styles.dotted_vertical : styles.dotted_horizontal),
|
|
21
|
-
...(dottedColor && { backgroundColor: dottedColor }),
|
|
22
|
-
}}/>);
|
|
23
|
-
})}
|
|
24
|
-
</View>);
|
|
25
|
-
};
|
|
26
|
-
const styles = StyleSheet.create({
|
|
27
|
-
container: {
|
|
28
|
-
display: "flex",
|
|
29
|
-
flexGrow: 1,
|
|
30
|
-
overflow: "hidden",
|
|
31
|
-
flexDirection: "row",
|
|
32
|
-
flexWrap: "nowrap",
|
|
33
|
-
},
|
|
34
|
-
dotted_horizontal: {
|
|
35
|
-
flexGrow: 0,
|
|
36
|
-
flexShrink: 0,
|
|
37
|
-
width: 2,
|
|
38
|
-
height: 1,
|
|
39
|
-
marginRight: 2,
|
|
40
|
-
backgroundColor: "#cccccc",
|
|
41
|
-
},
|
|
42
|
-
dotted_vertical: {
|
|
43
|
-
flexGrow: 0,
|
|
44
|
-
flexShrink: 0,
|
|
45
|
-
width: 1,
|
|
46
|
-
height: 2,
|
|
47
|
-
marginBottom: 2,
|
|
48
|
-
backgroundColor: "#cccccc",
|
|
49
|
-
},
|
|
50
|
-
});
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: shiguo
|
|
3
|
-
* @Date: 2022-05-05 14:52:53
|
|
4
|
-
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2023-01-03 17:50:43
|
|
6
|
-
* @FilePath: /@aks-dev/easyui/lib/Echarts/EchartsView.tsx
|
|
7
|
-
*/
|
|
8
|
-
import * as React from "react";
|
|
9
|
-
import { StyleSheet, View, } from "react-native";
|
|
10
|
-
import { WebView } from "react-native-webview";
|
|
11
|
-
import { getHtml, toString } from "./helper";
|
|
12
|
-
// type Reducer = (prevState: State, action: Partial<State>) => State;
|
|
13
|
-
const EchartsView = (props) => {
|
|
14
|
-
const [state, dispatch] = React.useReducer((prevState, ...args) => Object.assign({}, prevState, ...args), {
|
|
15
|
-
width: 0,
|
|
16
|
-
height: 0,
|
|
17
|
-
isLoaded: false,
|
|
18
|
-
});
|
|
19
|
-
const WebViewRef = React.useRef(null);
|
|
20
|
-
const containerRef = React.useRef(null);
|
|
21
|
-
const rootView = React.useRef({ pageX: 0, pageY: 0, width: 0, height: 0 });
|
|
22
|
-
const getRootViewlayoutPromise = () => {
|
|
23
|
-
return new Promise((resovle, reject) => {
|
|
24
|
-
containerRef.current?.measure((...args) => {
|
|
25
|
-
if (args.length == 6) {
|
|
26
|
-
rootView.current = {
|
|
27
|
-
width: args[2],
|
|
28
|
-
height: args[3],
|
|
29
|
-
pageX: args[4],
|
|
30
|
-
pageY: args[5],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
// console.log('RootView', rootView.current)
|
|
34
|
-
resovle(args);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
React.useLayoutEffect(() => {
|
|
39
|
-
(async () => {
|
|
40
|
-
if (state.isLoaded) {
|
|
41
|
-
await getRootViewlayoutPromise();
|
|
42
|
-
let height = rootView.current.height
|
|
43
|
-
? `${rootView.current.height}px`
|
|
44
|
-
: "auto";
|
|
45
|
-
let width = rootView.current.width
|
|
46
|
-
? `${rootView.current.width}px`
|
|
47
|
-
: "auto";
|
|
48
|
-
const run = `
|
|
49
|
-
;(function() {
|
|
50
|
-
var instance = echarts.getInstanceByDom(document.getElementById('main'));
|
|
51
|
-
if(instance == null){
|
|
52
|
-
document.getElementById('main').style.height = "${height}";
|
|
53
|
-
document.getElementById('main').style.width = "${width}";
|
|
54
|
-
instance = echarts.init(document.getElementById('main'));
|
|
55
|
-
}
|
|
56
|
-
instance.clear();
|
|
57
|
-
instance.setOption(${toString(props.option)});
|
|
58
|
-
})();
|
|
59
|
-
`;
|
|
60
|
-
WebViewRef.current?.injectJavaScript(run);
|
|
61
|
-
return () => {
|
|
62
|
-
const run = `
|
|
63
|
-
;(function() {
|
|
64
|
-
var instance = echarts.getInstanceByDom(document.getElementById('main'));
|
|
65
|
-
instance.clear();
|
|
66
|
-
if(!instance.isDisposed()){
|
|
67
|
-
instance.dispose();
|
|
68
|
-
}
|
|
69
|
-
})();
|
|
70
|
-
`;
|
|
71
|
-
WebViewRef.current?.injectJavaScript(run);
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
return undefined;
|
|
75
|
-
})().catch((err) => {
|
|
76
|
-
console.log(err);
|
|
77
|
-
});
|
|
78
|
-
}, [props.option, state.isLoaded]);
|
|
79
|
-
// const injectedJavaScript = (): string => {
|
|
80
|
-
// console.log('injectedJavaScript', props.option.xAxis.data)
|
|
81
|
-
// let height = state.height ? `${state.height}px` : 'auto'
|
|
82
|
-
// let width = state.width ? `${state.width}px` : 'auto'
|
|
83
|
-
// return `
|
|
84
|
-
// ;(function() {
|
|
85
|
-
// document.getElementById('main').style.height = "${height}";
|
|
86
|
-
// document.getElementById('main').style.width = "${width}";
|
|
87
|
-
// var instance = echarts.getInstanceByDom(document.getElementById('main'));
|
|
88
|
-
// if(instance == null){
|
|
89
|
-
// instance = echarts.init(document.getElementById('main'));
|
|
90
|
-
// }
|
|
91
|
-
// instance.clear();
|
|
92
|
-
// instance.setOption(${toString(props.option)});
|
|
93
|
-
// instance.on('click', function(params) {
|
|
94
|
-
// var seen = [];
|
|
95
|
-
// var paramsString = JSON.stringify(params, function(key, val) {
|
|
96
|
-
// if (val != null && typeof val == "object") {
|
|
97
|
-
// if (seen.indexOf(val) >= 0) {
|
|
98
|
-
// return;
|
|
99
|
-
// }
|
|
100
|
-
// seen.push(val);
|
|
101
|
-
// }
|
|
102
|
-
// return val;
|
|
103
|
-
// });
|
|
104
|
-
// // window.ReactNativeWebView.postMessage(JSON.stringify({"types":"ON_PRESS","payload": paramsString}));
|
|
105
|
-
// });
|
|
106
|
-
// })();
|
|
107
|
-
// `
|
|
108
|
-
// }
|
|
109
|
-
return (<View style={[styles.container, props.style]} ref={containerRef}>
|
|
110
|
-
<WebView ref={WebViewRef} originWhitelist={["*"]} useWebKit={true} // ios使用最新webkit内核渲染
|
|
111
|
-
allowUniversalAccessFromFileURLs={true} geolocationEnabled={true} mixedContentMode={"always"} renderLoading={() => {
|
|
112
|
-
if (props.renderLoading)
|
|
113
|
-
return props.renderLoading();
|
|
114
|
-
return (<View style={{
|
|
115
|
-
backgroundColor: props.style?.backgroundColor || "transparent",
|
|
116
|
-
}}/>);
|
|
117
|
-
}} // 设置空View,修复ioswebview闪白
|
|
118
|
-
style={{
|
|
119
|
-
backgroundColor: props.style?.backgroundColor || "transparent",
|
|
120
|
-
opacity: 0.99, //解决闪退的办法
|
|
121
|
-
}} // 设置背景色透明,修复android闪白
|
|
122
|
-
scrollEnabled={false}
|
|
123
|
-
// onMessage={e=>{
|
|
124
|
-
// console.log(e)
|
|
125
|
-
// }}
|
|
126
|
-
javaScriptEnabled={true}
|
|
127
|
-
// injectedJavaScript={injectedJavaScript()}
|
|
128
|
-
startInLoadingState={false} onLoadEnd={(_) => {
|
|
129
|
-
dispatch({ isLoaded: true });
|
|
130
|
-
// console.log('onLoadEnd')
|
|
131
|
-
}} onError={(e) => {
|
|
132
|
-
console.log("onError", e);
|
|
133
|
-
}} source={{
|
|
134
|
-
baseUrl: "",
|
|
135
|
-
html: getHtml({
|
|
136
|
-
backgroundColor: props.style?.backgroundColor || "transparent",
|
|
137
|
-
}),
|
|
138
|
-
}}/>
|
|
139
|
-
</View>);
|
|
140
|
-
};
|
|
141
|
-
const styles = StyleSheet.create({
|
|
142
|
-
container: {
|
|
143
|
-
display: "flex",
|
|
144
|
-
flexGrow: 0,
|
|
145
|
-
backgroundColor: "white",
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
export default EchartsView;
|
|
149
|
-
// React.memo(EchartsView)
|
|
150
|
-
import * as echarts from "echarts/core";
|
|
151
|
-
export { echarts };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: shiguo
|
|
3
|
-
* @Date: 2022-05-05 15:56:21
|
|
4
|
-
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2023-01-03 17:02:57
|
|
6
|
-
* @FilePath: /@aks-dev/easyui/lib/Echarts/helper.tsx
|
|
7
|
-
*/
|
|
8
|
-
export const getHtml = (props) => {
|
|
9
|
-
return `
|
|
10
|
-
<!DOCTYPE html>
|
|
11
|
-
<html>
|
|
12
|
-
|
|
13
|
-
<head>
|
|
14
|
-
<title>echarts</title>
|
|
15
|
-
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
16
|
-
<!-- webView ios适配 start -->
|
|
17
|
-
<meta name="viewport" content="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no">
|
|
18
|
-
<!-- webView ios适配 end -->
|
|
19
|
-
<style type="text/css">
|
|
20
|
-
html,
|
|
21
|
-
body {
|
|
22
|
-
height: 100%;
|
|
23
|
-
width: 100%;
|
|
24
|
-
margin: 0;
|
|
25
|
-
padding: 0;
|
|
26
|
-
background-color: rgba(0, 0, 0, 0);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
#main {
|
|
30
|
-
height: 100%;
|
|
31
|
-
background-color: rgba(0, 0, 0, 0);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
</style>
|
|
35
|
-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.1/echarts.min.js"></script>
|
|
36
|
-
</head>
|
|
37
|
-
|
|
38
|
-
<body style="background-color:${props.backgroundColor}">
|
|
39
|
-
<div id="main"></div>
|
|
40
|
-
</body>
|
|
41
|
-
|
|
42
|
-
</html>
|
|
43
|
-
`;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* https://res.actiiot.com/echarts/5.0.2/echarts.min.js
|
|
47
|
-
*
|
|
48
|
-
* https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.1/echarts.min.js
|
|
49
|
-
*/
|
|
50
|
-
export const toString = (obj) => {
|
|
51
|
-
let result = JSON.stringify(obj, function (key, val) {
|
|
52
|
-
// 对function进行特殊处理
|
|
53
|
-
if (typeof val === 'function') {
|
|
54
|
-
return `~ha~${val}~ha~`;
|
|
55
|
-
}
|
|
56
|
-
return val;
|
|
57
|
-
});
|
|
58
|
-
// 再进行还原
|
|
59
|
-
do {
|
|
60
|
-
result = result.replace('\"~ha~', '').replace('~ha~\"', '').replace(/\\\"/g, "\""); //最后一个replace将release模式中莫名生成的\"转换成"
|
|
61
|
-
} while (result.indexOf('~ha~') >= 0);
|
|
62
|
-
return result;
|
|
63
|
-
};
|
|
64
|
-
///.replace(/\\n/g, '')
|