clean up
This commit is contained in:
parent
219b241a67
commit
56b9e8bf50
@ -29,7 +29,7 @@ import { OnboardingNote } from "./components/OnboardingNote";
|
||||
import { usePersistedState } from "./hooks/usePersistedState";
|
||||
import { UrlInputSection } from "./components/UrlInputSection";
|
||||
import TermsOfServiceDialog from "./components/TermsOfServiceDialog";
|
||||
import html2canvas from 'html2canvas';
|
||||
import html2canvas from "html2canvas";
|
||||
import { USER_CLOSE_WEB_SOCKET_CODE } from "./constants";
|
||||
|
||||
function App() {
|
||||
@ -53,15 +53,17 @@ function App() {
|
||||
const wsRef = useRef<WebSocket>(null);
|
||||
|
||||
const takeScreenshot = async (): Promise<string> => {
|
||||
const iframeElement = document.querySelector('#preview-desktop') as HTMLIFrameElement;
|
||||
const iframeElement = document.querySelector(
|
||||
"#preview-desktop"
|
||||
) as HTMLIFrameElement;
|
||||
if (!iframeElement?.contentWindow?.document.body) {
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
|
||||
const canvas = await html2canvas(iframeElement.contentWindow.document.body);
|
||||
const png = canvas.toDataURL('image/png');
|
||||
const png = canvas.toDataURL("image/png");
|
||||
return png;
|
||||
}
|
||||
};
|
||||
|
||||
const downloadCode = () => {
|
||||
// Create a blob from the generated code
|
||||
@ -91,8 +93,8 @@ function App() {
|
||||
const stop = () => {
|
||||
wsRef.current?.close?.(USER_CLOSE_WEB_SOCKET_CODE);
|
||||
// make sure stop can correct the state even if the websocket is already closed
|
||||
setAppState(AppStatus.CODE_READY);
|
||||
}
|
||||
setAppState(AppState.CODE_READY);
|
||||
};
|
||||
|
||||
function doGenerateCode(params: CodeGenerationParams) {
|
||||
setExecutionConsole([]);
|
||||
@ -204,13 +206,11 @@ function App() {
|
||||
{appState === AppState.CODE_READY && (
|
||||
<div>
|
||||
<div className="grid w-full gap-2">
|
||||
<div className="flex justify-between items-center gap-x-2">
|
||||
<div className="font-500">
|
||||
Auto Image Comparison
|
||||
</div>
|
||||
<div className="flex justify-between items-center gap-x-2">
|
||||
<div className="font-500">Auto Image Comparison</div>
|
||||
<Switch
|
||||
checked={isImgCompare}
|
||||
onCheckedChange={setIsImgCompare}
|
||||
checked={isImgCompare}
|
||||
onCheckedChange={setIsImgCompare}
|
||||
/>
|
||||
</div>
|
||||
<Textarea
|
||||
|
||||
@ -53,7 +53,6 @@ export function generateCode(
|
||||
} else if (event.code !== 1000) {
|
||||
console.error("WebSocket error code", event);
|
||||
toast.error(ERROR_MESSAGE);
|
||||
onComplete();
|
||||
}
|
||||
onComplete();
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user