-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
app.ts
77 lines (70 loc) · 2.07 KB
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import '@/utils/errorHandle'
import { init as initLog } from '@/utils/log'
import { bootLog, getBootLog } from '@/utils/bootLog'
import '@/config/globalData'
import { getFontSize } from '@/utils/data'
import { exitApp } from './utils/nativeModules/utils'
import { windowSizeTools } from './utils/windowSizeTools'
import { listenLaunchEvent } from './navigation/regLaunchedEvent'
import { tipDialog } from './utils/tools'
console.log('starting app...')
listenLaunchEvent()
void Promise.all([getFontSize(), windowSizeTools.init()]).then(async([fontSize]) => {
global.lx.fontSize = fontSize
bootLog('Font size setting loaded.')
let isInited = false
let handlePushedHomeScreen: () => void | Promise<void>
const tryGetBootLog = () => {
try {
return getBootLog()
} catch (err) {
return 'Get boot log failed.'
}
}
const handleInit = async() => {
if (isInited) return
void initLog()
const { default: init } = await import('@/core/init')
try {
handlePushedHomeScreen = await init()
} catch (err: any) {
void tipDialog({
title: '初始化失败 (Init Failed)',
message: `Boot Log:\n${tryGetBootLog()}\n\n${(err.stack ?? err.message) as string}`,
btnText: 'Exit',
bgClose: false,
}).then(() => {
exitApp()
})
return
}
isInited ||= true
}
const { init: initNavigation, navigations } = await import('@/navigation')
initNavigation(async() => {
await handleInit()
if (!isInited) return
// import('@/utils/nativeModules/cryptoTest')
await navigations.pushHomeScreen().then(() => {
void handlePushedHomeScreen()
}).catch((err: any) => {
void tipDialog({
title: 'Error',
message: err.message,
btnText: 'Exit',
bgClose: false,
}).then(() => {
exitApp()
})
})
})
}).catch((err) => {
void tipDialog({
title: '初始化失败 (Init Failed)',
message: `Boot Log:\n\n${(err.stack ?? err.message) as string}`,
btnText: 'Exit',
bgClose: false,
}).then(() => {
exitApp()
})
})