ipanel-rnapp-ajb-base 1.0.3 → 1.0.4
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/app/.local_dev/polyfill.js +1 -46
- package/app/App.js +117 -120
- package/app/base.js +41 -2
- package/bin/local-dev.js +11 -2
- package/bin/polyfill.js.tmpl +24 -0
- package/package.json +1 -1
|
@@ -3,51 +3,6 @@ import {AppRegistry, NativeModules} from 'react-native';
|
|
|
3
3
|
// isMultiBundle:是否为分包加载方式(不是的话就是不分包方式,用于本地调试)
|
|
4
4
|
const isLocalDev = !NativeModules.RNToNativeEmitter?.isMultiBundle;
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* 动态加载业务包
|
|
8
|
-
* @param {object} data 要加载的业务包列表对象,格式如: { packages: [...] }
|
|
9
|
-
* @param {*} packageLoadCallback 每次一个业务包处理(加载成功或失败)完成时触发该回调函数
|
|
10
|
-
* @returns 全部业务包处理完成的promise,全部加载完成时promise返回true,否则返回加载失败的模块数组
|
|
11
|
-
*/
|
|
12
|
-
function loadPackages(data, packageLoadCallback) {
|
|
13
|
-
return new Promise((resolve, reject) => {
|
|
14
|
-
if (!isLocalDev) {
|
|
15
|
-
const load = pack => {
|
|
16
|
-
return new Promise(_reslove => {
|
|
17
|
-
NativeModules.RNToNativeEmitter.loadPackage(
|
|
18
|
-
{
|
|
19
|
-
package: pack,
|
|
20
|
-
},
|
|
21
|
-
function (error, packageName) {
|
|
22
|
-
console.log(error, packageName);
|
|
23
|
-
|
|
24
|
-
typeof packageLoadCallback === 'function' &&
|
|
25
|
-
packageLoadCallback(error, packageName);
|
|
26
|
-
|
|
27
|
-
_reslove({
|
|
28
|
-
error,
|
|
29
|
-
packageName,
|
|
30
|
-
});
|
|
31
|
-
},
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
Promise.all(data.packages.map(pack => load(pack))).then(datas => {
|
|
37
|
-
const errors = datas.filter(item => !!item.error);
|
|
38
|
-
if (errors.length > 0) {
|
|
39
|
-
reject(errors);
|
|
40
|
-
} else {
|
|
41
|
-
resolve(true);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
} else {
|
|
45
|
-
// 本地开发环境直接resolve
|
|
46
|
-
resolve(true);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
6
|
// 根据业务包的组件名异步获取业务包组件,返回一个promise
|
|
52
7
|
async function getRemoteComponentByName(componentName) {
|
|
53
8
|
if (!isLocalDev) {
|
|
@@ -80,4 +35,4 @@ async function getRemoteComponentByName(componentName) {
|
|
|
80
35
|
}
|
|
81
36
|
}
|
|
82
37
|
|
|
83
|
-
export {
|
|
38
|
+
export {getRemoteComponentByName};
|
package/app/App.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {useState, useEffect, useMemo} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
4
|
LogBox,
|
|
@@ -11,57 +11,57 @@ import {
|
|
|
11
11
|
AppState,
|
|
12
12
|
NativeEventEmitter,
|
|
13
13
|
DeviceEventEmitter,
|
|
14
|
-
} from
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import DeviceInfo from
|
|
19
|
-
import {
|
|
20
|
-
import VersionUpdateConfirm from
|
|
14
|
+
} from 'react-native';
|
|
15
|
+
import {NavigationContainer} from '@react-navigation/native';
|
|
16
|
+
import {createStackNavigator} from '@react-navigation/stack';
|
|
17
|
+
import {SheetProvider} from 'react-native-actions-sheet';
|
|
18
|
+
import DeviceInfo from 'react-native-device-info';
|
|
19
|
+
import {SafeAreaProvider, SafeAreaView} from 'react-native-safe-area-context';
|
|
20
|
+
import VersionUpdateConfirm from './components/VersionUpdateConfirm';
|
|
21
21
|
// import NetInfo from '@react-native-community/netinfo';
|
|
22
22
|
|
|
23
23
|
// 重要:base.js需放在一切自定义代码之前初始化
|
|
24
|
-
import
|
|
24
|
+
import './base.js';
|
|
25
25
|
// 版本升级相关代码
|
|
26
|
-
import
|
|
26
|
+
import './utils/bundleUpdater';
|
|
27
27
|
// 对接声必可屏幕
|
|
28
|
-
import
|
|
28
|
+
import './utils/SBK_plugin';
|
|
29
29
|
|
|
30
30
|
// 注册actionSheet组件
|
|
31
|
-
import
|
|
31
|
+
import './components/sheets.js';
|
|
32
32
|
|
|
33
|
-
import Loading from
|
|
34
|
-
import Toast from
|
|
35
|
-
import Dialog from
|
|
36
|
-
import Notify from
|
|
37
|
-
import storage from
|
|
33
|
+
import Loading from './components/common/Loading';
|
|
34
|
+
import Toast from './components/common/Toast';
|
|
35
|
+
import Dialog from './components/common/Dialog';
|
|
36
|
+
import Notify from './components/common/Notify';
|
|
37
|
+
import storage from './storage';
|
|
38
38
|
|
|
39
|
-
import {
|
|
40
|
-
import checkLogin from
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
39
|
+
import {navigationRef} from './utils/RootNavigation';
|
|
40
|
+
import checkLogin from './hooks/checkLogin';
|
|
41
|
+
import {getModuleVersionInfo} from './api/';
|
|
42
|
+
import {appReport} from './utils/common';
|
|
43
43
|
|
|
44
44
|
// 基础导航页、登录页
|
|
45
|
-
import BaseScreen from
|
|
46
|
-
import LoginScreen from
|
|
47
|
-
import NewLoginScreen from
|
|
48
|
-
import ResePasswordScreen from
|
|
49
|
-
import SbkScreen from
|
|
50
|
-
|
|
51
|
-
import eventBus, {
|
|
52
|
-
|
|
53
|
-
import useDynamicPackages from
|
|
54
|
-
import useAddress from
|
|
55
|
-
import useAddress2 from
|
|
56
|
-
import useNavigationFocus from
|
|
57
|
-
import useLatest from
|
|
58
|
-
import useDebounceFn from
|
|
59
|
-
import useUser from
|
|
60
|
-
import useKeyboard from
|
|
45
|
+
import BaseScreen from './screens/BaseScreen';
|
|
46
|
+
import LoginScreen from './screens/LoginScreen';
|
|
47
|
+
import NewLoginScreen from './screens/LoginScreen/indexNew';
|
|
48
|
+
import ResePasswordScreen from './screens/ResePassword';
|
|
49
|
+
import SbkScreen from './screens/SbkScreen';
|
|
50
|
+
|
|
51
|
+
import eventBus, {EVENTS} from './eventBus';
|
|
52
|
+
|
|
53
|
+
import useDynamicPackages from './hooks/useDynamicPackages';
|
|
54
|
+
import useAddress from './hooks/useAddress';
|
|
55
|
+
import useAddress2 from './hooks/useAddress2';
|
|
56
|
+
import useNavigationFocus from './hooks/useNavigationFocus';
|
|
57
|
+
import useLatest from './hooks/useLatest';
|
|
58
|
+
import useDebounceFn from './hooks/useDebounceFn';
|
|
59
|
+
import useUser from './hooks/useUser';
|
|
60
|
+
import useKeyboard from './hooks/useKeyboard';
|
|
61
61
|
|
|
62
62
|
LogBox.ignoreLogs([
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
'ViewPropTypes will be removed',
|
|
64
|
+
'ColorPropType will be removed',
|
|
65
65
|
]);
|
|
66
66
|
|
|
67
67
|
// base hooks, 内部可能依赖基础的base函数,因此放在基础base初始化之后
|
|
@@ -76,25 +76,25 @@ global.base.hooks = {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
// 公共页面
|
|
79
|
-
import WebviewScreen from
|
|
80
|
-
import ScanQRCodeScreen from
|
|
81
|
-
import OperatorSelectScreen from
|
|
82
|
-
import EditInvoiceTitleScreen from
|
|
83
|
-
import InvoiceTitleListScreen from
|
|
84
|
-
import TvAlbumScreen from
|
|
85
|
-
import DeviceFeedbackScreen from
|
|
86
|
-
import DeviceAnswerDetailScreen from
|
|
79
|
+
import WebviewScreen from './screens/WebviewScreen';
|
|
80
|
+
import ScanQRCodeScreen from './screens/CommonScreens/ScanQRCodeScreen';
|
|
81
|
+
import OperatorSelectScreen from './screens/CommonScreens/OperatorSelectScreen';
|
|
82
|
+
import EditInvoiceTitleScreen from './screens/CommonScreens/EditInvoiceTitleScreen';
|
|
83
|
+
import InvoiceTitleListScreen from './screens/CommonScreens/InvoiceTitleListScreen';
|
|
84
|
+
import TvAlbumScreen from './screens/CommonScreens/TvAlbumScreen';
|
|
85
|
+
import DeviceFeedbackScreen from './screens/CommonScreens/DeviceFeedbackScreen';
|
|
86
|
+
import DeviceAnswerDetailScreen from './screens/CommonScreens/DeviceAnswerDetailScreen';
|
|
87
87
|
|
|
88
88
|
// Boss绑定页面
|
|
89
|
-
import BindBossScreen from
|
|
89
|
+
import BindBossScreen from './screens/CommonScreens/BossScreen';
|
|
90
90
|
|
|
91
91
|
const Stack = createStackNavigator();
|
|
92
92
|
|
|
93
|
-
const envVersion = NativeModules?.RNToNativeEmitter?.serverCluster ||
|
|
93
|
+
const envVersion = NativeModules?.RNToNativeEmitter?.serverCluster || 'alpha';
|
|
94
94
|
// const envVersion = 'release';
|
|
95
95
|
|
|
96
96
|
let eventEmitter;
|
|
97
|
-
if (Platform.OS ===
|
|
97
|
+
if (Platform.OS === 'android') {
|
|
98
98
|
// ----yusm:安卓使用DeviceEventEmitter
|
|
99
99
|
eventEmitter = DeviceEventEmitter;
|
|
100
100
|
} else {
|
|
@@ -105,23 +105,23 @@ const CommonScreens = {
|
|
|
105
105
|
Home: {
|
|
106
106
|
component: BaseScreen,
|
|
107
107
|
screenOptions: {
|
|
108
|
-
title:
|
|
108
|
+
title: '首页',
|
|
109
109
|
headerShown: false,
|
|
110
110
|
includeBottom: true,
|
|
111
111
|
},
|
|
112
112
|
},
|
|
113
113
|
Login: {
|
|
114
114
|
component:
|
|
115
|
-
DeviceInfo.getBrand() ===
|
|
115
|
+
DeviceInfo.getBrand() === 'Allwinner' ? LoginScreen : NewLoginScreen,
|
|
116
116
|
screenOptions: {
|
|
117
|
-
title:
|
|
117
|
+
title: '登录',
|
|
118
118
|
headerShown: false,
|
|
119
119
|
},
|
|
120
120
|
},
|
|
121
121
|
ResePasswordScreen: {
|
|
122
122
|
component: ResePasswordScreen,
|
|
123
123
|
screenOptions: {
|
|
124
|
-
title:
|
|
124
|
+
title: '重置密码',
|
|
125
125
|
headerShown: false,
|
|
126
126
|
},
|
|
127
127
|
},
|
|
@@ -134,62 +134,62 @@ const CommonScreens = {
|
|
|
134
134
|
OperatorSelectScreen: {
|
|
135
135
|
component: OperatorSelectScreen,
|
|
136
136
|
screenOptions: {
|
|
137
|
-
title:
|
|
137
|
+
title: '选择运营商',
|
|
138
138
|
headerShown: false,
|
|
139
139
|
},
|
|
140
140
|
},
|
|
141
141
|
InvoiceTitleListScreen: {
|
|
142
142
|
component: InvoiceTitleListScreen,
|
|
143
143
|
screenOptions: {
|
|
144
|
-
title:
|
|
144
|
+
title: '发票抬头',
|
|
145
145
|
headerShown: false,
|
|
146
146
|
},
|
|
147
147
|
},
|
|
148
148
|
EditInvoiceTitleScreen: {
|
|
149
149
|
component: EditInvoiceTitleScreen,
|
|
150
150
|
screenOptions: {
|
|
151
|
-
title:
|
|
151
|
+
title: '编辑发票抬头',
|
|
152
152
|
headerShown: false,
|
|
153
153
|
},
|
|
154
154
|
},
|
|
155
155
|
WebviewScreen: {
|
|
156
156
|
component: WebviewScreen,
|
|
157
157
|
screenOptions: {
|
|
158
|
-
title:
|
|
158
|
+
title: '',
|
|
159
159
|
headerShown: false,
|
|
160
160
|
},
|
|
161
161
|
},
|
|
162
162
|
TvAlbumScreen: {
|
|
163
163
|
component: TvAlbumScreen,
|
|
164
164
|
screenOptions: {
|
|
165
|
-
title:
|
|
165
|
+
title: '电视相册',
|
|
166
166
|
},
|
|
167
167
|
},
|
|
168
168
|
DeviceFeedbackScreen: {
|
|
169
169
|
component: DeviceFeedbackScreen,
|
|
170
170
|
screenOptions: {
|
|
171
|
-
title:
|
|
171
|
+
title: '帮助与反馈',
|
|
172
172
|
headerShown: false,
|
|
173
173
|
},
|
|
174
174
|
},
|
|
175
175
|
DeviceAnswerDetailScreen: {
|
|
176
176
|
component: DeviceAnswerDetailScreen,
|
|
177
177
|
screenOptions: {
|
|
178
|
-
title:
|
|
178
|
+
title: '解答',
|
|
179
179
|
headerShown: false,
|
|
180
180
|
},
|
|
181
181
|
},
|
|
182
182
|
SbkScreen: {
|
|
183
183
|
component: SbkScreen,
|
|
184
184
|
screenOptions: {
|
|
185
|
-
title:
|
|
185
|
+
title: '爱家宝',
|
|
186
186
|
headerShown: false,
|
|
187
187
|
},
|
|
188
188
|
},
|
|
189
189
|
BindBossScreen: {
|
|
190
190
|
component: BindBossScreen,
|
|
191
191
|
screenOptions: {
|
|
192
|
-
title:
|
|
192
|
+
title: '绑定boss账号',
|
|
193
193
|
headerShown: false,
|
|
194
194
|
},
|
|
195
195
|
},
|
|
@@ -197,7 +197,7 @@ const CommonScreens = {
|
|
|
197
197
|
|
|
198
198
|
// screen分组
|
|
199
199
|
function StackScreenGroup(screens) {
|
|
200
|
-
return Object.entries(screens).map(([name, {
|
|
200
|
+
return Object.entries(screens).map(([name, {component, screenOptions}]) => (
|
|
201
201
|
<Stack.Screen
|
|
202
202
|
name={name}
|
|
203
203
|
component={component}
|
|
@@ -210,24 +210,24 @@ function StackScreenGroup(screens) {
|
|
|
210
210
|
// 兜底的底部导航模块
|
|
211
211
|
const initialNavigationPackages = [
|
|
212
212
|
{
|
|
213
|
-
bundleName:
|
|
213
|
+
bundleName: 'index.ios.bundle',
|
|
214
214
|
isMain: 1,
|
|
215
|
-
md5:
|
|
216
|
-
moduleName:
|
|
217
|
-
modulePublishDesc:
|
|
218
|
-
upgradeMode:
|
|
219
|
-
url:
|
|
220
|
-
version:
|
|
215
|
+
md5: '7284896d821f9e206efc979590561e18',
|
|
216
|
+
moduleName: 'tvShare',
|
|
217
|
+
modulePublishDesc: '电视分享ios',
|
|
218
|
+
upgradeMode: 'force',
|
|
219
|
+
url: 'https://dev.ipanelcloud2.ipanel.cn:50443/jshomeapp/appFiles/packFiles/ipanel/ios/tvShare/v1.0.2/20230601120633/ipanel_ios_tvShare_v1.0.2_20230601120633.zip',
|
|
220
|
+
version: 'v1.0.2',
|
|
221
221
|
},
|
|
222
222
|
{
|
|
223
|
-
bundleName:
|
|
223
|
+
bundleName: 'index.ios.bundle',
|
|
224
224
|
isMain: 1,
|
|
225
|
-
md5:
|
|
226
|
-
moduleName:
|
|
227
|
-
modulePublishDesc:
|
|
228
|
-
upgradeMode:
|
|
229
|
-
url:
|
|
230
|
-
version:
|
|
225
|
+
md5: '0fd7a6212a7b70baa54ce2a9cc99698b',
|
|
226
|
+
moduleName: 'smartHome',
|
|
227
|
+
modulePublishDesc: '智能家居ios',
|
|
228
|
+
upgradeMode: 'force',
|
|
229
|
+
url: 'https://dev.ipanelcloud2.ipanel.cn:50443/jshomeapp/appFiles/packFiles/ipanel/ios/smartHome/v1.0.2/20230601120752/ipanel_ios_smartHome_v1.0.2_20230601120752.zip',
|
|
230
|
+
version: 'v1.0.2',
|
|
231
231
|
},
|
|
232
232
|
// {
|
|
233
233
|
// bundleName: 'index.ios.bundle',
|
|
@@ -255,7 +255,7 @@ global.base.initialNavigationPackages = initialNavigationPackages;
|
|
|
255
255
|
// updateNavigationPackagesFromStorage(1);
|
|
256
256
|
|
|
257
257
|
const App = () => {
|
|
258
|
-
const {
|
|
258
|
+
const {DynamicStackScreens} = useDynamicPackages();
|
|
259
259
|
// 当前页面是否需要包括底部安全区
|
|
260
260
|
const [includeBottom, setIncludeBottom] = useState(false);
|
|
261
261
|
const [versionUpdateConfirmVisible, setVersionUpdateConfirmVisible] =
|
|
@@ -276,16 +276,16 @@ const App = () => {
|
|
|
276
276
|
|
|
277
277
|
// mounted
|
|
278
278
|
useEffect(() => {
|
|
279
|
-
StatusBar.setBackgroundColor(
|
|
280
|
-
StatusBar.setBarStyle(
|
|
281
|
-
storage.get(
|
|
282
|
-
global.base.accountType = res ||
|
|
279
|
+
StatusBar.setBackgroundColor('transparent');
|
|
280
|
+
StatusBar.setBarStyle('dark-content');
|
|
281
|
+
storage.get('accountType').then(res => {
|
|
282
|
+
global.base.accountType = res || 'ajb';
|
|
283
283
|
});
|
|
284
284
|
|
|
285
285
|
const rnToNative = NativeModules.RNToNativeEmitter;
|
|
286
286
|
// 应用通知app可正常显示,页面正常运行了,在componentDidMount 中加
|
|
287
287
|
rnToNative?.notifyApplicationReady({
|
|
288
|
-
moduleName:
|
|
288
|
+
moduleName: 'base',
|
|
289
289
|
}); // 不用传参数
|
|
290
290
|
|
|
291
291
|
// 首次进入app登录鉴权
|
|
@@ -294,35 +294,35 @@ const App = () => {
|
|
|
294
294
|
// 获取最新版本并通知原生平台,由平台判断后弹出升级确认提示
|
|
295
295
|
checkBaseVersion();
|
|
296
296
|
|
|
297
|
-
AppState.addEventListener(
|
|
298
|
-
console.log(
|
|
299
|
-
if (nextAppState ===
|
|
300
|
-
appReport(
|
|
297
|
+
AppState.addEventListener('change', async nextAppState => {
|
|
298
|
+
console.log('nextAppState', nextAppState);
|
|
299
|
+
if (nextAppState === 'active') {
|
|
300
|
+
appReport('APP_STARTUP');
|
|
301
301
|
}
|
|
302
302
|
});
|
|
303
303
|
|
|
304
304
|
const keyboardDidShowListener = Keyboard.addListener(
|
|
305
|
-
|
|
305
|
+
'keyboardDidShow',
|
|
306
306
|
() => {
|
|
307
307
|
setIsKeyboardVisible(true);
|
|
308
|
-
}
|
|
308
|
+
},
|
|
309
309
|
);
|
|
310
310
|
|
|
311
311
|
const keyboardDidHideListener = Keyboard.addListener(
|
|
312
|
-
|
|
312
|
+
'keyboardDidHide',
|
|
313
313
|
() => {
|
|
314
314
|
setIsKeyboardVisible(false);
|
|
315
|
-
}
|
|
315
|
+
},
|
|
316
316
|
);
|
|
317
317
|
|
|
318
318
|
const cellularDataStateListener = eventEmitter.addListener(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
console.log(JSON.stringify(data),
|
|
319
|
+
'CellularDataState',
|
|
320
|
+
data => {
|
|
321
|
+
console.log(JSON.stringify(data), 'CellularDataState');
|
|
322
322
|
if (data?.state && data?.state !== 0) {
|
|
323
323
|
checkBaseVersion();
|
|
324
324
|
}
|
|
325
|
-
}
|
|
325
|
+
},
|
|
326
326
|
);
|
|
327
327
|
|
|
328
328
|
return () => {
|
|
@@ -341,23 +341,23 @@ const App = () => {
|
|
|
341
341
|
|
|
342
342
|
const checkBaseVersion = async () => {
|
|
343
343
|
// 当前版本
|
|
344
|
-
const baseVersionInfo = await global.base.getBundleInfo(
|
|
344
|
+
const baseVersionInfo = await global.base.getBundleInfo('base');
|
|
345
345
|
if (!baseVersionInfo) {
|
|
346
346
|
return false;
|
|
347
347
|
}
|
|
348
348
|
try {
|
|
349
349
|
const res = await getModuleVersionInfo({
|
|
350
350
|
platform: Platform.OS,
|
|
351
|
-
operatorId:
|
|
352
|
-
moduleName:
|
|
351
|
+
operatorId: 'ipanel',
|
|
352
|
+
moduleName: 'base',
|
|
353
353
|
});
|
|
354
354
|
if (res.code === 0) {
|
|
355
355
|
const versionInfo = res.data.packages[0];
|
|
356
356
|
const newVersion = Number(
|
|
357
|
-
versionInfo.version.slice(1).replace(/\./g,
|
|
357
|
+
versionInfo.version.slice(1).replace(/\./g, ''),
|
|
358
358
|
);
|
|
359
359
|
const currentVersion = Number(
|
|
360
|
-
baseVersionInfo.version.slice(1).replace(/\./g,
|
|
360
|
+
baseVersionInfo.version.slice(1).replace(/\./g, ''),
|
|
361
361
|
);
|
|
362
362
|
if (newVersion > currentVersion) {
|
|
363
363
|
setVersionUpdateConfirmVisible(true);
|
|
@@ -371,21 +371,21 @@ const App = () => {
|
|
|
371
371
|
global.base.checkBaseVersion = checkBaseVersion;
|
|
372
372
|
|
|
373
373
|
// 升级测试
|
|
374
|
-
const onUpdate =
|
|
374
|
+
const onUpdate = versionInfo => {
|
|
375
375
|
const rnToNative = NativeModules.RNToNativeEmitter;
|
|
376
376
|
rnToNative?.selectedInfo({
|
|
377
377
|
packages: [versionInfo],
|
|
378
|
-
operatorId:
|
|
378
|
+
operatorId: 'ipanel',
|
|
379
379
|
});
|
|
380
380
|
};
|
|
381
381
|
|
|
382
|
-
const handleStateChange = ({
|
|
382
|
+
const handleStateChange = ({routes}) => {
|
|
383
383
|
const routeName = routes[routes.length - 1].name;
|
|
384
384
|
setIncludeBottom(
|
|
385
|
-
allStackScreens[routeName]?.screenOptions?.includeBottom || false
|
|
385
|
+
allStackScreens[routeName]?.screenOptions?.includeBottom || false,
|
|
386
386
|
);
|
|
387
387
|
/* 加载之后每次navigate都鉴权一把登录状态(重置密码不需要检测) */
|
|
388
|
-
if (routeName !==
|
|
388
|
+
if (routeName !== 'ResePasswordScreen') {
|
|
389
389
|
checkLogin();
|
|
390
390
|
}
|
|
391
391
|
|
|
@@ -399,14 +399,12 @@ const App = () => {
|
|
|
399
399
|
<SheetProvider>
|
|
400
400
|
<NavigationContainer
|
|
401
401
|
ref={navigationRef}
|
|
402
|
-
onStateChange={handleStateChange}
|
|
403
|
-
>
|
|
402
|
+
onStateChange={handleStateChange}>
|
|
404
403
|
<Stack.Navigator
|
|
405
|
-
initialRouteName={
|
|
404
|
+
initialRouteName={'Login'}
|
|
406
405
|
screenOptions={{
|
|
407
406
|
headerStyle: {},
|
|
408
|
-
}}
|
|
409
|
-
>
|
|
407
|
+
}}>
|
|
410
408
|
{/* 首页 */}
|
|
411
409
|
{/*<Stack.Screen*/}
|
|
412
410
|
{/* name="Home"*/}
|
|
@@ -435,10 +433,10 @@ const App = () => {
|
|
|
435
433
|
</NavigationContainer>
|
|
436
434
|
</SheetProvider>
|
|
437
435
|
|
|
438
|
-
<Loading onRef={
|
|
439
|
-
<Toast onRef={
|
|
440
|
-
<Notify onRef={
|
|
441
|
-
<Dialog onRef={
|
|
436
|
+
<Loading onRef={ref => (global.loading = ref)} />
|
|
437
|
+
<Toast onRef={ref => (global.toast = ref)} />
|
|
438
|
+
<Notify onRef={ref => (global.notify = ref)} />
|
|
439
|
+
<Dialog onRef={ref => (global.dialog = ref)} />
|
|
442
440
|
{versionUpdateConfirmVisible && (
|
|
443
441
|
<VersionUpdateConfirm
|
|
444
442
|
onVisibleChange={setVersionUpdateConfirmVisible}
|
|
@@ -446,7 +444,7 @@ const App = () => {
|
|
|
446
444
|
onUpdate={onUpdate}
|
|
447
445
|
/>
|
|
448
446
|
)}
|
|
449
|
-
{isKeyboardVisible && Platform.OS ===
|
|
447
|
+
{isKeyboardVisible && Platform.OS === 'ios' && (
|
|
450
448
|
<TouchableWithoutFeedback onPress={handleTouchOutside}>
|
|
451
449
|
<View style={styles.touchableContainer} />
|
|
452
450
|
</TouchableWithoutFeedback>
|
|
@@ -455,12 +453,11 @@ const App = () => {
|
|
|
455
453
|
);
|
|
456
454
|
};
|
|
457
455
|
|
|
458
|
-
return Platform.OS ===
|
|
456
|
+
return Platform.OS === 'ios' ? (
|
|
459
457
|
<SafeAreaProvider>
|
|
460
458
|
<SafeAreaView
|
|
461
|
-
style={{
|
|
462
|
-
edges={includeBottom ? [
|
|
463
|
-
>
|
|
459
|
+
style={{flex: 1}}
|
|
460
|
+
edges={includeBottom ? ['right', 'left'] : ['right', 'bottom', 'left']}>
|
|
464
461
|
{renderContent()}
|
|
465
462
|
</SafeAreaView>
|
|
466
463
|
</SafeAreaProvider>
|
package/app/base.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {NativeModules, Platform} from 'react-native';
|
|
2
2
|
// 引入兼容本地运行开发测试的额外处理
|
|
3
|
-
import {
|
|
3
|
+
import {getRemoteComponentByName} from './.local_dev/polyfill';
|
|
4
4
|
|
|
5
5
|
import eventBus, {EVENTS} from './eventBus';
|
|
6
6
|
import storage from './storage';
|
|
@@ -102,13 +102,52 @@ global.base.shopMessageManager = {
|
|
|
102
102
|
wsRef: null,
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
+
// isMultiBundle:是否为分包加载方式(不是的话就是不分包方式,用于本地调试)
|
|
106
|
+
const isLocalDev = !NativeModules.RNToNativeEmitter?.isMultiBundle;
|
|
105
107
|
/**
|
|
106
108
|
* 动态加载业务包
|
|
107
109
|
* @param {object} data 要加载的业务包列表对象,格式如: { packages: [...] }
|
|
108
110
|
* @param {*} packageLoadCallback 每次一个业务包处理(加载成功或失败)完成时触发该回调函数
|
|
109
111
|
* @returns 全部业务包处理完成的promise,全部加载完成时promise返回true,否则返回加载失败的模块数组
|
|
110
112
|
*/
|
|
111
|
-
global.base.loadPackages = loadPackages
|
|
113
|
+
global.base.loadPackages = function loadPackages(data, packageLoadCallback) {
|
|
114
|
+
return new Promise((resolve, reject) => {
|
|
115
|
+
if (!isLocalDev) {
|
|
116
|
+
const load = pack => {
|
|
117
|
+
return new Promise(_reslove => {
|
|
118
|
+
NativeModules.RNToNativeEmitter.loadPackage(
|
|
119
|
+
{
|
|
120
|
+
package: pack,
|
|
121
|
+
},
|
|
122
|
+
function (error, packageName) {
|
|
123
|
+
console.log(error, packageName);
|
|
124
|
+
|
|
125
|
+
typeof packageLoadCallback === 'function' &&
|
|
126
|
+
packageLoadCallback(error, packageName);
|
|
127
|
+
|
|
128
|
+
_reslove({
|
|
129
|
+
error,
|
|
130
|
+
packageName,
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
Promise.all(data.packages.map(pack => load(pack))).then(datas => {
|
|
138
|
+
const errors = datas.filter(item => !!item.error);
|
|
139
|
+
if (errors.length > 0) {
|
|
140
|
+
reject(errors);
|
|
141
|
+
} else {
|
|
142
|
+
resolve(true);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
// 本地开发环境直接resolve
|
|
147
|
+
resolve(true);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
};
|
|
112
151
|
|
|
113
152
|
// 根据业务包的组件名异步获取业务包组件,返回一个promise
|
|
114
153
|
global.base.getRemoteComponentByName = getRemoteComponentByName;
|
package/bin/local-dev.js
CHANGED
|
@@ -6,6 +6,15 @@ const path = require("path");
|
|
|
6
6
|
(function () {
|
|
7
7
|
console.log("ipanel_rnapp_ajb_base local_dev=====");
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
fs.writeFileSync(
|
|
9
|
+
// 重写.local_dev/env.js
|
|
10
|
+
fs.writeFileSync(
|
|
11
|
+
path.resolve(__dirname, "../app/.local_dev/env.js"),
|
|
12
|
+
`export default '__LOCAL_DEV__';`
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
// 重写.local_dev/polyfill.js
|
|
16
|
+
fs.writeFileSync(
|
|
17
|
+
path.resolve(__dirname, "../app/.local_dev/polyfill.js"),
|
|
18
|
+
fs.readFileSync(path.resolve(__dirname, "./polyfill.js.tmpl")).toString()
|
|
19
|
+
);
|
|
11
20
|
})();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AppRegistry, NativeModules } from "react-native";
|
|
2
|
+
|
|
3
|
+
// isMultiBundle:是否为分包加载方式(不是的话就是不分包方式,用于本地调试)
|
|
4
|
+
const isLocalDev = !NativeModules.RNToNativeEmitter?.isMultiBundle;
|
|
5
|
+
|
|
6
|
+
// 根据业务包的组件名异步获取业务包组件,返回一个promise
|
|
7
|
+
async function getRemoteComponentByName(componentName) {
|
|
8
|
+
if (!isLocalDev) {
|
|
9
|
+
return AppRegistry.getRunnable(componentName).componentProvider();
|
|
10
|
+
} else {
|
|
11
|
+
try {
|
|
12
|
+
// 用于本地开发测试,每加一个业务包这里都需要加一下
|
|
13
|
+
switch (componentName) {
|
|
14
|
+
case "app":
|
|
15
|
+
return (await import("../../app/App.js")).default;
|
|
16
|
+
}
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.log(componentName, e);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { getRemoteComponentByName };
|