forked from VirtualHotBar/NetMount
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tsx
More file actions
47 lines (40 loc) · 1.38 KB
/
main.tsx
File metadata and controls
47 lines (40 loc) · 1.38 KB
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
import React, { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next';
import './services/i18n'
import './index.css'
import { App } from './app'
import { BrowserRouter } from 'react-router-dom'
import { init } from './controller/main';
import ReactDOM from 'react-dom/client';
import { ConfigProvider, Spin } from '@arco-design/web-react';
import { hooks } from './services/hook';
import './controller/errorHandling'
function StartPage() {
const { t } = useTranslation()
const [startStr, setStartStr] = useState('loading')
useEffect(() => {
appStart(setStartStr)
})
return <div style={{ textAlign: 'center', width: '100%', height: '100%', margin: '0px', padding: '0px', backgroundColor: 'var(--color-bg-1)' }} data-tauri-drag-region>
<p style={{ paddingTop: '30%' }} data-tauri-drag-region>
<Spin size={30} />
<br />
{t('starting') + ':' + startStr}</p>
</div>
}
const reactRoot = ReactDOM.createRoot(document.getElementById('root')!)
reactRoot.render(
<StartPage></StartPage>
)
let appStarting = false
async function appStart(setStartStr: Function) {
if (appStarting) { return }//避免重新执行
appStarting = true
1
await init(setStartStr)//初始化功能
reactRoot.render(<React.StrictMode>
<BrowserRouter>
<App></App>
</BrowserRouter>
</React.StrictMode>)//React.StrictMode:严格模式检查组件副作用
}