wujingjing
2024-12-23 dd407c5da58ca201a1fc91af028ace3a6491853b
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<template>
    <ywDialog v-model="dialogIsShow" title="代码" width="50%" @dlgClosed="closeDialog" :showHeaderIcon="false" :showFooter="false">
        <div style="height: 600px" class="relative">
            <codemirror
                class="overflow-auto"
                style="height: 600px"
                v-model="codeValue"
                :autofocus="true"
                :indent-with-tab="true"
                :tab-size="2"
                :extensions="javascriptEditorExtensions"
            />
            <!-- <i
                @click="copyInfo(item.sql)"
                class="ywifont ywicon-copy text-blue-400 !text-[25px] cursor-pointer absolute bottom-10 right-10"
            ></i> -->
        </div>
    </ywDialog>
</template>
 
<script setup lang="ts">
import ywDialog from '/@/components/dialog/yw-dialog.vue';
 
import { javascript } from '@codemirror/lang-javascript';
import { vscodeDark } from '@uiw/codemirror-theme-vscode';
import { ref, watch } from 'vue';
import { Codemirror } from 'vue-codemirror';
import commonFunction from '/@/utils/commonFunction';
 
const javascriptEditorExtensions = [javascript(), vscodeDark];
const dialogIsShow = defineModel({
    type: Boolean,
});
const closeDialog = () => {
    dialogIsShow.value = false;
};
// const dialogTitle = computed(() => {
//     return props.item?.id ;
// });
const props = defineProps(['item']);
 
const { copyText } = commonFunction();
 
const copyInfo = async (sql) => {
    copyText(sql);
};
 
const codeValue = ref('');
watch(
    () => dialogIsShow.value,
    (val) => {
        if (val) {
            codeValue.value = props.item.value;
            // 关闭时保存内容
        } else {
            props.item.value = codeValue.value;
        }
    }
);
</script>
<style scoped lang="scss"></style>