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
02fa9f7f44
commit
5a77ce7f12
1529
build/cool/eps.d.ts
vendored
1529
build/cool/eps.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@
|
|||||||
"lint:eslint": "eslint \"./src/**/*.{vue,ts,tsx}\" --fix"
|
"lint:eslint": "eslint \"./src/**/*.{vue,ts,tsx}\" --fix"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cool-vue/crud": "^7.1.18",
|
"@cool-vue/crud": "^7.1.23",
|
||||||
"@element-plus/icons-vue": "^2.3.1",
|
"@element-plus/icons-vue": "^2.3.1",
|
||||||
"@vueuse/core": "^10.4.0",
|
"@vueuse/core": "^10.4.0",
|
||||||
"@wangeditor/editor": "^5.1.23",
|
"@wangeditor/editor": "^5.1.23",
|
||||||
|
5750
pnpm-lock.yaml
5750
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -308,61 +308,61 @@ export function useCode() {
|
|||||||
|
|
||||||
// 代码模板
|
// 代码模板
|
||||||
return `<template>
|
return `<template>
|
||||||
<cl-crud ref="Crud">
|
<cl-crud ref="Crud">
|
||||||
<cl-row>
|
<cl-row>
|
||||||
<!-- 刷新按钮 -->
|
<!-- 刷新按钮 -->
|
||||||
<cl-refresh-btn />
|
<cl-refresh-btn />
|
||||||
${perms.add ? "<!-- 新增按钮 -->\n<cl-add-btn />" : ""}
|
${perms.add ? "<!-- 新增按钮 -->\n <cl-add-btn />" : ""}
|
||||||
${perms.del ? "<!-- 删除按钮 -->\n<cl-multi-delete-btn />" : ""}
|
${perms.del ? "<!-- 删除按钮 -->\n <cl-multi-delete-btn />" : ""}
|
||||||
${clFilter}
|
${clFilter}
|
||||||
<cl-flex1 />
|
<cl-flex1 />
|
||||||
<!-- 关键字搜索 -->
|
<!-- 关键字搜索 -->
|
||||||
<cl-search-key placeholder="搜索${clSearchKeyPlaceholder || "关键字"}" />
|
<cl-search-key placeholder="搜索${clSearchKeyPlaceholder || "关键字"}" />
|
||||||
</cl-row>
|
</cl-row>
|
||||||
|
|
||||||
<cl-row>
|
|
||||||
<!-- 数据表格 -->
|
|
||||||
<cl-table ref="Table" />
|
|
||||||
</cl-row>
|
|
||||||
|
|
||||||
<cl-row>
|
|
||||||
<cl-flex1 />
|
|
||||||
<!-- 分页控件 -->
|
|
||||||
<cl-pagination />
|
|
||||||
</cl-row>
|
|
||||||
|
|
||||||
<!-- 新增、编辑 -->
|
|
||||||
<cl-upsert ref="Upsert" />
|
|
||||||
</cl-crud>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" name="${router.replace(/^\//, "").replace(/\//g, "-")}" setup>
|
|
||||||
import { useCrud, useTable, useUpsert } from "@cool-vue/crud";
|
|
||||||
import { useCool } from "/@/cool";
|
|
||||||
|
|
||||||
const { service } = useCool();
|
|
||||||
|
|
||||||
// cl-upsert
|
|
||||||
const Upsert = useUpsert(${toCodeString(upsert)});
|
|
||||||
|
|
||||||
// cl-table
|
|
||||||
const Table = useTable(${toCodeString(table)});
|
|
||||||
|
|
||||||
// cl-crud
|
|
||||||
const Crud = useCrud(
|
|
||||||
{
|
|
||||||
service: ${service.join(".")}
|
|
||||||
},
|
|
||||||
(app) => {
|
|
||||||
app.refresh();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// 刷新
|
<cl-row>
|
||||||
function refresh(params?: any) {
|
<!-- 数据表格 -->
|
||||||
Crud.value?.refresh(params);
|
<cl-table ref="Table" />
|
||||||
}
|
</cl-row>
|
||||||
</script>`;
|
|
||||||
|
<cl-row>
|
||||||
|
<cl-flex1 />
|
||||||
|
<!-- 分页控件 -->
|
||||||
|
<cl-pagination />
|
||||||
|
</cl-row>
|
||||||
|
|
||||||
|
<!-- 新增、编辑 -->
|
||||||
|
<cl-upsert ref="Upsert" />
|
||||||
|
</cl-crud>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="${router.replace(/^\//, "").replace(/\//g, "-")}" setup>
|
||||||
|
import { useCrud, useTable, useUpsert } from "@cool-vue/crud";
|
||||||
|
import { useCool } from "/@/cool";
|
||||||
|
|
||||||
|
const { service } = useCool();
|
||||||
|
|
||||||
|
// cl-upsert
|
||||||
|
const Upsert = useUpsert(${toCodeString(upsert)});
|
||||||
|
|
||||||
|
// cl-table
|
||||||
|
const Table = useTable(${toCodeString(table)});
|
||||||
|
|
||||||
|
// cl-crud
|
||||||
|
const Crud = useCrud(
|
||||||
|
{
|
||||||
|
service: ${service.join(".")}
|
||||||
|
},
|
||||||
|
(app) => {
|
||||||
|
app.refresh();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// 刷新
|
||||||
|
function refresh(params?: any) {
|
||||||
|
Crud.value?.refresh(params);
|
||||||
|
}
|
||||||
|
</script>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 转成代码字符串
|
// 转成代码字符串
|
||||||
|
@ -182,9 +182,7 @@
|
|||||||
<span
|
<span
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
if (!code.loading) {
|
step.prev();
|
||||||
step.prev();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
></span>
|
></span>
|
||||||
@ -212,9 +210,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="op" v-if="!isEmpty(code.list) && !code.loading">
|
<div class="op" v-if="!isEmpty(code.list) && !code.loading">
|
||||||
|
<el-tooltip content="重新生成" v-if="code.active == 'vue'">
|
||||||
|
<el-icon @click="code.refresh()">
|
||||||
|
<refresh />
|
||||||
|
</el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
|
||||||
<el-tooltip content="复制代码">
|
<el-tooltip content="复制代码">
|
||||||
<el-icon @click="code.copy()">
|
<el-icon @click="code.copy()">
|
||||||
<copy-document />
|
<document-copy />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
@ -277,8 +281,9 @@ import {
|
|||||||
Back,
|
Back,
|
||||||
ArrowRightBold,
|
ArrowRightBold,
|
||||||
Loading,
|
Loading,
|
||||||
CopyDocument,
|
DocumentCopy,
|
||||||
QuestionFilled
|
QuestionFilled,
|
||||||
|
Refresh
|
||||||
} from "@element-plus/icons-vue";
|
} from "@element-plus/icons-vue";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import { assign, isEmpty } from "lodash-es";
|
import { assign, isEmpty } from "lodash-es";
|
||||||
@ -320,7 +325,7 @@ const form = reactive({
|
|||||||
// 执行步骤
|
// 执行步骤
|
||||||
const step = reactive({
|
const step = reactive({
|
||||||
loading: false,
|
loading: false,
|
||||||
value: "start",
|
value: "coding",
|
||||||
list: ["start", "enter", "form", "coding"],
|
list: ["start", "enter", "form", "coding"],
|
||||||
|
|
||||||
async next() {
|
async next() {
|
||||||
@ -373,7 +378,7 @@ const step = reactive({
|
|||||||
|
|
||||||
// 代码
|
// 代码
|
||||||
const code = reactive({
|
const code = reactive({
|
||||||
active: "",
|
active: "node-entity",
|
||||||
|
|
||||||
// 代码列表
|
// 代码列表
|
||||||
list: (storage.get("ai-code.list") || []) as CodeItem[],
|
list: (storage.get("ai-code.list") || []) as CodeItem[],
|
||||||
@ -464,7 +469,8 @@ const code = reactive({
|
|||||||
|
|
||||||
// service 代码
|
// service 代码
|
||||||
const service = await code.setContent("Service 服务层", "node-service", {
|
const service = await code.setContent("Service 服务层", "node-service", {
|
||||||
...entityData
|
...entityData,
|
||||||
|
entity
|
||||||
});
|
});
|
||||||
|
|
||||||
code.tips("Service 生成成功,开始解析");
|
code.tips("Service 生成成功,开始解析");
|
||||||
@ -509,6 +515,8 @@ const code = reactive({
|
|||||||
async createVue() {
|
async createVue() {
|
||||||
const item = code.add("Vue 页面", "vue");
|
const item = code.add("Vue 页面", "vue");
|
||||||
|
|
||||||
|
item.content = "";
|
||||||
|
|
||||||
code.data = {
|
code.data = {
|
||||||
router: "",
|
router: "",
|
||||||
prefix: "",
|
prefix: "",
|
||||||
@ -555,13 +563,13 @@ const code = reactive({
|
|||||||
entity: code.getContent("node-entity")
|
entity: code.getContent("node-entity")
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
assign(code.data, res);
|
res.router = res.path.replace("/admin", "");
|
||||||
|
res.prefix = res.path;
|
||||||
|
|
||||||
code.data.router = res.path.replace("/admin", "");
|
assign(code.data, res);
|
||||||
code.data.prefix = res.path;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
code.tips("AI 字段分析中");
|
code.tips("AI 分析字段中");
|
||||||
|
|
||||||
// ai分析
|
// ai分析
|
||||||
await ai.matchType({ columns: code.data.columns, name: form.entity });
|
await ai.matchType({ columns: code.data.columns, name: form.entity });
|
||||||
@ -569,25 +577,30 @@ const code = reactive({
|
|||||||
// 生成内容
|
// 生成内容
|
||||||
item.content = menu.createVue(code.data);
|
item.content = menu.createVue(code.data);
|
||||||
|
|
||||||
code.tips("Vue 生成成功");
|
|
||||||
|
|
||||||
await sleep(300);
|
await sleep(300);
|
||||||
|
|
||||||
// 格式化
|
// 格式化
|
||||||
refs.editor.formatCode();
|
refs.editor.formatCode();
|
||||||
|
|
||||||
|
code.tips("Vue 生成成功");
|
||||||
},
|
},
|
||||||
|
|
||||||
// 添加 tab
|
// 添加 tab
|
||||||
add(label: string, flow: string) {
|
add(label: string, flow: string) {
|
||||||
const item = reactive<CodeItem>({
|
let item = code.list.find((e) => e.value == flow);
|
||||||
label,
|
|
||||||
value: flow,
|
if (!item) {
|
||||||
content: "",
|
item = reactive<CodeItem>({
|
||||||
_content: ""
|
label,
|
||||||
});
|
value: flow,
|
||||||
|
content: "",
|
||||||
|
_content: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
code.list.push(item);
|
||||||
|
}
|
||||||
|
|
||||||
code.active = flow;
|
code.active = flow;
|
||||||
code.list.push(item);
|
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
},
|
},
|
||||||
@ -628,6 +641,11 @@ const code = reactive({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
|
if (step.value != "coding") {
|
||||||
|
clearInterval(timer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const v = item._content[item.content.length] || "";
|
const v = item._content[item.content.length] || "";
|
||||||
|
|
||||||
if (isEnd) {
|
if (isEnd) {
|
||||||
@ -642,18 +660,27 @@ const code = reactive({
|
|||||||
|
|
||||||
// 滚动到底
|
// 滚动到底
|
||||||
if (flow == code.active) {
|
if (flow == code.active) {
|
||||||
refs.editor.revealLine(99999);
|
refs.editor?.revealLine(99999);
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 复制
|
||||||
copy() {
|
copy() {
|
||||||
copy(code.getContent(code.active)!);
|
copy(code.getContent(code.active)!);
|
||||||
code.save();
|
code.save();
|
||||||
ElMessage.success("复制成功");
|
ElMessage.success("复制成功");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 重新生成
|
||||||
|
async refresh() {
|
||||||
|
code.loading = true;
|
||||||
|
await code.createVue();
|
||||||
|
code.loading = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
// 保存
|
||||||
save() {
|
save() {
|
||||||
storage.set("ai-code.list", code.list);
|
storage.set("ai-code.list", code.list);
|
||||||
storage.set("ai-code.data", code.data);
|
storage.set("ai-code.data", code.data);
|
||||||
@ -1301,11 +1328,9 @@ $color: #41d1ff;
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
animation: coding 0.3s forwards;
|
animation: coding 0.3s forwards;
|
||||||
border-top: 5px solid rgba(255, 255, 255, 0.1);
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
transform: translateY(10vh);
|
|
||||||
|
|
||||||
.editor {
|
.editor {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -1363,7 +1388,7 @@ $color: #41d1ff;
|
|||||||
height: 30px;
|
height: 30px;
|
||||||
width: 30px;
|
width: 30px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 18px;
|
font-size: 15px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
|
||||||
@ -1382,6 +1407,7 @@ $color: #41d1ff;
|
|||||||
height: 150px;
|
height: 150px;
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
border-top: 1px solid #2f3447;
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
Loading…
Reference in New Issue
Block a user