ipanel-rnapp-ajb-base 1.0.23 → 1.0.25
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/App.js +123 -136
- package/app/hooks/checkLogin.js +2 -1
- package/app/screens/BaseScreen.js +9 -4
- package/app/screens/CommonScreens/PersonalScreen/index.js +1 -0
- package/app/screens/LoginScreen/indexNew.js +4 -3
- package/app/utils/common.js +9 -4
- package/app/utils/http.js +2 -1
- package/package.json +3 -6
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,64 +11,64 @@ 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
|
-
import {
|
|
22
|
+
import {Provider} from '@ant-design/react-native';
|
|
23
23
|
|
|
24
24
|
// 重要:base.js需放在一切自定义代码之前初始化
|
|
25
|
-
import
|
|
25
|
+
import './base.js';
|
|
26
26
|
// 版本升级相关代码
|
|
27
|
-
import
|
|
27
|
+
import './utils/bundleUpdater';
|
|
28
28
|
// 对接声必可屏幕
|
|
29
|
-
import
|
|
29
|
+
import './utils/SBK_plugin';
|
|
30
30
|
|
|
31
31
|
// 注册actionSheet组件
|
|
32
|
-
import
|
|
32
|
+
import './components/sheets.js';
|
|
33
33
|
|
|
34
|
-
import Loading from
|
|
35
|
-
import Toast from
|
|
36
|
-
import Dialog from
|
|
37
|
-
import Notify from
|
|
38
|
-
import SheetManage from
|
|
39
|
-
import storage from
|
|
34
|
+
import Loading from './components/common/Loading';
|
|
35
|
+
import Toast from './components/common/Toast';
|
|
36
|
+
import Dialog from './components/common/Dialog';
|
|
37
|
+
import Notify from './components/common/Notify';
|
|
38
|
+
import SheetManage from './components/common/SheetManage';
|
|
39
|
+
import storage from './storage';
|
|
40
40
|
|
|
41
|
-
import {
|
|
42
|
-
import checkLogin from
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
41
|
+
import {navigationRef} from './utils/RootNavigation';
|
|
42
|
+
import checkLogin from './hooks/checkLogin';
|
|
43
|
+
import {getModuleVersionInfo} from './api/';
|
|
44
|
+
import {appReport} from './utils/common';
|
|
45
45
|
|
|
46
46
|
// 基础导航页、登录页
|
|
47
|
-
import BaseScreen from
|
|
48
|
-
import LoginScreen from
|
|
49
|
-
import NewLoginScreen from
|
|
50
|
-
import ResePasswordScreen from
|
|
51
|
-
import SbkScreen from
|
|
47
|
+
import BaseScreen from './screens/BaseScreen';
|
|
48
|
+
import LoginScreen from './screens/LoginScreen';
|
|
49
|
+
import NewLoginScreen from './screens/LoginScreen/indexNew';
|
|
50
|
+
import ResePasswordScreen from './screens/ResePassword';
|
|
51
|
+
import SbkScreen from './screens/SbkScreen';
|
|
52
52
|
|
|
53
|
-
import eventBus, {
|
|
53
|
+
import eventBus, {EVENTS} from './eventBus';
|
|
54
54
|
|
|
55
|
-
import useDynamicPackages from
|
|
56
|
-
import useAddress from
|
|
57
|
-
import useAddress2 from
|
|
58
|
-
import useNavigationFocus from
|
|
59
|
-
import useLatest from
|
|
60
|
-
import useDebounceFn from
|
|
61
|
-
import useUser from
|
|
62
|
-
import useKeyboard from
|
|
55
|
+
import useDynamicPackages from './hooks/useDynamicPackages';
|
|
56
|
+
import useAddress from './hooks/useAddress';
|
|
57
|
+
import useAddress2 from './hooks/useAddress2';
|
|
58
|
+
import useNavigationFocus from './hooks/useNavigationFocus';
|
|
59
|
+
import useLatest from './hooks/useLatest';
|
|
60
|
+
import useDebounceFn from './hooks/useDebounceFn';
|
|
61
|
+
import useUser from './hooks/useUser';
|
|
62
|
+
import useKeyboard from './hooks/useKeyboard';
|
|
63
63
|
|
|
64
|
-
import RegisteCountScreen from
|
|
64
|
+
import RegisteCountScreen from './screens/RegisteCountScreen';
|
|
65
65
|
|
|
66
66
|
LogBox.ignoreLogs([
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
'ViewPropTypes will be removed',
|
|
68
|
+
'ColorPropType will be removed',
|
|
69
69
|
]);
|
|
70
70
|
|
|
71
|
-
if (DeviceInfo.getBrand() ===
|
|
71
|
+
if (DeviceInfo.getBrand() === 'Allwinner') {
|
|
72
72
|
NativeModules.Orientation?.lockToLandscapeLeft();
|
|
73
73
|
|
|
74
74
|
setTimeout(() => {
|
|
@@ -88,25 +88,25 @@ global.base.hooks = {
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
// 公共页面
|
|
91
|
-
import WebviewScreen from
|
|
92
|
-
import ScanQRCodeScreen from
|
|
93
|
-
import OperatorSelectScreen from
|
|
94
|
-
import EditInvoiceTitleScreen from
|
|
95
|
-
import InvoiceTitleListScreen from
|
|
96
|
-
import TvAlbumScreen from
|
|
97
|
-
import DeviceFeedbackScreen from
|
|
98
|
-
import DeviceAnswerDetailScreen from
|
|
91
|
+
import WebviewScreen from './screens/WebviewScreen';
|
|
92
|
+
import ScanQRCodeScreen from './screens/CommonScreens/ScanQRCodeScreen';
|
|
93
|
+
import OperatorSelectScreen from './screens/CommonScreens/OperatorSelectScreen';
|
|
94
|
+
import EditInvoiceTitleScreen from './screens/CommonScreens/EditInvoiceTitleScreen';
|
|
95
|
+
import InvoiceTitleListScreen from './screens/CommonScreens/InvoiceTitleListScreen';
|
|
96
|
+
import TvAlbumScreen from './screens/CommonScreens/TvAlbumScreen';
|
|
97
|
+
import DeviceFeedbackScreen from './screens/CommonScreens/DeviceFeedbackScreen';
|
|
98
|
+
import DeviceAnswerDetailScreen from './screens/CommonScreens/DeviceAnswerDetailScreen';
|
|
99
99
|
|
|
100
100
|
// Boss绑定页面
|
|
101
|
-
import BindBossScreen from
|
|
101
|
+
import BindBossScreen from './screens/CommonScreens/BossScreen';
|
|
102
102
|
|
|
103
103
|
const Stack = createStackNavigator();
|
|
104
104
|
|
|
105
|
-
const envVersion = NativeModules?.RNToNativeEmitter?.serverCluster ||
|
|
105
|
+
const envVersion = NativeModules?.RNToNativeEmitter?.serverCluster || 'alpha';
|
|
106
106
|
// const envVersion = 'release';
|
|
107
107
|
|
|
108
108
|
let eventEmitter;
|
|
109
|
-
if (Platform.OS ===
|
|
109
|
+
if (Platform.OS === 'android') {
|
|
110
110
|
// ----yusm:安卓使用DeviceEventEmitter
|
|
111
111
|
eventEmitter = DeviceEventEmitter;
|
|
112
112
|
} else {
|
|
@@ -117,30 +117,30 @@ const CommonScreens = {
|
|
|
117
117
|
Home: {
|
|
118
118
|
component: BaseScreen,
|
|
119
119
|
screenOptions: {
|
|
120
|
-
title:
|
|
120
|
+
title: '首页',
|
|
121
121
|
headerShown: false,
|
|
122
122
|
includeBottom: true,
|
|
123
123
|
},
|
|
124
124
|
},
|
|
125
125
|
Login: {
|
|
126
126
|
component:
|
|
127
|
-
DeviceInfo.getBrand() ===
|
|
127
|
+
DeviceInfo.getBrand() === 'Allwinner' ? LoginScreen : NewLoginScreen,
|
|
128
128
|
screenOptions: {
|
|
129
|
-
title:
|
|
129
|
+
title: '登录',
|
|
130
130
|
headerShown: false,
|
|
131
131
|
},
|
|
132
132
|
},
|
|
133
133
|
ResePasswordScreen: {
|
|
134
134
|
component: ResePasswordScreen,
|
|
135
135
|
screenOptions: {
|
|
136
|
-
title:
|
|
136
|
+
title: '重置密码',
|
|
137
137
|
headerShown: false,
|
|
138
138
|
},
|
|
139
139
|
},
|
|
140
140
|
RegisteCountScreen: {
|
|
141
141
|
component: RegisteCountScreen,
|
|
142
142
|
screenOptions: {
|
|
143
|
-
title:
|
|
143
|
+
title: '注册',
|
|
144
144
|
headerShown: false,
|
|
145
145
|
},
|
|
146
146
|
},
|
|
@@ -153,62 +153,62 @@ const CommonScreens = {
|
|
|
153
153
|
OperatorSelectScreen: {
|
|
154
154
|
component: OperatorSelectScreen,
|
|
155
155
|
screenOptions: {
|
|
156
|
-
title:
|
|
156
|
+
title: '选择运营商',
|
|
157
157
|
headerShown: false,
|
|
158
158
|
},
|
|
159
159
|
},
|
|
160
160
|
InvoiceTitleListScreen: {
|
|
161
161
|
component: InvoiceTitleListScreen,
|
|
162
162
|
screenOptions: {
|
|
163
|
-
title:
|
|
163
|
+
title: '发票抬头',
|
|
164
164
|
headerShown: false,
|
|
165
165
|
},
|
|
166
166
|
},
|
|
167
167
|
EditInvoiceTitleScreen: {
|
|
168
168
|
component: EditInvoiceTitleScreen,
|
|
169
169
|
screenOptions: {
|
|
170
|
-
title:
|
|
170
|
+
title: '编辑发票抬头',
|
|
171
171
|
headerShown: false,
|
|
172
172
|
},
|
|
173
173
|
},
|
|
174
174
|
WebviewScreen: {
|
|
175
175
|
component: WebviewScreen,
|
|
176
176
|
screenOptions: {
|
|
177
|
-
title:
|
|
177
|
+
title: '',
|
|
178
178
|
headerShown: false,
|
|
179
179
|
},
|
|
180
180
|
},
|
|
181
181
|
TvAlbumScreen: {
|
|
182
182
|
component: TvAlbumScreen,
|
|
183
183
|
screenOptions: {
|
|
184
|
-
title:
|
|
184
|
+
title: '电视相册',
|
|
185
185
|
},
|
|
186
186
|
},
|
|
187
187
|
DeviceFeedbackScreen: {
|
|
188
188
|
component: DeviceFeedbackScreen,
|
|
189
189
|
screenOptions: {
|
|
190
|
-
title:
|
|
190
|
+
title: '帮助与反馈',
|
|
191
191
|
headerShown: false,
|
|
192
192
|
},
|
|
193
193
|
},
|
|
194
194
|
DeviceAnswerDetailScreen: {
|
|
195
195
|
component: DeviceAnswerDetailScreen,
|
|
196
196
|
screenOptions: {
|
|
197
|
-
title:
|
|
197
|
+
title: '解答',
|
|
198
198
|
headerShown: false,
|
|
199
199
|
},
|
|
200
200
|
},
|
|
201
201
|
SbkScreen: {
|
|
202
202
|
component: SbkScreen,
|
|
203
203
|
screenOptions: {
|
|
204
|
-
title:
|
|
204
|
+
title: '爱家宝',
|
|
205
205
|
headerShown: false,
|
|
206
206
|
},
|
|
207
207
|
},
|
|
208
208
|
BindBossScreen: {
|
|
209
209
|
component: BindBossScreen,
|
|
210
210
|
screenOptions: {
|
|
211
|
-
title:
|
|
211
|
+
title: '绑定boss账号',
|
|
212
212
|
headerShown: false,
|
|
213
213
|
},
|
|
214
214
|
},
|
|
@@ -216,7 +216,7 @@ const CommonScreens = {
|
|
|
216
216
|
|
|
217
217
|
// screen分组
|
|
218
218
|
function StackScreenGroup(screens) {
|
|
219
|
-
return Object.entries(screens).map(([name, {
|
|
219
|
+
return Object.entries(screens).map(([name, {component, screenOptions}]) => (
|
|
220
220
|
<Stack.Screen
|
|
221
221
|
name={name}
|
|
222
222
|
component={component}
|
|
@@ -229,24 +229,24 @@ function StackScreenGroup(screens) {
|
|
|
229
229
|
// 兜底的底部导航模块
|
|
230
230
|
const initialNavigationPackages = [
|
|
231
231
|
{
|
|
232
|
-
bundleName:
|
|
232
|
+
bundleName: 'index.ios.bundle',
|
|
233
233
|
isMain: 1,
|
|
234
|
-
md5:
|
|
235
|
-
moduleName:
|
|
236
|
-
modulePublishDesc:
|
|
237
|
-
upgradeMode:
|
|
238
|
-
url:
|
|
239
|
-
version:
|
|
234
|
+
md5: '7284896d821f9e206efc979590561e18',
|
|
235
|
+
moduleName: 'tvShare',
|
|
236
|
+
modulePublishDesc: '电视分享ios',
|
|
237
|
+
upgradeMode: 'force',
|
|
238
|
+
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',
|
|
239
|
+
version: 'v1.0.2',
|
|
240
240
|
},
|
|
241
241
|
{
|
|
242
|
-
bundleName:
|
|
242
|
+
bundleName: 'index.ios.bundle',
|
|
243
243
|
isMain: 1,
|
|
244
|
-
md5:
|
|
245
|
-
moduleName:
|
|
246
|
-
modulePublishDesc:
|
|
247
|
-
upgradeMode:
|
|
248
|
-
url:
|
|
249
|
-
version:
|
|
244
|
+
md5: '0fd7a6212a7b70baa54ce2a9cc99698b',
|
|
245
|
+
moduleName: 'smartHome',
|
|
246
|
+
modulePublishDesc: '智能家居ios',
|
|
247
|
+
upgradeMode: 'force',
|
|
248
|
+
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',
|
|
249
|
+
version: 'v1.0.2',
|
|
250
250
|
},
|
|
251
251
|
// {
|
|
252
252
|
// bundleName: 'index.ios.bundle',
|
|
@@ -274,7 +274,7 @@ global.base.initialNavigationPackages = initialNavigationPackages;
|
|
|
274
274
|
// updateNavigationPackagesFromStorage(1);
|
|
275
275
|
|
|
276
276
|
const App = () => {
|
|
277
|
-
const {
|
|
277
|
+
const {DynamicStackScreens} = useDynamicPackages();
|
|
278
278
|
// 当前页面是否需要包括底部安全区
|
|
279
279
|
const [includeBottom, setIncludeBottom] = useState(false);
|
|
280
280
|
const [versionUpdateConfirmVisible, setVersionUpdateConfirmVisible] =
|
|
@@ -295,16 +295,18 @@ const App = () => {
|
|
|
295
295
|
|
|
296
296
|
// mounted
|
|
297
297
|
useEffect(() => {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
298
|
+
if (Platform.OS === 'android') {
|
|
299
|
+
StatusBar.setBackgroundColor('transparent');
|
|
300
|
+
}
|
|
301
|
+
StatusBar.setBarStyle('dark-content');
|
|
302
|
+
storage.get('accountType').then(res => {
|
|
303
|
+
global.base.accountType = res || 'ajb';
|
|
302
304
|
});
|
|
303
305
|
|
|
304
306
|
const rnToNative = NativeModules.RNToNativeEmitter;
|
|
305
307
|
// 应用通知app可正常显示,页面正常运行了,在componentDidMount 中加
|
|
306
308
|
rnToNative?.notifyApplicationReady({
|
|
307
|
-
moduleName:
|
|
309
|
+
moduleName: 'base',
|
|
308
310
|
}); // 不用传参数
|
|
309
311
|
|
|
310
312
|
// 首次进入app登录鉴权
|
|
@@ -313,35 +315,35 @@ const App = () => {
|
|
|
313
315
|
// 获取最新版本并通知原生平台,由平台判断后弹出升级确认提示
|
|
314
316
|
checkBaseVersion();
|
|
315
317
|
|
|
316
|
-
AppState.addEventListener(
|
|
317
|
-
console.log(
|
|
318
|
-
if (nextAppState ===
|
|
319
|
-
appReport(
|
|
318
|
+
AppState.addEventListener('change', async nextAppState => {
|
|
319
|
+
console.log('nextAppState', nextAppState);
|
|
320
|
+
if (nextAppState === 'active') {
|
|
321
|
+
appReport('APP_STARTUP');
|
|
320
322
|
}
|
|
321
323
|
});
|
|
322
324
|
|
|
323
325
|
const keyboardDidShowListener = Keyboard.addListener(
|
|
324
|
-
|
|
326
|
+
'keyboardDidShow',
|
|
325
327
|
() => {
|
|
326
328
|
setIsKeyboardVisible(true);
|
|
327
|
-
}
|
|
329
|
+
},
|
|
328
330
|
);
|
|
329
331
|
|
|
330
332
|
const keyboardDidHideListener = Keyboard.addListener(
|
|
331
|
-
|
|
333
|
+
'keyboardDidHide',
|
|
332
334
|
() => {
|
|
333
335
|
setIsKeyboardVisible(false);
|
|
334
|
-
}
|
|
336
|
+
},
|
|
335
337
|
);
|
|
336
338
|
|
|
337
339
|
const cellularDataStateListener = eventEmitter.addListener(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
console.log(JSON.stringify(data),
|
|
340
|
+
'CellularDataState',
|
|
341
|
+
data => {
|
|
342
|
+
console.log(JSON.stringify(data), 'CellularDataState');
|
|
341
343
|
if (data?.state && data?.state !== 0) {
|
|
342
344
|
checkBaseVersion();
|
|
343
345
|
}
|
|
344
|
-
}
|
|
346
|
+
},
|
|
345
347
|
);
|
|
346
348
|
|
|
347
349
|
return () => {
|
|
@@ -351,32 +353,25 @@ const App = () => {
|
|
|
351
353
|
};
|
|
352
354
|
}, []);
|
|
353
355
|
|
|
354
|
-
// 处理屏幕其他部分的触摸事件
|
|
355
|
-
const handleTouchOutside = () => {
|
|
356
|
-
if (isKeyboardVisible) {
|
|
357
|
-
Keyboard.dismiss();
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
|
|
361
356
|
const checkBaseVersion = async () => {
|
|
362
357
|
// 当前版本
|
|
363
|
-
const baseVersionInfo = await global.base.getBundleInfo(
|
|
358
|
+
const baseVersionInfo = await global.base.getBundleInfo('base');
|
|
364
359
|
if (!baseVersionInfo) {
|
|
365
360
|
return false;
|
|
366
361
|
}
|
|
367
362
|
try {
|
|
368
363
|
const res = await getModuleVersionInfo({
|
|
369
364
|
platform: Platform.OS,
|
|
370
|
-
operatorId:
|
|
371
|
-
moduleName:
|
|
365
|
+
operatorId: 'ipanel',
|
|
366
|
+
moduleName: 'base',
|
|
372
367
|
});
|
|
373
368
|
if (res.code === 0) {
|
|
374
369
|
const versionInfo = res.data.packages[0];
|
|
375
370
|
const newVersion = Number(
|
|
376
|
-
versionInfo.version.slice(1).replace(/\./g,
|
|
371
|
+
versionInfo.version.slice(1).replace(/\./g, ''),
|
|
377
372
|
);
|
|
378
373
|
const currentVersion = Number(
|
|
379
|
-
baseVersionInfo.version.slice(1).replace(/\./g,
|
|
374
|
+
baseVersionInfo.version.slice(1).replace(/\./g, ''),
|
|
380
375
|
);
|
|
381
376
|
if (newVersion > currentVersion) {
|
|
382
377
|
setVersionUpdateConfirmVisible(true);
|
|
@@ -390,23 +385,23 @@ const App = () => {
|
|
|
390
385
|
global.base.checkBaseVersion = checkBaseVersion;
|
|
391
386
|
|
|
392
387
|
// 升级测试
|
|
393
|
-
const onUpdate =
|
|
388
|
+
const onUpdate = versionInfo => {
|
|
394
389
|
const rnToNative = NativeModules.RNToNativeEmitter;
|
|
395
390
|
rnToNative?.selectedInfo({
|
|
396
391
|
packages: [versionInfo],
|
|
397
|
-
operatorId:
|
|
392
|
+
operatorId: 'ipanel',
|
|
398
393
|
});
|
|
399
394
|
};
|
|
400
395
|
|
|
401
|
-
const handleStateChange = ({
|
|
396
|
+
const handleStateChange = ({routes}) => {
|
|
402
397
|
const routeName = routes[routes.length - 1].name;
|
|
403
398
|
setIncludeBottom(
|
|
404
|
-
allStackScreens[routeName]?.screenOptions?.includeBottom || false
|
|
399
|
+
allStackScreens[routeName]?.screenOptions?.includeBottom || false,
|
|
405
400
|
);
|
|
406
401
|
/* 加载之后每次navigate都鉴权一把登录状态(重置密码不需要检测) */
|
|
407
402
|
if (
|
|
408
|
-
routeName !==
|
|
409
|
-
routeName !==
|
|
403
|
+
routeName !== 'ResePasswordScreen' &&
|
|
404
|
+
routeName !== 'RegisteCountScreen'
|
|
410
405
|
) {
|
|
411
406
|
checkLogin();
|
|
412
407
|
}
|
|
@@ -422,14 +417,12 @@ const App = () => {
|
|
|
422
417
|
<SheetProvider>
|
|
423
418
|
<NavigationContainer
|
|
424
419
|
ref={navigationRef}
|
|
425
|
-
onStateChange={handleStateChange}
|
|
426
|
-
>
|
|
420
|
+
onStateChange={handleStateChange}>
|
|
427
421
|
<Stack.Navigator
|
|
428
|
-
initialRouteName={
|
|
422
|
+
initialRouteName={'Login'}
|
|
429
423
|
screenOptions={{
|
|
430
424
|
headerStyle: {},
|
|
431
|
-
}}
|
|
432
|
-
>
|
|
425
|
+
}}>
|
|
433
426
|
{/* 首页 */}
|
|
434
427
|
{/*<Stack.Screen*/}
|
|
435
428
|
{/* name="Home"*/}
|
|
@@ -458,11 +451,11 @@ const App = () => {
|
|
|
458
451
|
</NavigationContainer>
|
|
459
452
|
</SheetProvider>
|
|
460
453
|
|
|
461
|
-
<Loading onRef={
|
|
462
|
-
<Toast onRef={
|
|
463
|
-
<Notify onRef={
|
|
464
|
-
<Dialog onRef={
|
|
465
|
-
<SheetManage onRef={
|
|
454
|
+
<Loading onRef={ref => (global.loading = ref)} />
|
|
455
|
+
<Toast onRef={ref => (global.toast = ref)} />
|
|
456
|
+
<Notify onRef={ref => (global.notify = ref)} />
|
|
457
|
+
<Dialog onRef={ref => (global.dialog = ref)} />
|
|
458
|
+
<SheetManage onRef={ref => (global.sheetManager = ref)} />
|
|
466
459
|
{versionUpdateConfirmVisible && (
|
|
467
460
|
<VersionUpdateConfirm
|
|
468
461
|
onVisibleChange={setVersionUpdateConfirmVisible}
|
|
@@ -470,22 +463,16 @@ const App = () => {
|
|
|
470
463
|
onUpdate={onUpdate}
|
|
471
464
|
/>
|
|
472
465
|
)}
|
|
473
|
-
{isKeyboardVisible && Platform.OS === "ios" && (
|
|
474
|
-
<TouchableWithoutFeedback onPress={handleTouchOutside}>
|
|
475
|
-
<View style={styles.touchableContainer} />
|
|
476
|
-
</TouchableWithoutFeedback>
|
|
477
|
-
)}
|
|
478
466
|
</Provider>
|
|
479
467
|
</>
|
|
480
468
|
);
|
|
481
469
|
};
|
|
482
470
|
|
|
483
|
-
return Platform.OS ===
|
|
471
|
+
return Platform.OS === 'ios' ? (
|
|
484
472
|
<SafeAreaProvider>
|
|
485
473
|
<SafeAreaView
|
|
486
|
-
style={{
|
|
487
|
-
edges={includeBottom ? [
|
|
488
|
-
>
|
|
474
|
+
style={{flex: 1}}
|
|
475
|
+
edges={includeBottom ? ['right', 'left'] : ['right', 'bottom', 'left']}>
|
|
489
476
|
{renderContent()}
|
|
490
477
|
</SafeAreaView>
|
|
491
478
|
</SafeAreaProvider>
|
package/app/hooks/checkLogin.js
CHANGED
|
@@ -13,7 +13,8 @@ async function checkLogin() {
|
|
|
13
13
|
// console.log("正在进行登录鉴权", currentStackRoute.name);
|
|
14
14
|
if (!['Login', 'WebviewScreen'].includes(currentStackRoute.name)) {
|
|
15
15
|
// const start = new Date().getTime();
|
|
16
|
-
const
|
|
16
|
+
const accountType = await storage.get("accountType");
|
|
17
|
+
const token = await storage.get(accountType === 'adg' ? 'adgAccessToken' : 'accessToken')
|
|
17
18
|
// console.log(isLogined, new Date() - start); // 获取登录状态是异步的
|
|
18
19
|
if (!token) {
|
|
19
20
|
if (rootNavigationState.routes.length > 1) {
|
|
@@ -242,15 +242,20 @@ function HomeTabScreen({ navigation, route }) {
|
|
|
242
242
|
|
|
243
243
|
// 刷新token
|
|
244
244
|
const checkToken = async () => {
|
|
245
|
-
const
|
|
246
|
-
const
|
|
245
|
+
const accountType = await storage.get("accountType");
|
|
246
|
+
const accessTokenKey = accountType === 'adg' ? 'adgAccessToken' : 'accessToken';
|
|
247
|
+
const refreshTokenKey = accountType === 'adg' ? 'adgRefreshToken' : 'refreshToken';
|
|
248
|
+
const access_token = await storage.get(accessTokenKey);
|
|
249
|
+
const refresh_token = await storage.get(refreshTokenKey);
|
|
247
250
|
const logout = () => {
|
|
248
251
|
Alert.alert("登录过期,请重新登录!", "", [
|
|
249
252
|
{
|
|
250
253
|
text: "好",
|
|
251
254
|
onPress: async () => {
|
|
252
255
|
await storage.set("accessToken", null);
|
|
256
|
+
await storage.set("adgAccessToken", null);
|
|
253
257
|
await storage.set("refreshToken", null);
|
|
258
|
+
await storage.set("adgRefreshToken", null);
|
|
254
259
|
await storage.set("homedAccessToken", null);
|
|
255
260
|
replace("Login");
|
|
256
261
|
},
|
|
@@ -268,8 +273,8 @@ function HomeTabScreen({ navigation, route }) {
|
|
|
268
273
|
);
|
|
269
274
|
if (res.code === 0) {
|
|
270
275
|
console.log("刷新token", res);
|
|
271
|
-
await storage.set(
|
|
272
|
-
await storage.set(
|
|
276
|
+
await storage.set(accessTokenKey, res.result.access_token);
|
|
277
|
+
await storage.set(refreshTokenKey, res.result.refresh_token);
|
|
273
278
|
} else {
|
|
274
279
|
logout();
|
|
275
280
|
}
|
|
@@ -150,7 +150,8 @@ function LoginScreen({ navigation, route }) {
|
|
|
150
150
|
useEffect(() => {
|
|
151
151
|
// 获取登录状态
|
|
152
152
|
(async () => {
|
|
153
|
-
const
|
|
153
|
+
const accountType = await storage.get("accountType");
|
|
154
|
+
const token = await storage.get(accountType === 'adg' ? 'adgAccessToken' : 'accessToken')
|
|
154
155
|
if (token) {
|
|
155
156
|
if (appName === "遥控键码库") {
|
|
156
157
|
global.loading.showLoading("正在加载");
|
|
@@ -469,8 +470,8 @@ function LoginScreen({ navigation, route }) {
|
|
|
469
470
|
if (res.code === 0) {
|
|
470
471
|
console.log(res.result, "ipanelClound用户信息");
|
|
471
472
|
await storage.set("accountType", activeType);
|
|
472
|
-
await storage.set("accessToken
|
|
473
|
-
await storage.set("refreshToken", res.result.refresh_token);
|
|
473
|
+
await storage.set(activeType === 'adg' ? "adgAccessToken" : 'accessToken', res.result.access_token);
|
|
474
|
+
await storage.set(activeType === 'adg' ? 'adgRefreshToken' : "refreshToken", res.result.refresh_token);
|
|
474
475
|
|
|
475
476
|
if (activeIndex === 1) {
|
|
476
477
|
if (res.result.address && res.result.address[0]) {
|
package/app/utils/common.js
CHANGED
|
@@ -328,8 +328,11 @@ async function appReport(tag, extraData = {}) {
|
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
const checkToken = async () => {
|
|
331
|
-
const
|
|
332
|
-
const
|
|
331
|
+
const accountType = await storage.get("accountType");
|
|
332
|
+
const accessTokenKey = accountType === 'adg' ? 'adgAccessToken' : 'accessToken';
|
|
333
|
+
const refreshTokenKey = accountType === 'adg' ? 'adgRefreshToken' : 'refreshToken';
|
|
334
|
+
const access_token = await storage.get(accessTokenKey);
|
|
335
|
+
const refresh_token = await storage.get(refreshTokenKey);
|
|
333
336
|
|
|
334
337
|
const logout = () => {
|
|
335
338
|
Alert.alert("登录过期,请重新登录!", "", [
|
|
@@ -337,7 +340,9 @@ const checkToken = async () => {
|
|
|
337
340
|
text: "好",
|
|
338
341
|
onPress: async () => {
|
|
339
342
|
await storage.set("accessToken", null);
|
|
343
|
+
await storage.set("adgAccessToken", null);
|
|
340
344
|
await storage.set("refreshToken", null);
|
|
345
|
+
await storage.set("adgRefreshToken", null);
|
|
341
346
|
await storage.set("homedAccessToken", null);
|
|
342
347
|
replace("Login");
|
|
343
348
|
},
|
|
@@ -357,8 +362,8 @@ const checkToken = async () => {
|
|
|
357
362
|
);
|
|
358
363
|
if (res.code === 0) {
|
|
359
364
|
console.log("刷新token", res);
|
|
360
|
-
await storage.set(
|
|
361
|
-
await storage.set(
|
|
365
|
+
await storage.set(accessTokenKey, res.result.access_token);
|
|
366
|
+
await storage.set(refreshTokenKey, res.result.refresh_token);
|
|
362
367
|
resolve(true);
|
|
363
368
|
} else {
|
|
364
369
|
resolve(false);
|
package/app/utils/http.js
CHANGED
|
@@ -31,7 +31,8 @@ async function http(options) {
|
|
|
31
31
|
}, options.timeout); // 设置超时时间为5秒
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
// 如果url包含/install_ea用安电工token否者用爱家宝token
|
|
35
|
+
const TOKEN = await storage.get(url.indexOf('/install_ea') > -1 ? 'adgAccessToken' : 'accessToken');
|
|
35
36
|
const apartmentToken = await storage.get('apartmentToken');
|
|
36
37
|
const apartmentData = await storage.get('apartmentData');
|
|
37
38
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ipanel-rnapp-ajb-base",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"ipanelVersion": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
|
+
"ipanelVersion": "1.0.365",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
|
-
"bin": {
|
|
8
|
-
"local-dev": "bin/local-dev.js"
|
|
9
|
-
},
|
|
10
7
|
"keywords": [
|
|
11
8
|
"linyk",
|
|
12
9
|
"ipanel"
|
|
@@ -14,6 +11,6 @@
|
|
|
14
11
|
"author": "linyk",
|
|
15
12
|
"license": "ISC",
|
|
16
13
|
"scripts": {
|
|
17
|
-
"postinstall": "local-dev"
|
|
14
|
+
"postinstall": "node bin/local-dev.js"
|
|
18
15
|
}
|
|
19
16
|
}
|