@@ -140,3 +140,22 @@ export const pubPlug = (params) => {
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export const llmAuto = (params) => {
|
||||
let modeName = {
|
||||
"xiaoqi": "小奇",
|
||||
"xiaomiao": "小淼",
|
||||
}
|
||||
return service({
|
||||
url: '/autoCode/llmAuto',
|
||||
method: 'post',
|
||||
params,
|
||||
timeout: 1000 * 60 * 10,
|
||||
loadingOption:{
|
||||
lock: true,
|
||||
fullscreen:true,
|
||||
text: `${modeName[params.mode]}正在思考,请稍候...`,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg t="1718869075082" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="13564" width="200" height="200"><path d="M274.344554 173.673875c16.429399 0 30.950568 8.00526 39.956484 20.338945a34.906655 34.906655 0 0 1 14.660796 15.754537l1.117013 2.815803 210.138065 597.927736c6.795162 19.268474-5.329083 40.817516-27.041022 48.147913-20.641469 6.95806-42.493035-1.419537-50.451753-18.803052l-1.117013-2.815803-54.477653-154.939008H134.997185L80.566074 837.039954c-6.771891 19.268474-29.856826 28.949253-51.568765 21.618855-20.641469-6.981331-32.602816-26.761769-27.925325-45.239025l0.861031-2.908888L212.047809 212.58316c4.025901-11.426112 13.799764-19.477914 25.598214-22.619512 9.029188-10.006575 22.107548-16.289773 36.67526-16.289773z m386.416675 169.460176c21.828295 0 39.723774 10.890876 41.469106 24.713912l0.116356 2.210755v461.652153c0 14.893506-18.616883 26.947938-41.585462 26.947938-21.805024 0-39.700503-10.890876-41.422565-24.737183l-0.162897-2.210755V370.081989c0-14.870235 18.616883-26.924667 41.585462-26.924667z m-389.697901-48.171184L163.620643 600.628812h214.88537l-107.442685-305.665945z m602.163076-206.181978a12.566396 12.566396 0 0 1 8.144887 8.051802l32.509731 99.041817 101.694723 36.07021a12.566396 12.566396 0 0 1-0.791218 23.922695l-99.53051 27.995137-30.857483 97.552467a12.566396 12.566396 0 0 1-23.899423 0.116355l-32.509732-99.018546-98.669479-31.322905a12.566396 12.566396 0 0 1-0.186169-23.876152l97.505924-32.812256 30.834212-97.529195a12.566396 12.566396 0 0 1 15.754537-8.191429zM649.544557 0.513593c2.676177 0.884302 4.770576 3.025243 5.608336 5.724692l18.523798 59.294772 60.970292 20.66474a8.796477 8.796477 0 0 1-0.325796 16.755194l-60.73758 18.058377-19.780438 59.550754a8.796477 8.796477 0 0 1-16.731924-0.162898l-18.523798-59.271501-59.062061-17.825665a8.796477 8.796477 0 0 1-0.395609-16.708653l59.574025-20.943993 19.780438-59.574025a8.796477 8.796477 0 0 1 11.100317-5.561794z" p-id="13565"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
@@ -2,8 +2,33 @@
|
||||
<div>
|
||||
<warning-bar
|
||||
href="https://www.bilibili.com/video/BV1kv4y1g7nT?p=3"
|
||||
title="此功能为开发环境使用,不建议发布到生产,具体使用效果请点我观看。页面数据内容会自动暂存,如需清除,请点击【清除缓存】"
|
||||
title="此功能为开发环境使用,不建议发布到生产,具体使用效果请点我观看。"
|
||||
/>
|
||||
<div class="gva-search-box">
|
||||
<div class="relative">
|
||||
<el-input v-model="prompt" type="textarea" :rows="5" :placeholder="`【Beta】试试描述你的表,让AI帮你完成。\n目前正在测试阶段,遇到问题请及时反馈。\n此功能需要到插件市场个人中心获取自己的AI-Path,把AI-Path填入config.yaml下的autocode-->ai-path,重启项目即可使用。`" resize="none" />
|
||||
<div class="flex absolute right-2 bottom-2">
|
||||
<el-tooltip
|
||||
content="小奇存在失败概率,面向所有用户开放使用(失败了重新生成一下就好)。"
|
||||
>
|
||||
<el-button type="primary" @click="llmAutoFunc('xiaoqi')">
|
||||
<el-icon size="18">
|
||||
<ai-gva />
|
||||
</el-icon> 小奇
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip
|
||||
content="小淼基本啥也能设计出来,但是需要消耗积分,测试阶段授权用户自动获得基础积分,开源用户需要填表申请。"
|
||||
>
|
||||
<el-button type="primary" @click="llmAutoFunc('xiaomiao')">
|
||||
<el-icon size="18">
|
||||
<ai-gva />
|
||||
</el-icon> 小淼
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 从数据库直接获取字段 -->
|
||||
<div class="gva-search-box">
|
||||
<el-collapse
|
||||
@@ -100,21 +125,13 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="getColumnFunc"
|
||||
>使用此表创建</el-button>
|
||||
>
|
||||
使用此表创建
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
<div class="flex justify-end">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="clearCatch()"
|
||||
>清除暂存</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="catchData()"
|
||||
>暂存</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gva-search-box">
|
||||
<!-- 初始版本自动化代码工具 -->
|
||||
@@ -204,11 +221,15 @@
|
||||
<el-icon
|
||||
class="cursor-pointer ml-2 text-gray-600"
|
||||
@click="getPkgs"
|
||||
><refresh /></el-icon>
|
||||
>
|
||||
<refresh />
|
||||
</el-icon>
|
||||
<el-icon
|
||||
class="cursor-pointer ml-2 text-gray-600"
|
||||
@click="goPkgs"
|
||||
><document-add /></el-icon>
|
||||
>
|
||||
<document-add />
|
||||
</el-icon>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="业务库"
|
||||
@@ -296,9 +317,9 @@
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<el-tooltip
|
||||
content="注:自动同步数据库表结构,如果不需要可以选择关闭。"
|
||||
placement="bottom"
|
||||
effect="light"
|
||||
content="注:自动同步数据库表结构,如果不需要可以选择关闭。"
|
||||
placement="bottom"
|
||||
effect="light"
|
||||
>
|
||||
<div> 同步表结构 <el-icon><QuestionFilled /></el-icon></div>
|
||||
</el-tooltip>
|
||||
@@ -314,7 +335,9 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="editAndAddField()"
|
||||
>新增字段</el-button>
|
||||
>
|
||||
新增字段
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="draggable">
|
||||
<el-table
|
||||
@@ -384,21 +407,27 @@
|
||||
prop="require"
|
||||
label="必填"
|
||||
>
|
||||
<template #default="{row}"> <el-checkbox v-model="row.require" /></template>
|
||||
<template #default="{row}">
|
||||
<el-checkbox v-model="row.require" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="left"
|
||||
prop="sort"
|
||||
label="排序"
|
||||
>
|
||||
<template #default="{row}"> <el-checkbox v-model="row.sort" /> </template>
|
||||
<template #default="{row}">
|
||||
<el-checkbox v-model="row.sort" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="left"
|
||||
prop="front"
|
||||
label="前端可见"
|
||||
>
|
||||
<template #default="{row}"> <el-checkbox v-model="row.front" /> </template>
|
||||
<template #default="{row}">
|
||||
<el-checkbox v-model="row.front" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="left"
|
||||
@@ -433,23 +462,23 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="left"
|
||||
prop="fieldIndexType"
|
||||
label="索引类型"
|
||||
width="160"
|
||||
align="left"
|
||||
prop="fieldIndexType"
|
||||
label="索引类型"
|
||||
width="160"
|
||||
>
|
||||
<template #default="{row}">
|
||||
<el-select
|
||||
v-model="row.fieldIndexType"
|
||||
style="width:100%"
|
||||
placeholder="请选择字段索引类型"
|
||||
clearable
|
||||
v-model="row.fieldIndexType"
|
||||
style="width:100%"
|
||||
placeholder="请选择字段索引类型"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="item in typeIndexOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
v-for="item in typeIndexOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
@@ -510,7 +539,6 @@
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="left"
|
||||
@@ -525,27 +553,47 @@
|
||||
link
|
||||
icon="edit"
|
||||
@click="editAndAddField(scope.row)"
|
||||
>高级编辑</el-button>
|
||||
>
|
||||
高级编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
icon="delete"
|
||||
@click="deleteField(scope.$index)"
|
||||
>删除</el-button>
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<!-- 组件列表 -->
|
||||
<div class="gva-btn-list justify-end mt-4">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="clearCatch()"
|
||||
>
|
||||
清除暂存
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="catchData()"
|
||||
>
|
||||
暂存
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="enterForm(true)"
|
||||
>预览代码</el-button>
|
||||
>
|
||||
预览代码
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="enterForm(false)"
|
||||
>生成代码</el-button>
|
||||
>
|
||||
生成代码
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 组件弹窗 -->
|
||||
@@ -558,11 +606,15 @@
|
||||
<div class="flex justify-between items-center">
|
||||
<span class="text-lg">组件内容</span>
|
||||
<div>
|
||||
<el-button @click="closeDialog">取 消</el-button>
|
||||
<el-button @click="closeDialog">
|
||||
取 消
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="enterDialog"
|
||||
>确 定</el-button>
|
||||
>
|
||||
确 定
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -575,7 +627,6 @@
|
||||
:type-search-options="typeSearchOptions"
|
||||
:type-index-options="typeIndexOptions"
|
||||
/>
|
||||
|
||||
</el-drawer>
|
||||
|
||||
<el-drawer
|
||||
@@ -583,7 +634,6 @@
|
||||
size="60%"
|
||||
:show-close="false"
|
||||
>
|
||||
|
||||
<template #header>
|
||||
<div class="flex justify-between items-center">
|
||||
<span class="text-lg">操作栏</span>
|
||||
@@ -591,11 +641,15 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="selectText"
|
||||
>全选</el-button>
|
||||
>
|
||||
全选
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="copy"
|
||||
>复制</el-button>
|
||||
>
|
||||
复制
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -613,7 +667,7 @@
|
||||
import FieldDialog from '@/view/systemTools/autoCode/component/fieldDialog.vue'
|
||||
import PreviewCodeDialog from '@/view/systemTools/autoCode/component/previewCodeDialg.vue'
|
||||
import { toUpperCase, toHump, toSQLLine, toLowerCase } from '@/utils/stringFun'
|
||||
import { createTemp, getDB, getTable, getColumn, preview, getMeta, getPackageApi } from '@/api/autoCode'
|
||||
import { createTemp, getDB, getTable, getColumn, preview, getMeta, getPackageApi,llmAuto } from '@/api/autoCode'
|
||||
import { getDict } from '@/utils/dictionary'
|
||||
import { ref, reactive, watch, toRaw, onMounted, nextTick } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
@@ -621,6 +675,53 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import WarningBar from '@/components/warningBar/warningBar.vue'
|
||||
import Sortable from 'sortablejs'
|
||||
|
||||
const prompt = ref("")
|
||||
|
||||
const llmAutoFunc = async (mode) =>{
|
||||
const res = await llmAuto({prompt:prompt.value,mode:mode})
|
||||
if (res.code === 0) {
|
||||
form.value.fields = []
|
||||
const json = JSON.parse(res.data)
|
||||
for (let key in json){
|
||||
if(key === "fields"){
|
||||
json[key].forEach(item => {
|
||||
if (item.primaryKey) {
|
||||
form.value.gvaModel = false
|
||||
}
|
||||
form.value.fields.push({
|
||||
fieldName: toUpperCase(item.fieldName),
|
||||
fieldDesc: item.fieldDesc,
|
||||
fieldType: item.fieldType,
|
||||
dataType: "",
|
||||
fieldJson: item.fieldJson||item.columnName,
|
||||
primaryKey: item.primaryKey,
|
||||
dataTypeLong: item.dataTypeLong,
|
||||
columnName: item.columnName,
|
||||
comment: item.comment || item.fieldDesc,
|
||||
require: false,
|
||||
errorText: '',
|
||||
clearable: true,
|
||||
fieldSearchType: '',
|
||||
fieldIndexType: '',
|
||||
dictType: '',
|
||||
front: true,
|
||||
dataSource: {
|
||||
association:1,
|
||||
table: '',
|
||||
label: '',
|
||||
value: ''
|
||||
}
|
||||
})
|
||||
})
|
||||
}else{
|
||||
if(mode === "xiaomiao"){
|
||||
form.value[key] = json[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 行拖拽
|
||||
const rowDrop = () => {
|
||||
// 要拖拽元素的父容器
|
||||
@@ -1009,6 +1110,7 @@ const getColumnFunc = async() => {
|
||||
const dbraw = toRaw(dbtmp)
|
||||
dbtype = dbraw.dbtype
|
||||
}
|
||||
form.value.gvaModel = false
|
||||
const tbHump = toHump(dbform.value.tableName)
|
||||
form.value.structName = toUpperCase(tbHump)
|
||||
form.value.tableName = dbform.value.tableName
|
||||
|
||||
Reference in New Issue
Block a user