feat: 代码编辑器

This commit is contained in:
wang_fan_w 2024-06-05 00:05:39 +08:00
parent caf400f9d3
commit 2f11c433fd
2 changed files with 7 additions and 21 deletions

View File

@ -1,28 +1,20 @@
<template> <template>
<div class="main"> <code-mirror basic :lang="lang" v-model="codeVal" :theme="theme" :extensions="extensions" />
<code-mirror basic :lang="lang" v-model="codeVal" style="height: 400px" :theme="theme" :extensions="extensions" />
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import CodeMirror from "vue-codemirror6"; import CodeMirror from "vue-codemirror6";
import { oneDark } from '@codemirror/theme-one-dark' import { oneDark } from "@codemirror/theme-one-dark";
import { json } from "@codemirror/lang-json"; import { json } from "@codemirror/lang-json";
defineOptions({ name: "CodemirrorCode" }); defineOptions({ name: "CodemirrorCode" });
const props = defineProps({ const props = defineProps({
initJson: { initJson: {
type: Object, type: Object,
default: () => {} default: {}
} }
}); });
// const initJson = {
// name: `maybaby`,
// year: 25,
// weight: 45,
// height: 165
// };
// //
let codeVal = ref(""); let codeVal = ref("");
// json // json
@ -54,13 +46,4 @@ const theme = {
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped></style>
.main {
width: 100%;
height: 100%;
}
/* required! */
.cm-editor {
height: 100%;
}
</style>

3
src/vite-env.d.ts vendored
View File

@ -8,3 +8,6 @@ declare module "*.vue" {
declare module "vue-i18n"; declare module "vue-i18n";
declare module "@arco-design/color"; declare module "@arco-design/color";
declare module "sortablejs"; declare module "sortablejs";
declare module "vue-codemirror6";
declare module "@codemirror/theme-one-dark";
declare module "@codemirror/lang-json";