@@ -2,29 +2,47 @@ import "./ReplayPage.less";
22
33import classNames from "classnames" ;
44import { observer } from "mobx-react-lite" ;
5- import React , { useContext , useState } from "react" ;
5+ import React , { useContext , useMemo , useState } from "react" ;
66import { RouteComponentProps , useHistory } from "react-router-dom" ;
7+ import { useWindowSize } from "react-use" ;
78
89import { RoomType } from "@netless/flat-server-api" ;
910import { LoadingPage , TopBar } from "flat-components" ;
1011
11- import ExitReplayConfirm from "../components/ExitReplayConfirm" ;
12+ import { WeChatRedirect } from "../AppRoutes/WeChatRedirect" ;
13+ import { ExitReplayConfirm } from "../components/ExitReplayConfirm" ;
1214import { WindowsSystemBtnContext } from "../components/StoreProvider" ;
1315import { useClassroomReplayStore } from "../utils/use-classroom-replay-store" ;
1416import { useLoginCheck } from "../utils/use-login-check" ;
1517import { ReplayList } from "./ReplayList" ;
1618import { ReplayVideo } from "./ReplayVideo" ;
1719import { ReplayWhiteboard } from "./ReplayWhiteboard" ;
1820import { withFlatServices } from "../components/FlatServicesContext" ;
21+ import { isWeChatBrowser } from "../utils/user-agent" ;
1922
2023export type ReplayPageProps = RouteComponentProps < {
2124 roomUUID : string ;
2225 ownerUUID : string ;
2326 roomType : RoomType ;
2427} > ;
2528
26- export const ReplayPage = withFlatServices ( "whiteboard" ) (
27- observer < ReplayPageProps > ( function ReplayPage ( { match } ) {
29+ export const ReplayPage = observer < ReplayPageProps > ( function ReplayPage ( { ...props } ) {
30+ const { width } = useWindowSize ( 1080 ) ;
31+
32+ const url = useMemo ( ( ) => {
33+ const { roomUUID, ownerUUID, roomType } = props . match . params ;
34+ return `x-agora-flat-client://replayRoom?roomUUID=${ roomUUID } &ownerUUID=${ ownerUUID } &roomType=${ roomType } ` ;
35+ } , [ props . match ] ) ;
36+
37+ if ( isWeChatBrowser || width < 480 ) {
38+ return < WeChatRedirect open url = { url } /> ;
39+ }
40+
41+ return < ReplayPageImpl { ...props } /> ;
42+ } ) ;
43+
44+ export const ReplayPageImpl = withFlatServices ( "whiteboard" ) (
45+ observer < ReplayPageProps > ( function ReplayPageImpl ( { match } ) {
2846 useLoginCheck ( ) ;
2947
3048 const history = useHistory ( ) ;
0 commit comments