From cd1cd39a7afef66bdf1f67efb841a39f3c3a565f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E4=BB=99=E9=83=BD=E6=B2=A1=E7=94=A8?= <615206459@qq.com> Date: Tue, 16 Jul 2024 14:46:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3ai=E7=BC=96=E7=A0=81=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=A9=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/helper/views/ai-code.vue | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/modules/helper/views/ai-code.vue b/src/modules/helper/views/ai-code.vue index 3793dfa..281f4f4 100644 --- a/src/modules/helper/views/ai-code.vue +++ b/src/modules/helper/views/ai-code.vue @@ -448,6 +448,9 @@ const code = reactive({ // 生成中 loading: false, + // 请求 + req: null as Promise | null, + // 获取字段 async getColumns() { return ai @@ -465,6 +468,8 @@ const code = reactive({ clear() { code.list = []; code.logs = []; + code.req = null; + code.loading = false; }, // 提示 @@ -504,6 +509,7 @@ const code = reactive({ code.data.prefix = entityData.path; code.data.fileName = entityData.fileName; + // 解析字段 code.parseColumn(); code.tips("Service 代码生成中"); @@ -568,6 +574,7 @@ const code = reactive({ code.data.prefix = entityData.path; code.data.fileName = entityData.fileName; + // 解析字段 code.parseColumn(); code.tips("Mapper 代码生成中"); @@ -655,7 +662,7 @@ const code = reactive({ await code[`create${lang.value}`](); - await code.createVue(false); + await code.createVue(); code.tips("编码完成"); @@ -684,7 +691,7 @@ const code = reactive({ entity: code.getContent(`${lang.value}-entity`) }); - await Promise.all([a, b]).then((res) => { + code.req = Promise.all([a, b]).then((res) => { if (res[0]?.columns) { code.data.columns = res[0].columns.map((e: EpsColumn) => { if (res[1]?.columns) { @@ -715,7 +722,7 @@ const code = reactive({ }, // 创建vue - async createVue(isParse: boolean = true) { + async createVue() { const item = code.add("Vue 页面", "vue"); item.content = ""; @@ -724,11 +731,14 @@ const code = reactive({ code.tips("Vue 代码开始生成"); - if (isParse) { - code.tips("AI 分析中"); - await code.parseColumn(); + if (!code.req) { + code.parseColumn(); } + code.tips("AI 分析中"); + + await code.req; + // 生成内容 item.content = menu.createVue({ ...code.data, @@ -840,6 +850,7 @@ const code = reactive({ // 重新生成 async refresh() { code.loading = true; + code.req = null; await code.createVue(); code.loading = false; }