ipanel-rnapp-ajb-base 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {StyleSheet, View, Text
|
|
1
|
+
import React, {useState, useEffect} from 'react';
|
|
2
|
+
import {StyleSheet, View, Text} from 'react-native';
|
|
3
|
+
import {Icon, Button} from '@rneui/themed';
|
|
4
|
+
import LinearGradient from 'react-native-linear-gradient';
|
|
3
5
|
|
|
4
6
|
const {storage, replace} = global.base;
|
|
5
7
|
|
|
6
8
|
const TestPage = ({navigation}) => {
|
|
9
|
+
const [viewVisible, setViewVisible] = useState(false);
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
// 让视图晚一点渲染,先显示空白,避免默认进入独立页面时,有闪烁感
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
setViewVisible(true);
|
|
15
|
+
}, 500);
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
7
18
|
const onPress = () => {
|
|
8
19
|
global.base.navigateModule({
|
|
9
20
|
operatorId: 'ipanel',
|
|
@@ -13,13 +24,8 @@ const TestPage = ({navigation}) => {
|
|
|
13
24
|
|
|
14
25
|
const handleLogout = async () => {
|
|
15
26
|
await storage.set('accessToken', null);
|
|
27
|
+
await storage.set('refreshToken', null);
|
|
16
28
|
await storage.set('homedAccessToken', null);
|
|
17
|
-
await storage.set('accountType', null);
|
|
18
|
-
await storage.set('addressRoomMap', null);
|
|
19
|
-
await storage.set('roomDeviceMap', null);
|
|
20
|
-
await storage.set('roomDeviceStatusMap', null);
|
|
21
|
-
await storage.set('roomDeviceGroupMap', null);
|
|
22
|
-
await storage.set('roomDeviceSceneMap', null);
|
|
23
29
|
// 如果是在tab页的路由,当前栈路由历史只有首页Home调用会报错,如果是从智能客服进入“我的”,退出登录需要置顶
|
|
24
30
|
if (navigation.getState().type === 'stack') {
|
|
25
31
|
popToTop();
|
|
@@ -30,17 +36,71 @@ const TestPage = ({navigation}) => {
|
|
|
30
36
|
};
|
|
31
37
|
|
|
32
38
|
return (
|
|
33
|
-
<View>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
<View style={styles.container}>
|
|
40
|
+
{viewVisible ? (
|
|
41
|
+
<>
|
|
42
|
+
<View style={styles.container}>
|
|
43
|
+
{viewVisible && (
|
|
44
|
+
<Button
|
|
45
|
+
buttonStyle={styles.previewBtn}
|
|
46
|
+
titleStyle={styles.previewBtnStyle}
|
|
47
|
+
size="lg"
|
|
48
|
+
ViewComponent={LinearGradient} // Don't forget this!
|
|
49
|
+
linearGradientProps={{
|
|
50
|
+
colors: ['#FF9800', '#F44336'],
|
|
51
|
+
start: {x: 0, y: 0.5},
|
|
52
|
+
end: {x: 1, y: 0.5},
|
|
53
|
+
}}
|
|
54
|
+
radius="10"
|
|
55
|
+
onPress={onPress}
|
|
56
|
+
title="点击预览app作为独立页面的效果"
|
|
57
|
+
/>
|
|
58
|
+
)}
|
|
59
|
+
</View>
|
|
60
|
+
<View style={styles.welcomeTextBox}>
|
|
61
|
+
<Text style={styles.welcomeText}>欢迎你,开发者!</Text>
|
|
62
|
+
</View>
|
|
63
|
+
<Icon
|
|
64
|
+
containerStyle={styles.exitBtn}
|
|
65
|
+
type="ionicon"
|
|
66
|
+
name="exit-outline"
|
|
67
|
+
color="#00aced"
|
|
68
|
+
size={30}
|
|
69
|
+
onPress={handleLogout}
|
|
70
|
+
/>
|
|
71
|
+
</>
|
|
72
|
+
) : null}
|
|
40
73
|
</View>
|
|
41
74
|
);
|
|
42
75
|
};
|
|
43
76
|
|
|
44
|
-
const styles = StyleSheet.create({
|
|
77
|
+
const styles = StyleSheet.create({
|
|
78
|
+
container: {
|
|
79
|
+
flex: 1,
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
justifyContent: 'center',
|
|
82
|
+
backgroundColor: '#F2F2F2',
|
|
83
|
+
},
|
|
84
|
+
previewBtn: {
|
|
85
|
+
height: 70,
|
|
86
|
+
},
|
|
87
|
+
previewBtnStyle: {
|
|
88
|
+
fontSize: 18,
|
|
89
|
+
},
|
|
90
|
+
welcomeTextBox: {
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
top: 200,
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
justifyContent: 'center',
|
|
95
|
+
},
|
|
96
|
+
welcomeText: {
|
|
97
|
+
fontSize: 24,
|
|
98
|
+
},
|
|
99
|
+
exitBtn: {
|
|
100
|
+
position: 'absolute',
|
|
101
|
+
top: 40,
|
|
102
|
+
right: 20,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
45
105
|
|
|
46
106
|
export default TestPage;
|
package/bin/local-dev.js
CHANGED
|
@@ -3,6 +3,60 @@
|
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
|
|
6
|
+
// stat = fs.stat;
|
|
7
|
+
/*
|
|
8
|
+
* 复制目录中的所有文件包括子目录
|
|
9
|
+
* @param{ String } 需要复制的目录
|
|
10
|
+
* @param{ String } 复制到指定的目录
|
|
11
|
+
*/
|
|
12
|
+
var copy = function (src, dst) {
|
|
13
|
+
// 读取目录中的所有文件/目录
|
|
14
|
+
fs.readdir(src, function (err, paths) {
|
|
15
|
+
if (err) {
|
|
16
|
+
throw err;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
paths.forEach(function (path) {
|
|
20
|
+
var _src = src + "/" + path,
|
|
21
|
+
_dst = dst + "/" + path,
|
|
22
|
+
readable,
|
|
23
|
+
writable;
|
|
24
|
+
|
|
25
|
+
fs.stat(_src, function (err, st) {
|
|
26
|
+
if (err) {
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
// 判断是否为文件
|
|
30
|
+
if (st.isFile()) {
|
|
31
|
+
// 创建读取流
|
|
32
|
+
readable = fs.createReadStream(_src);
|
|
33
|
+
// 创建写入流
|
|
34
|
+
writable = fs.createWriteStream(_dst);
|
|
35
|
+
// 通过管道来传输流
|
|
36
|
+
readable.pipe(writable);
|
|
37
|
+
}
|
|
38
|
+
// 如果是目录则递归调用自身
|
|
39
|
+
else if (st.isDirectory()) {
|
|
40
|
+
exists(_src, _dst, copy);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
// 在复制目录前需要判断该目录是否存在,不存在需要先创建目录
|
|
47
|
+
var exists = function (src, dst, callback) {
|
|
48
|
+
fs.exists(dst, function (exists) {
|
|
49
|
+
// 已存在
|
|
50
|
+
if (exists) {
|
|
51
|
+
// callback(src, dst);
|
|
52
|
+
} else {
|
|
53
|
+
fs.mkdir(dst, function () {
|
|
54
|
+
callback(src, dst);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
6
60
|
(function () {
|
|
7
61
|
console.log("ipanel_rnapp_ajb_base local_dev=====");
|
|
8
62
|
|
|
@@ -15,6 +69,23 @@ const path = require("path");
|
|
|
15
69
|
// 重写.local_dev/polyfill.js
|
|
16
70
|
fs.writeFileSync(
|
|
17
71
|
path.resolve(__dirname, "../app/.local_dev/polyfill.js"),
|
|
18
|
-
fs.readFileSync(path.resolve(__dirname, "
|
|
72
|
+
fs.readFileSync(path.resolve(__dirname, "../tmpl/polyfill.js")).toString()
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
fs.copyFile(
|
|
76
|
+
path.resolve(__dirname, "../tmpl/index.android.js"),
|
|
77
|
+
"../../index.android.js",
|
|
78
|
+
(err) => {
|
|
79
|
+
if (err) throw err;
|
|
80
|
+
console.log("index.android.js文件拷贝成功!");
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
fs.copyFile(
|
|
84
|
+
path.resolve(__dirname, "../tmpl/index.ios.js"),
|
|
85
|
+
"../../index.ios.js",
|
|
86
|
+
(err) => {
|
|
87
|
+
if (err) throw err;
|
|
88
|
+
console.log("index.ios.js文件拷贝成功!");
|
|
89
|
+
}
|
|
19
90
|
);
|
|
20
91
|
})();
|
package/package.json
CHANGED
|
File without changes
|