forked from Gitlink/forgeplus-react
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
import React, { useEffect, useState, useCallback } from 'react';
|
|
import { withRouter } from "react-router";
|
|
import { SnackbarHOC } from "educoder";
|
|
import { CNotificationHOC } from "../modules/courses/common/CNotificationHOC";
|
|
import { TPMIndexHOC } from "../modules/tpm/TPMIndexHOC";
|
|
|
|
|
|
const Iframe = (props) => {
|
|
|
|
const { history, showLoginDialog, current_user } = props
|
|
let settings = localStorage.chromesetting && localStorage.chromesetting !== 'undefined' &&JSON.parse(localStorage.chromesetting);
|
|
|
|
useEffect(() => {
|
|
if (!settings?.common?.hiAgent) {
|
|
history.push("/404");
|
|
}
|
|
if (!current_user?.login) {
|
|
history.push("/login?go_page=/hiagent");
|
|
}
|
|
document.title = "GitLink-AI"
|
|
}, [])
|
|
|
|
function iframeLoad() {
|
|
let myIframe = document.getElementById("iframe");
|
|
const toastRight = myIframe?.contentWindow?.document?.getElementsByClassName("arco-notification-wrapper-topRight")[0]
|
|
const toastTop = myIframe?.contentWindow?.document?.getElementsByClassName("arco-notification-wrapper-top")[0]
|
|
if (toastRight) {
|
|
toastRight.style.top = '60px'
|
|
}
|
|
if (toastTop) {
|
|
toastTop.style.top = '80px'
|
|
}
|
|
}
|
|
|
|
return current_user?.login ? <iframe
|
|
id="iframe"
|
|
width="100%"
|
|
className="test-iframe"
|
|
src={ settings?.common?.hiAgent }
|
|
onLoad={iframeLoad}
|
|
></iframe> : ''
|
|
}
|
|
|
|
export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(Iframe)))); |