forked from polywock/globalSpeed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.tsx
64 lines (57 loc) · 1.79 KB
/
popup.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
import { useState } from "react"
import ReactDOM from "react-dom"
import { Header } from "./Header"
import { getActiveTabInfo } from "../utils/browserUtils"
import { MainPanel } from "./MainPanel"
import { FxPanel } from "./FxPanel"
import { AudioPanel } from "notFirefox/popup/AudioPanel"
import { requestGsm } from "../utils/configUtils"
import { ErrorFallback } from "../comps/ErrorFallback"
import { useStateView } from "../hooks/useStateView"
import { FaPowerOff } from "react-icons/fa"
import { pushView } from "../background/GlobalState"
import { useThemeSync } from "src/hooks/useThemeSync"
import "./popup.scss"
import { createRoot } from "react-dom/client"
export function App(props: {}) {
const [panel, setPanel] = useState(0)
const [view, setView] = useStateView({superDisable: true})
useThemeSync()
if (!view) return null
if (view.superDisable) {
return (
<div
id={"SuperDisable"}
onClick={() => {
pushView({override: {superDisable: false, enabled: true}, tabId: gvar.tabInfo.tabId})
}}
onContextMenu={e => {
e.preventDefault()
pushView({override: {superDisable: false, enabled: true}, tabId: gvar.tabInfo.tabId})
}}
>
<FaPowerOff size="25px"/>
</div>
)
}
return (
<div id="App">
<Header panel={panel} setPanel={v => setPanel(v)}/>
{panel === 0 && <MainPanel/>}
{panel === 1 && <FxPanel/>}
{panel === 2 && AudioPanel && <AudioPanel/>}
</div>
)
}
Promise.all([
requestGsm().then(gsm => {
window.gsm = gsm
}),
getActiveTabInfo().then(tabInfo => {
gvar.tabInfo = tabInfo
gvar.tabInfo || window.close()
})
]).then(() => {
const root = createRoot(document.querySelector("#root"))
root.render(<ErrorFallback><App/></ErrorFallback>)
})