解决ai编码字段空的问题

This commit is contained in:
神仙都没用 2024-07-16 14:46:37 +08:00
parent ba0525f559
commit cd1cd39a7a

View File

@ -448,6 +448,9 @@ const code = reactive({
// //
loading: false, loading: false,
//
req: null as Promise<any> | null,
// //
async getColumns() { async getColumns() {
return ai return ai
@ -465,6 +468,8 @@ const code = reactive({
clear() { clear() {
code.list = []; code.list = [];
code.logs = []; code.logs = [];
code.req = null;
code.loading = false;
}, },
// //
@ -504,6 +509,7 @@ const code = reactive({
code.data.prefix = entityData.path; code.data.prefix = entityData.path;
code.data.fileName = entityData.fileName; code.data.fileName = entityData.fileName;
//
code.parseColumn(); code.parseColumn();
code.tips("Service 代码生成中"); code.tips("Service 代码生成中");
@ -568,6 +574,7 @@ const code = reactive({
code.data.prefix = entityData.path; code.data.prefix = entityData.path;
code.data.fileName = entityData.fileName; code.data.fileName = entityData.fileName;
//
code.parseColumn(); code.parseColumn();
code.tips("Mapper 代码生成中"); code.tips("Mapper 代码生成中");
@ -655,7 +662,7 @@ const code = reactive({
await code[`create${lang.value}`](); await code[`create${lang.value}`]();
await code.createVue(false); await code.createVue();
code.tips("编码完成"); code.tips("编码完成");
@ -684,7 +691,7 @@ const code = reactive({
entity: code.getContent(`${lang.value}-entity`) 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) { if (res[0]?.columns) {
code.data.columns = res[0].columns.map((e: EpsColumn) => { code.data.columns = res[0].columns.map((e: EpsColumn) => {
if (res[1]?.columns) { if (res[1]?.columns) {
@ -715,7 +722,7 @@ const code = reactive({
}, },
// vue // vue
async createVue(isParse: boolean = true) { async createVue() {
const item = code.add("Vue 页面", "vue"); const item = code.add("Vue 页面", "vue");
item.content = ""; item.content = "";
@ -724,11 +731,14 @@ const code = reactive({
code.tips("Vue 代码开始生成"); code.tips("Vue 代码开始生成");
if (isParse) { if (!code.req) {
code.tips("AI 分析中"); code.parseColumn();
await code.parseColumn();
} }
code.tips("AI 分析中");
await code.req;
// //
item.content = menu.createVue({ item.content = menu.createVue({
...code.data, ...code.data,
@ -840,6 +850,7 @@ const code = reactive({
// //
async refresh() { async refresh() {
code.loading = true; code.loading = true;
code.req = null;
await code.createVue(); await code.createVue();
code.loading = false; code.loading = false;
} }