From 14cc54d97f9958fd6f3d60739fe46523a2a837d2 Mon Sep 17 00:00:00 2001 From: luoqiz Date: Sun, 12 Jan 2025 22:31:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(generator):=20=E6=BA=90=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=86=85=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81=20(#44)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/code/generator.ts | 12 ++++++++++-- src/views/code/generator/GenPreviewModal.vue | 8 +++++++- src/views/code/generator/index.vue | 18 ++++++++++++++---- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/apis/code/generator.ts b/src/apis/code/generator.ts index d8c0a2aa..ab4fd187 100644 --- a/src/apis/code/generator.ts +++ b/src/apis/code/generator.ts @@ -32,14 +32,22 @@ export function genPreview(tableNames: Array) { } /** @desc 生成代码 */ -export function generate(tableNames: Array) { +export function downloadCode(tableNames: Array) { return http.requestNative({ - url: `${BASE_URL}/${tableNames}`, + url: `${BASE_URL}/${tableNames}/download`, method: 'post', responseType: 'blob', }) } +/** @desc 生成代码 */ +export function generateCode(tableNames: Array) { + return http.requestNative({ + url: `${BASE_URL}/${tableNames}`, + method: 'post', + }) +} + /** @desc 查询字典列表 */ export function listFieldConfigDict() { return http.get(`${BASE_URL}/dict`) diff --git a/src/views/code/generator/GenPreviewModal.vue b/src/views/code/generator/GenPreviewModal.vue index d6e9ac6b..0e69d8e0 100644 --- a/src/views/code/generator/GenPreviewModal.vue +++ b/src/views/code/generator/GenPreviewModal.vue @@ -3,6 +3,7 @@
@@ -71,7 +72,7 @@ import { Message, type TreeNodeData } from '@arco-design/web-vue' import { useClipboard } from '@vueuse/core' import { type GeneratePreviewResp, genPreview } from '@/apis/code/generator' -const emit = defineEmits<{ (e: 'generate', previewTableNames: string[]): void }>() +const emit = defineEmits([ 'download','generate']) const { copy, copied } = useClipboard() const genPreviewList = ref([]) @@ -128,6 +129,11 @@ const assembleTree = (genPreview: GeneratePreviewResp) => { // 下载 const onDownload = () => { + emit('download', [previewTableNames.value]) +} + +// 下载 +const onGenerator = () => { emit('generate', [previewTableNames.value]) } // 校验文件类型 diff --git a/src/views/code/generator/index.vue b/src/views/code/generator/index.vue index d3eeadd0..b4245e53 100644 --- a/src/views/code/generator/index.vue +++ b/src/views/code/generator/index.vue @@ -56,13 +56,14 @@ - +