mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2024-11-01 14:10:27 +08:00
1
This commit is contained in:
parent
b84785f5e6
commit
d110ad119b
1410
build/cool/eps.d.ts
vendored
1410
build/cool/eps.d.ts
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
|||||||
export const proxy = {
|
export const proxy = {
|
||||||
"/dev/": {
|
"/dev/": {
|
||||||
target: "http://127.0.0.1:8001",
|
// target: "http://127.0.0.1:8001",
|
||||||
// target: "http://192.168.0.112:8001",
|
target: "http://192.168.0.119:8001",
|
||||||
// target: "https://dev-admin.cool-js.cloud",
|
// target: "https://dev-admin.cool-js.cloud",
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path: string) => path.replace(/^\/dev/, "")
|
rewrite: (path: string) => path.replace(/^\/dev/, "")
|
||||||
|
@ -21,7 +21,7 @@ import { useForm } from "@cool-vue/crud";
|
|||||||
import { deepPaths } from "/@/cool/utils";
|
import { deepPaths } from "/@/cool/utils";
|
||||||
import { computed, onMounted } from "vue";
|
import { computed, onMounted } from "vue";
|
||||||
import { useMenu, useAi } from "../../hooks";
|
import { useMenu, useAi } from "../../hooks";
|
||||||
import type { EpsData } from "../../types";
|
import type { EpsColumn, EpsData } from "../../types";
|
||||||
|
|
||||||
const { service, mitt } = useCool();
|
const { service, mitt } = useCool();
|
||||||
const menu = useMenu();
|
const menu = useMenu();
|
||||||
@ -193,7 +193,15 @@ function open() {
|
|||||||
|
|
||||||
// 是否需要ai分析
|
// 是否需要ai分析
|
||||||
if (data.isAi) {
|
if (data.isAi) {
|
||||||
await ai.matchType({ columns, name: data.name });
|
await ai
|
||||||
|
.invokeFlow("comm-parse-column", {
|
||||||
|
entity: JSON.stringify(columns)
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
columns.forEach((e: EpsColumn) => {
|
||||||
|
e.component = res.columns[e.propertyName] || "input";
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.create({
|
menu.create({
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { request } from "../utils";
|
|
||||||
import type { EpsColumn } from "../types";
|
|
||||||
import { module } from "/@/cool";
|
import { module } from "/@/cool";
|
||||||
import { useBase } from "/$/base";
|
import { useBase } from "/$/base";
|
||||||
|
|
||||||
@ -98,42 +96,7 @@ export function useAi() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 匹配组件类型
|
|
||||||
async function matchType({ columns, name }: { columns: EpsColumn[]; name: string }) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const fields = columns.filter((e) => {
|
|
||||||
return !["id", "crateTime", "updateTime"].includes(e.propertyName);
|
|
||||||
});
|
|
||||||
|
|
||||||
request({
|
|
||||||
url: "/open/code/eps/matchType",
|
|
||||||
method: "POST",
|
|
||||||
data: {
|
|
||||||
fields: fields.map((e) => {
|
|
||||||
return {
|
return {
|
||||||
type: e.type,
|
|
||||||
field: e.propertyName,
|
|
||||||
description: e.comment
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
func: name
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
const names = res.split(",");
|
|
||||||
|
|
||||||
fields.forEach((e, i) => {
|
|
||||||
e.component = names[i];
|
|
||||||
});
|
|
||||||
|
|
||||||
resolve(fields);
|
|
||||||
})
|
|
||||||
.catch(reject);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
matchType,
|
|
||||||
invokeFlow
|
invokeFlow
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ const form = reactive({
|
|||||||
// 执行步骤
|
// 执行步骤
|
||||||
const step = reactive({
|
const step = reactive({
|
||||||
loading: false,
|
loading: false,
|
||||||
value: "coding",
|
value: "start",
|
||||||
list: ["start", "enter", "form", "coding"],
|
list: ["start", "enter", "form", "coding"],
|
||||||
|
|
||||||
async next() {
|
async next() {
|
||||||
@ -505,6 +505,8 @@ 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.tips("Service 代码生成中");
|
code.tips("Service 代码生成中");
|
||||||
|
|
||||||
// service 代码
|
// service 代码
|
||||||
@ -544,7 +546,7 @@ const code = reactive({
|
|||||||
code.data.fieldEq = controllerData.fieldEq;
|
code.data.fieldEq = controllerData.fieldEq;
|
||||||
code.data.keyWordLikeFields = controllerData.keyWordLikeFields;
|
code.data.keyWordLikeFields = controllerData.keyWordLikeFields;
|
||||||
|
|
||||||
await code.createVue();
|
await code.createVue(false);
|
||||||
|
|
||||||
code.tips("编码完成");
|
code.tips("编码完成");
|
||||||
|
|
||||||
@ -563,8 +565,48 @@ const code = reactive({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 解析字段
|
||||||
|
async parseColumn() {
|
||||||
|
const a = ai.invokeFlow("comm-parse-entity-column", {
|
||||||
|
entity: code.getContent("node-entity")
|
||||||
|
});
|
||||||
|
|
||||||
|
const b = ai.invokeFlow("comm-parse-column", {
|
||||||
|
entity: code.getContent("node-entity")
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.all([a, b]).then((res) => {
|
||||||
|
if (res[0]?.columns) {
|
||||||
|
code.data.columns = res[0].columns.map((e: EpsColumn) => {
|
||||||
|
if (res[1]?.columns) {
|
||||||
|
e.component = res[1].columns[e.propertyName] || "input";
|
||||||
|
}
|
||||||
|
return e;
|
||||||
|
});
|
||||||
|
|
||||||
|
code.data.columns.push({
|
||||||
|
comment: "更新时间",
|
||||||
|
length: 0,
|
||||||
|
component: "datetime",
|
||||||
|
nullable: false,
|
||||||
|
propertyName: "updateTime",
|
||||||
|
type: "datetime"
|
||||||
|
});
|
||||||
|
|
||||||
|
code.data.columns.push({
|
||||||
|
comment: "创建时间",
|
||||||
|
length: 0,
|
||||||
|
component: "datetime",
|
||||||
|
nullable: false,
|
||||||
|
propertyName: "createTime",
|
||||||
|
type: "datetime"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// 创建vue
|
// 创建vue
|
||||||
async createVue() {
|
async createVue(isParse: boolean = true) {
|
||||||
const item = code.add("Vue 页面", "vue");
|
const item = code.add("Vue 页面", "vue");
|
||||||
|
|
||||||
item.content = "";
|
item.content = "";
|
||||||
@ -573,25 +615,10 @@ const code = reactive({
|
|||||||
|
|
||||||
code.tips("Vue 代码开始生成");
|
code.tips("Vue 代码开始生成");
|
||||||
|
|
||||||
|
if (isParse) {
|
||||||
code.tips("AI 分析中");
|
code.tips("AI 分析中");
|
||||||
|
await code.parseColumn();
|
||||||
await ai
|
}
|
||||||
.invokeFlow("comm-parse-entity-column", {
|
|
||||||
entity: code.getContent("node-entity")
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
code.data.columns = res.columns || [];
|
|
||||||
});
|
|
||||||
|
|
||||||
await ai
|
|
||||||
.invokeFlow("comm-parse-column", {
|
|
||||||
entity: code.getContent("node-entity")
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
code.data.columns.forEach((e) => {
|
|
||||||
e.component = res[e.propertyName];
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// 生成内容
|
// 生成内容
|
||||||
item.content = menu.createVue({
|
item.content = menu.createVue({
|
||||||
@ -692,7 +719,11 @@ const code = reactive({
|
|||||||
copy() {
|
copy() {
|
||||||
copy(code.getContent(code.active)!);
|
copy(code.getContent(code.active)!);
|
||||||
ElMessage.success("复制成功");
|
ElMessage.success("复制成功");
|
||||||
code.save();
|
|
||||||
|
// 存本地,方便调试
|
||||||
|
storage.set("ai-code.list", code.list);
|
||||||
|
storage.set("ai-code.data", code.data);
|
||||||
|
storage.set("ai-code.form", form);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 重新生成
|
// 重新生成
|
||||||
@ -700,14 +731,6 @@ const code = reactive({
|
|||||||
code.loading = true;
|
code.loading = true;
|
||||||
await code.createVue();
|
await code.createVue();
|
||||||
code.loading = false;
|
code.loading = false;
|
||||||
},
|
|
||||||
|
|
||||||
// 保存
|
|
||||||
save() {
|
|
||||||
console.log(code);
|
|
||||||
storage.set("ai-code.list", code.list);
|
|
||||||
storage.set("ai-code.data", code.data);
|
|
||||||
storage.set("ai-code.form", form);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -932,6 +955,7 @@ function toBack() {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
desc.init();
|
desc.init();
|
||||||
|
|
||||||
|
// 测试
|
||||||
if (step.value == "coding") {
|
if (step.value == "coding") {
|
||||||
code.list = storage.get("ai-code.list") || [];
|
code.list = storage.get("ai-code.list") || [];
|
||||||
|
|
||||||
|
@ -31,14 +31,16 @@ export function useFormat() {
|
|||||||
async provideDocumentFormattingEdits(model) {
|
async provideDocumentFormattingEdits(model) {
|
||||||
let text = model.getValue();
|
let text = model.getValue();
|
||||||
|
|
||||||
|
const parser = options[i].parser;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
text = await prettier.format(text, {
|
text = await prettier.format(text, {
|
||||||
parser: options[i].parser,
|
parser,
|
||||||
plugins: options[i].plugins,
|
plugins: options[i].plugins,
|
||||||
semi: true,
|
semi: true,
|
||||||
printWidth: 100,
|
printWidth: 100,
|
||||||
tabWidth: 4,
|
tabWidth: parser == "html" ? 4 : 2,
|
||||||
useTabs: true,
|
useTabs: parser == "html",
|
||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
trailingComma: "none"
|
trailingComma: "none"
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user