优化 cl-editor-monaco 加载

This commit is contained in:
神仙都没用 2024-07-23 15:00:59 +08:00
parent d380613ba1
commit 2f56336564
4 changed files with 19 additions and 14 deletions

View File

@ -229,7 +229,8 @@
</div>
<div class="code">
<cl-editor-monaco
<cl-editor
name="cl-editor-monaco"
:ref="setRefs('editor')"
v-model="activeCode.content"
height="100%"
@ -291,7 +292,6 @@ import { assign, isEmpty } from "lodash-es";
import { useMenu, useAi } from "../hooks";
import { config, isDev } from "/@/config";
import { useForm } from "@cool-vue/crud";
import * as monaco from "monaco-editor";
import { sleep, storage } from "/@/cool/utils";
import dayjs from "dayjs";
import type { CodeItem, EpsColumn } from "../types";
@ -303,17 +303,6 @@ const ai = useAi();
const Form = useForm();
const { copy } = useClipboard();
//
monaco.editor.defineTheme("ai-code--dark", {
base: "vs-dark",
inherit: true,
rules: [],
colors: {
"editor.background": "#0f151e",
"editor.inactiveSelectionBackground": "#0f151e"
}
});
//
const form = reactive({
entity: "",

View File

@ -15,6 +15,7 @@ export default (): ModuleConfig => {
],
components: [
// 依赖偏大现用于“ai编码页面”如不需要请注释组件
// 代码编辑器 https://www.npmjs.com/package/monaco-editor
() => import("./components/monaco.vue")
]

View File

@ -1 +1,2 @@
export * from "./utils/declare";
export * from "./utils/theme";

View File

@ -1,6 +1,6 @@
import { editor } from "monaco-editor";
editor.defineTheme("default", {
defineTheme("default", {
base: "vs",
inherit: true,
rules: [
@ -348,3 +348,17 @@ editor.defineTheme("default", {
"editor.selectionHighlightBorder": "#fafbfc"
}
});
defineTheme("ai-code--dark", {
base: "vs-dark",
inherit: true,
rules: [],
colors: {
"editor.background": "#0f151e",
"editor.inactiveSelectionBackground": "#0f151e"
}
});
export function defineTheme(name: string, data: editor.IStandaloneThemeData) {
editor.defineTheme(name, data);
}