diff --git a/src/api/database.ts b/src/api/database.ts index 9730337c..14d4c4d7 100644 --- a/src/api/database.ts +++ b/src/api/database.ts @@ -22,7 +22,7 @@ class DatabaseAPI { /** 获取代码生成预览数据 */ static getPreviewData(tableName: string) { - return request({ + return request({ url: `${DATABASE_BASE_URL}/table/${tableName}/generate-preview`, method: "get", }); diff --git a/src/views/generator/index.vue b/src/views/generator/index.vue index f00703a9..71339f10 100644 --- a/src/views/generator/index.vue +++ b/src/views/generator/index.vue @@ -85,19 +85,20 @@ size="80%" > - 123 + + + - +
+ +
@@ -119,32 +120,12 @@ import Codemirror from "codemirror-editor-vue3"; import type { CmComponentRef } from "codemirror-editor-vue3"; import type { Editor, EditorConfiguration } from "codemirror"; -const code = ref( - `var i = 0; -for (; i < 9; i++) { - console.log(i); - // more statements -} -` -); +const code = ref(); const cmRef = ref(); const cmOptions: EditorConfiguration = { mode: "text/javascript", }; -const onChange = (val: string, cm: Editor) => { - console.log(val); - console.log(cm.getValue()); -}; - -const onInput = (val: string) => { - console.log(val); -}; - -const onReady = (cm: Editor) => { - console.log(cm.focus()); -}; - onMounted(() => { setTimeout(() => { cmRef.value?.refresh(); @@ -174,7 +155,6 @@ import DatabaseAPI, { const queryFormRef = ref(ElForm); const loading = ref(false); -const ids = ref([]); const total = ref(0); const queryParams = reactive({ @@ -184,8 +164,6 @@ const queryParams = reactive({ const pageData = ref([]); -const formData = reactive({}); - const dialog = reactive({ visible: false, title: "", @@ -213,6 +191,9 @@ function handleResetQuery() { function handlePreview(tableName: string) { DatabaseAPI.getPreviewData(tableName).then((data) => { dialog.title = `预览 ${tableName}`; + code.value = data[0].content; + + console.log("data", data); handleOpenDialog(); }); } @@ -227,9 +208,9 @@ function handleOpenDialog() { function handleSubmit() {} -/* onMounted(() => { +onMounted(() => { handleQuery(); -}); */ +});