@@ -5,9 +5,7 @@ import speakerSVG from "./icons/speaker.svg";
5
5
import microphoneSVG from "./icons/microphone.svg" ;
6
6
import "./DeviceCheckLayoutContainer.less" ;
7
7
8
- import React from "react" ;
9
- import { MainPageLayoutContainer } from "../../components/MainPageLayoutContainer" ;
10
- import { useWindowSize } from "../../utils/hooks/use-window-size" ;
8
+ import React , { useContext , useEffect } from "react" ;
11
9
import { routeConfig , RouteNameType } from "../../route-config" ;
12
10
import { useHistory , useLocation } from "react-router-dom" ;
13
11
import { DeviceCheckState } from "./utils" ;
@@ -20,50 +18,47 @@ export const DeviceCheckLayoutContainer: React.FC = ({ children }): React.ReactE
20
18
const t = useTranslate ( ) ;
21
19
const history = useHistory < DeviceCheckState > ( ) ;
22
20
const location = useLocation < DeviceCheckState | undefined > ( ) ;
21
+ const pageStore = useContext ( PageStoreContext ) ;
23
22
24
- const subMenu = [
25
- {
26
- key : routeConfig [ RouteNameType . SystemCheckPage ] . path ,
27
- icon : ( ) : React . ReactNode => < img src = { systemSVG } /> ,
28
- title : t ( "system-testing" ) ,
29
- route : routeConfig [ RouteNameType . SystemCheckPage ] . path ,
30
- } ,
31
- {
32
- key : routeConfig [ RouteNameType . CameraCheckPage ] . path ,
33
- icon : ( ) : React . ReactNode => < img src = { cameraSVG } /> ,
34
- title : t ( "camera-testing" ) ,
35
- route : routeConfig [ RouteNameType . CameraCheckPage ] . path ,
36
- } ,
37
- {
38
- key : routeConfig [ RouteNameType . SpeakerCheckPage ] . path ,
39
- icon : ( ) : React . ReactNode => < img src = { speakerSVG } /> ,
40
- title : t ( "headphone-testing" ) ,
41
- route : routeConfig [ RouteNameType . SpeakerCheckPage ] . path ,
42
- } ,
43
- {
44
- key : routeConfig [ RouteNameType . MicrophoneCheckPage ] . path ,
45
- icon : ( ) : React . ReactNode => < img src = { microphoneSVG } /> ,
46
- title : t ( "microphone-testing" ) ,
47
- route : routeConfig [ RouteNameType . MicrophoneCheckPage ] . path ,
48
- } ,
49
- ] ;
50
-
51
- const activeKeys = [ "deviceCheck" , location . pathname ] ;
52
-
53
- return (
54
- < MainPageLayoutContainer
55
- activeKeys = { activeKeys }
56
- subMenu = { subMenu }
57
- onRouteChange = { ( mainPageLayoutItem : MainPageLayoutItem ) => {
23
+ useEffect ( ( ) => {
24
+ pageStore . configure ( {
25
+ subMenu : [
26
+ {
27
+ key : routeConfig [ RouteNameType . SystemCheckPage ] . path ,
28
+ icon : ( ) : React . ReactNode => < img src = { systemSVG } /> ,
29
+ title : t ( "system-testing" ) ,
30
+ route : routeConfig [ RouteNameType . SystemCheckPage ] . path ,
31
+ } ,
32
+ {
33
+ key : routeConfig [ RouteNameType . CameraCheckPage ] . path ,
34
+ icon : ( ) : React . ReactNode => < img src = { cameraSVG } /> ,
35
+ title : t ( "camera-testing" ) ,
36
+ route : routeConfig [ RouteNameType . CameraCheckPage ] . path ,
37
+ } ,
38
+ {
39
+ key : routeConfig [ RouteNameType . SpeakerCheckPage ] . path ,
40
+ icon : ( ) : React . ReactNode => < img src = { speakerSVG } /> ,
41
+ title : t ( "headphone-testing" ) ,
42
+ route : routeConfig [ RouteNameType . SpeakerCheckPage ] . path ,
43
+ } ,
44
+ {
45
+ key : routeConfig [ RouteNameType . MicrophoneCheckPage ] . path ,
46
+ icon : ( ) : React . ReactNode => < img src = { microphoneSVG } /> ,
47
+ title : t ( "microphone-testing" ) ,
48
+ route : routeConfig [ RouteNameType . MicrophoneCheckPage ] . path ,
49
+ } ,
50
+ ] ,
51
+ activeKeys : [ "deviceCheck" , location . pathname ] ,
52
+ onRouteChange ( mainPageLayoutItem : MainPageLayoutItem ) {
58
53
history . push ( {
59
54
pathname : mainPageLayoutItem . route ,
60
55
state : {
61
56
...location . state ,
62
57
} ,
63
58
} ) ;
64
- } }
65
- >
66
- < div className = "device-check-layout-container" > { children } </ div >
67
- </ MainPageLayoutContainer >
68
- ) ;
59
+ } ,
60
+ } ) ;
61
+ } , [ history , location . pathname , location . state , pageStore , t ] ) ;
62
+
63
+ return < div className = "device-check-layout-container" > { children } </ div > ;
69
64
} ;
0 commit comments