diff --git a/web/src/App.css b/web/src/App.css index 21615c5eb0..86cbe6ab6a 100644 --- a/web/src/App.css +++ b/web/src/App.css @@ -20,7 +20,7 @@ /* 滚动条滑块 */ ::-webkit-scrollbar-thumb { border-radius: 4px; - background: rgba(0, 0, 0, 0.5); + background: rgba(0, 0, 0, 0.2); } html, diff --git a/web/src/components/Editor/FunctionEditor.tsx b/web/src/components/Editor/FunctionEditor.tsx index e1ec8661c3..741bc31eb6 100644 --- a/web/src/components/Editor/FunctionEditor.tsx +++ b/web/src/components/Editor/FunctionEditor.tsx @@ -2,10 +2,15 @@ import { useEffect, useRef } from "react"; import { debounce } from "lodash"; import * as monaco from "monaco-editor/esm/vs/editor/editor.api"; +import { Pages } from "@/constants"; + import "./userWorker"; import { AutoImportTypings } from "./typesResolve"; +import useHotKey, { DEFAULT_SHORTCUTS } from "@/hooks/useHotKey"; +import useGlobalStore from "@/pages/globalStore"; + const autoImportTypings = new AutoImportTypings(); const parseImports = debounce(autoImportTypings.parse, 1500).bind(autoImportTypings); @@ -108,6 +113,19 @@ function FunctionEditor(props: { const subscriptionRef = useRef(undefined); const monacoEl = useRef(null); + const globalStore = useGlobalStore((state) => state); + + useHotKey( + DEFAULT_SHORTCUTS.send_request, + () => { + // format + editorRef.current?.trigger("keyboard", "editor.action.formatDocument", {}); + }, + { + enabled: globalStore.currentPageId === Pages.function, + }, + ); + useEffect(() => { if (monacoEl && !editorRef.current) { editorRef.current = monaco.editor.create(monacoEl.current!, { @@ -120,6 +138,7 @@ function FunctionEditor(props: { scrollbar: { verticalScrollbarSize: 6, }, + formatOnPaste: true, overviewRulerLanes: 0, lineNumbersMinChars: 4, fontSize: 14, diff --git a/web/src/components/Editor/JSONViewer.tsx b/web/src/components/Editor/JSONViewer.tsx index fb251df041..b5da8868e9 100644 --- a/web/src/components/Editor/JSONViewer.tsx +++ b/web/src/components/Editor/JSONViewer.tsx @@ -245,8 +245,8 @@ export default function JSONViewer(props: JSONViewerProps) { return (