forked from Renovamen/playground-macos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
77 lines (68 loc) · 1.79 KB
/
index.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
import React, { useState } from "react";
import { createRoot } from "react-dom/client";
import { Provider } from "react-redux";
import { store } from "~/redux/store";
import Desktop from "~/pages/Desktop";
import Login from "~/pages/Login";
import Boot from "~/pages/Boot";
import "@unocss/reset/tailwind.css";
import "uno.css";
import "katex/dist/katex.min.css";
import "~/styles/index.css";
export default function App() {
const [login, setLogin] = useState<boolean>(false);
const [booting, setBooting] = useState<boolean>(false);
const [restart, setRestart] = useState<boolean>(false);
const [sleep, setSleep] = useState<boolean>(false);
const shutMac = (e: React.MouseEvent): void => {
e.stopPropagation();
setRestart(false);
setSleep(false);
setLogin(false);
setBooting(true);
};
const restartMac = (e: React.MouseEvent): void => {
e.stopPropagation();
setRestart(true);
setSleep(false);
setLogin(false);
setBooting(true);
};
const sleepMac = (e: React.MouseEvent): void => {
e.stopPropagation();
setRestart(false);
setSleep(true);
setLogin(false);
setBooting(true);
};
if (booting) {
return <Boot restart={restart} sleep={sleep} setBooting={setBooting} />;
} else if (login) {
return (
<Desktop
setLogin={setLogin}
shutMac={shutMac}
sleepMac={sleepMac}
restartMac={restartMac}
/>
);
} else {
return (
<Login
setLogin={setLogin}
shutMac={shutMac}
sleepMac={sleepMac}
restartMac={restartMac}
/>
);
}
}
const rootElement = document.getElementById("root") as HTMLElement;
const root = createRoot(rootElement);
root.render(
<Provider store={store}>
<React.StrictMode>
<App />
</React.StrictMode>
</Provider>
);