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
import { AlertTitle } from "@mui/material";
import MuiAlert from "@mui/material/Alert";
import CssBaseline from "@mui/material/CssBaseline";
import Slide from "@mui/material/Slide";
import Snackbar from "@mui/material/Snackbar";
import * as Sentry from "@sentry/react";
import { Outlet, useModel } from "@umijs/max";
import React from "react";
import ThemeProvider from "./theme";
// 自定义主题
// const { palette } = useTheme();
// const theme = useMemo(() => {
// return createTheme(curthemeconfig);
// }, [curthemeconfig]);
{
/* <div style={{ position: "fixed", right: 36, top: 36 }}>
<IconButton
onClick={() => {
if (curthemeconfig.palette.mode == "dark") {
dispatch(changetheme("lightTheme"));
} else {
dispatch(changetheme("darkTheme"));
}
}}
>
{curthemeconfig.palette.mode !== "dark" ? (
<WbSunnyIcon style={{ color: "#ff9900" }}></WbSunnyIcon>
) : (
<DarkModeIcon></DarkModeIcon>
)}
</IconButton>
</div> */
}
Sentry.init({
dsn: "http://38a2decfe9214e639164d2ca6ef92a67@iot-dev.nangaoyun.com:9000/9",
integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],
enabled: process.env.NODE_ENV !== "development",
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
Sentry.configureScope(function (scope) {
scope.setLevel("error");
});
const Alert = React.forwardRef(function Alert(props, ref) {
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />;
});
function App() {
const handleClose = (event) => {
setInitialState((s) => ({
...s,
message: {
...message,
open: false,
},
}));
};
const {
initialState: { message },
setInitialState,
} = useModel("@@initialState");
return (
<ThemeProvider>
<CssBaseline />
<Snackbar
open={message?.open}
TransitionComponent={(props) => <Slide {...props} direction="left" />}
{...message?.snackbar}
onClose={handleClose}
>
<Alert
severity={message?.type}
onClose={handleClose}
{...message.alert}
sx={{ color: "#f9f9f9" }}
>
{message?.title ? <AlertTitle>{message?.title}</AlertTitle> : null}
{message?.content}
</Alert>
</Snackbar>
<Outlet />
</ThemeProvider>
);
}
export default App;