<template>
  <BasicModal
    v-bind="$attrs"
    destroyOnClose
    @register="registerModal"
    :title="getTitle"
    @ok="handleSubmit"
    width="900px"
  >
    <CodeEditor v-model:value="codeData.value" :mode="codeData.mode" />
  </BasicModal>
</template>

<script setup lang="ts">
  import { ref } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { CodeEditor } from '/@/components/CodeEditor';
  const getTitle = '代码预览';
  const codeData = ref({
    value: '',
    mode: 'javascript',
  });
  const [registerModal, { setModalProps, closeModal }] = useModalInner(async data => {
    setModalProps({ confirmLoading: false });
    codeData.value.value = data.record;
  });
  // 提交按钮事件
  async function handleSubmit() {
    closeModal();
  }
</script>

<style lang="less" scoped></style>
