ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<script lang="ts" setup>
import { ref } from 'vue';
 
import { MonacoEditor } from '@jnpf/ui';
import { BasicModal, useModalInner } from '@jnpf/ui/modal';
 
const emit = defineEmits(['register', 'change']);
const [registerModal, { closeModal }] = useModalInner(init);
const editorRef = ref(null);
const value = ref();
 
function init(data) {
  value.value = JSON.stringify(data.value ? JSON.parse(data.value) : '', null, 2);
}
function handleSubmit() {
  emit('change', value.value);
  setTimeout(() => {
    closeModal();
  }, 200);
}
</script>
<template>
  <BasicModal v-bind="$attrs" @register="registerModal" title="数据设置" @ok="handleSubmit" destroy-on-close class="json-modal">
    <MonacoEditor ref="editorRef" v-model="value" class="json-editor" />
  </BasicModal>
</template>