-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathPage.tsx
109 lines (104 loc) · 2.74 KB
/
Page.tsx
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import React, { useEffect } from 'react'
import AutoSave from 'components/AutoSave'
import Loading from 'components/Loading'
import Editor from 'components/Editor'
import Error from 'components/Error'
import LoadError from 'components/LoadError'
import RemoveDraft from 'components/RemoveDraft'
import Goto from 'components/Goto'
import Hosts from 'components/Hosts'
import DonateLink from 'components/DonateLink'
import Toggle from 'components/Toggle'
import Include from 'components/Include'
import Reset from 'components/Reset'
import ModeSelect from 'components/ModeSelect'
import Save from 'components/Save'
import Size from 'components/Size'
import NewPattern from 'components/NewPattern'
import queryString from 'query-string'
import NewTabLink from './NewTabLink'
import { useStore } from './StoreContext'
import { observer } from 'mobx-react'
import Format from './Format'
import HostTableLink from './HostTableLink'
import { useLocation } from 'react-router-dom'
const toolbarStyle = {
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center'
}
export default observer((props) => {
const { AppStore } = useStore()
const location = useLocation()
useEffect(() => {
const query = queryString.parse(location.search)
AppStore.init(query)
}, [location.search])
const { loading, error, loadError } = AppStore
const closePopup = () => {
if (!AppStore.tabMode) {
window.close()
}
}
if (loadError) {
return <LoadError error={loadError} />
}
if (error) {
return <Error error={error} />
}
if (loading) {
return <Loading />
}
return (
<div
style={{
display: 'grid',
gridTemplateRows: 'auto auto 1fr auto',
height: '100vh'
}}
>
<div style={toolbarStyle}>
<div>
<Save onSave={() => AppStore.save()} />
<Reset closePopup={closePopup} />
<ModeSelect />
<Format />
<NewTabLink />
<HostTableLink />
</div>
<div>
<Toggle />
</div>
</div>
<div style={toolbarStyle}>
<div>
<Hosts />
<NewPattern />
<Goto
goTo={() => {
AppStore.goTo()
closePopup()
}}
/>
</div>
<Include />
</div>
<Editor />
<div style={toolbarStyle}>
<span>
<RemoveDraft />
<AutoSave />
</span>
<Size />
<DonateLink />
</div>
<div id='error' className='error is-hidden'>
<strong>Custom JavaScript says:</strong>
<p className='red-text'>
It seems that this page cannot be modified with me..
</p>
<span>tip: Try refresh page</span>
</div>
</div>
)
})