From 9f627fc643651f8d4b8e2eedca8f12e675a6880f Mon Sep 17 00:00:00 2001 From: heheer <1239331448@qq.com> Date: Thu, 11 Jan 2024 11:57:47 +0800 Subject: [PATCH] fix(web): fix running methods & change editor cdn --- web/src/App.tsx | 7 +++++++ web/src/pages/app/functions/mods/DebugPanel/index.tsx | 11 +++++++++-- .../mods/FunctionPanel/CreateModal/index.tsx | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/web/src/App.tsx b/web/src/App.tsx index b437d2963e..7e6f6f7a42 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next"; import { BrowserRouter, useRoutes } from "react-router-dom"; import { ChakraProvider } from "@chakra-ui/react"; import { css, Global } from "@emotion/react"; +import { loader } from "@monaco-editor/react"; import { wrapUseRoutes } from "@sentry/react"; import * as Sentry from "@sentry/react"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; @@ -69,6 +70,12 @@ function APP() { initProviders(); }, [getSiteSettings, i18n.language, initProviders]); + useEffect(() => { + loader.config({ + paths: { vs: "https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.45.0/min/vs" }, + }); + }, []); + return ( diff --git a/web/src/pages/app/functions/mods/DebugPanel/index.tsx b/web/src/pages/app/functions/mods/DebugPanel/index.tsx index 33bd122fbc..7a4a821079 100644 --- a/web/src/pages/app/functions/mods/DebugPanel/index.tsx +++ b/web/src/pages/app/functions/mods/DebugPanel/index.tsx @@ -102,8 +102,15 @@ export default function DebugPanel(props: { containerRef: any }) { ]; useEffect(() => { - if (currentFunction?.methods) { - setRunningMethod(currentFunction.params?.runningMethod || currentFunction.methods[0]); + const lastRunningMethod = currentFunction.params?.runningMethod; + if ( + currentFunction?.methods && + lastRunningMethod && + currentFunction.methods.includes(lastRunningMethod) + ) { + setRunningMethod(lastRunningMethod); + } else if (currentFunction?.methods) { + setRunningMethod(currentFunction.methods[0]); } }, [setRunningMethod, currentFunction]); diff --git a/web/src/pages/app/functions/mods/FunctionPanel/CreateModal/index.tsx b/web/src/pages/app/functions/mods/FunctionPanel/CreateModal/index.tsx index c28677039f..b0002eb4f6 100644 --- a/web/src/pages/app/functions/mods/FunctionPanel/CreateModal/index.tsx +++ b/web/src/pages/app/functions/mods/FunctionPanel/CreateModal/index.tsx @@ -119,6 +119,7 @@ const CreateModal = (props: { setCurrentFunction({ ...currentFunction, name: data.name }); } else if (isEdit && functionItem.name === data.name) { res = await updateFunctionMutation.mutateAsync(data); + setCurrentFunction({ ...currentFunction, ...data }); } else { res = await createFunctionMutation.mutateAsync(data); }