From 37b6eef15efab0a71ac8d54b7917d6a6326902f3 Mon Sep 17 00:00:00 2001 From: ZackYoung Date: Wed, 20 Dec 2023 17:16:42 +0800 Subject: [PATCH 1/2] fix_monaco_cdn --- dinky-web/src/components/CustomEditor/CodeEdit/function.tsx | 2 ++ dinky-web/src/components/CustomEditor/CodeEdit/index.tsx | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dinky-web/src/components/CustomEditor/CodeEdit/function.tsx b/dinky-web/src/components/CustomEditor/CodeEdit/function.tsx index fae3acce0f..934f0f385f 100644 --- a/dinky-web/src/components/CustomEditor/CodeEdit/function.tsx +++ b/dinky-web/src/components/CustomEditor/CodeEdit/function.tsx @@ -26,7 +26,9 @@ import ITextModel = editor.ITextModel; import ProviderResult = languages.ProviderResult; import CompletionList = languages.CompletionList; import CompletionItem = languages.CompletionItem; +import {loader} from "@monaco-editor/react"; // 导入 lodash +loader.config({ monaco }); /** * get keyWordJson from {@link ./keyword.json} diff --git a/dinky-web/src/components/CustomEditor/CodeEdit/index.tsx b/dinky-web/src/components/CustomEditor/CodeEdit/index.tsx index 3e8e11412c..fee34bcbe6 100644 --- a/dinky-web/src/components/CustomEditor/CodeEdit/index.tsx +++ b/dinky-web/src/components/CustomEditor/CodeEdit/index.tsx @@ -25,7 +25,7 @@ import { handleInitEditorAndLanguageOnBeforeMount } from '@/components/CustomEdi import { StateType } from '@/pages/DataStudio/model'; import { MonacoEditorOptions, SuggestionInfo } from '@/types/Public/data'; import { convertCodeEditTheme } from '@/utils/function'; -import { Editor, Monaco, OnChange } from '@monaco-editor/react'; +import {Editor, loader, Monaco, OnChange} from '@monaco-editor/react'; import { connect } from '@umijs/max'; import useMemoCallback from 'rc-menu/es/hooks/useMemoCallback'; import { memo, useCallback, useRef } from 'react'; @@ -35,6 +35,8 @@ import CompletionContext = languages.CompletionContext; import CompletionList = languages.CompletionList; import ProviderResult = languages.ProviderResult; +loader.config({ monaco }); + let provider = { dispose: () => {} }; From 16f0b55ac3b86a403bbd813fe146b97f6b1c5435 Mon Sep 17 00:00:00 2001 From: Zzm0809 <934230207@qq.com> Date: Wed, 20 Dec 2023 21:35:01 +0800 Subject: [PATCH 2/2] added some loader --- dinky-web/src/components/CustomEditor/CodeShow/index.tsx | 6 +++++- .../DataStudio/MiddleContainer/StudioEditor/DiffModal.tsx | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dinky-web/src/components/CustomEditor/CodeShow/index.tsx b/dinky-web/src/components/CustomEditor/CodeShow/index.tsx index deaecdc473..b2a77e1107 100644 --- a/dinky-web/src/components/CustomEditor/CodeShow/index.tsx +++ b/dinky-web/src/components/CustomEditor/CodeShow/index.tsx @@ -28,8 +28,12 @@ import { EditorLanguage } from 'monaco-editor/esm/metadata'; import FullscreenBtn from '@/components/CustomEditor/FullscreenBtn'; import { handleInitEditorAndLanguageOnBeforeMount } from '@/components/CustomEditor/function'; -import { Editor, Monaco } from '@monaco-editor/react'; +import {Editor, loader, Monaco} from '@monaco-editor/react'; import { CSSProperties, useRef, useState } from 'react'; +import * as monaco from "monaco-editor"; + +loader.config({ monaco }); + export type CodeShowFormProps = { height?: string | number; diff --git a/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/DiffModal.tsx b/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/DiffModal.tsx index ba69b07fe0..c5f1df43ca 100644 --- a/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/DiffModal.tsx +++ b/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/DiffModal.tsx @@ -24,10 +24,13 @@ import { } from '@/pages/DataStudio/MiddleContainer/StudioEditor/constants'; import { convertCodeEditTheme } from '@/utils/function'; import { l } from '@/utils/intl'; -import { DiffEditor } from '@monaco-editor/react'; +import {DiffEditor, loader} from '@monaco-editor/react'; import { Col, Modal, Row, Space, Table, Tabs, Typography } from 'antd'; import React, { memo } from 'react'; import styles from './index.less'; +import * as monaco from "monaco-editor"; + +loader.config({ monaco }); const { Text, Link } = Typography;