|
|
@@ -1,24 +1,27 @@ |
|
|
import { editorUrl, getSessionStorageItem, removeSessionStorageItem } from '@/utils/sessionStorage'; |
|
|
|
|
|
|
|
|
// import { editorUrl, getSessionStorageItem, removeSessionStorageItem } from '@/utils/sessionStorage'; |
|
|
|
|
|
import { getJupyterUrl } from '@/services/developmentEnvironment'; |
|
|
|
|
|
import { to } from '@/utils/promise'; |
|
|
import { useEffect, useState } from 'react'; |
|
|
import { useEffect, useState } from 'react'; |
|
|
|
|
|
|
|
|
function DevEditor() { |
|
|
function DevEditor() { |
|
|
const [iframeUrl, setIframeUrl] = useState(''); |
|
|
const [iframeUrl, setIframeUrl] = useState(''); |
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
const url = getSessionStorageItem(editorUrl) || ''; |
|
|
|
|
|
setIframeUrl(url); |
|
|
|
|
|
return () => { |
|
|
|
|
|
removeSessionStorageItem(editorUrl); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
// const url = getSessionStorageItem(editorUrl) || ''; |
|
|
|
|
|
// setIframeUrl(url); |
|
|
|
|
|
// return () => { |
|
|
|
|
|
// removeSessionStorageItem(editorUrl); |
|
|
|
|
|
// }; |
|
|
|
|
|
requestJupyterUrl(); |
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|
// const requestJupyterUrl = async () => { |
|
|
|
|
|
// const [res, error] = await to(getJupyterUrl()); |
|
|
|
|
|
// if (res) { |
|
|
|
|
|
// setIframeUrl(res.data as string); |
|
|
|
|
|
// } else { |
|
|
|
|
|
// console.log(error); |
|
|
|
|
|
// } |
|
|
|
|
|
// }; |
|
|
|
|
|
|
|
|
const requestJupyterUrl = async () => { |
|
|
|
|
|
const [res, error] = await to(getJupyterUrl()); |
|
|
|
|
|
if (res) { |
|
|
|
|
|
setIframeUrl(res.data as string); |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log(error); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
return <iframe style={{ width: '100%', height: '100%', border: 0 }} src={iframeUrl}></iframe>; |
|
|
return <iframe style={{ width: '100%', height: '100%', border: 0 }} src={iframeUrl}></iframe>; |
|
|
} |
|
|
} |
|
|
|