mirror of
https://gitcode.com/flipped-aurora/gin-vue-admin.git
synced 2026-05-20 06:07:58 +00:00
initdb默认string长度改为191
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div class="previewCode">
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane :label="key" :name="key" v-for="(item,key) in previewCode" :key="key">
|
||||
<div style="background:#fff;padding:0 20px" :id="key"></div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import marked from "marked"
|
||||
import hljs from "highlight.js";
|
||||
// import 'highlight.js/styles/atelier-cave-light.css';
|
||||
import 'highlight.js/styles/atelier-plateau-light.css';
|
||||
export default {
|
||||
props:{
|
||||
previewCode:{
|
||||
type:Object,
|
||||
default(){
|
||||
return {}
|
||||
}
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return{
|
||||
activeName: "",
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
marked.setOptions({
|
||||
renderer: new marked.Renderer(),
|
||||
highlight: function(code) {
|
||||
return hljs.highlightAuto(code).value;
|
||||
},
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
tables: true,
|
||||
breaks: false,
|
||||
sanitize: false,
|
||||
smartLists: true,
|
||||
smartypants: false,
|
||||
xhtml: false
|
||||
}
|
||||
);
|
||||
for(const key in this.previewCode){
|
||||
if(this.activeName == ""){
|
||||
this.activeName = key
|
||||
}
|
||||
document.getElementById(key).innerHTML = marked(this.previewCode[key])
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
@@ -58,7 +58,7 @@
|
||||
<el-input v-model="form.description" placeholder="中文描述作为自动api描述"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="文件名称" prop="packageName">
|
||||
<el-input v-model="form.packageName"></el-input>
|
||||
<el-input v-model="form.packageName" placeholder="生成文件的默认名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="自动创建api">
|
||||
<el-checkbox v-model="form.autoCreateApiToSql"></el-checkbox>
|
||||
@@ -117,6 +117,7 @@
|
||||
<el-tag type="danger">id , created_at , updated_at , deleted_at 会自动生成请勿重复创建</el-tag>
|
||||
<!-- 组件列表 -->
|
||||
<div class="button-box clearflex">
|
||||
<el-button @click="enterForm(true)" type="primary">预览代码</el-button>
|
||||
<el-button @click="enterForm" type="primary">生成代码</el-button>
|
||||
</div>
|
||||
<!-- 组件弹窗 -->
|
||||
@@ -127,6 +128,13 @@
|
||||
<el-button type="primary" @click="enterDialog">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :visible.sync="previewFlag">
|
||||
<PreviewCodeDialg v-if="previewFlag" :previewCode="preViewCode"></PreviewCodeDialg>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="previewFlag = false">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@@ -144,8 +152,9 @@ const fieldTemplate = {
|
||||
};
|
||||
|
||||
import FieldDialog from "@/view/systemTools/autoCode/component/fieldDialog.vue";
|
||||
import PreviewCodeDialg from "@/view/systemTools/autoCode/component/previewCodeDialg.vue";
|
||||
import { toUpperCase, toHump } from "@/utils/stringFun.js";
|
||||
import { createTemp, getDB, getTable, getColumn } from "@/api/autoCode.js";
|
||||
import { createTemp, getDB, getTable, getColumn, preview } from "@/api/autoCode.js";
|
||||
import { getDict } from "@/utils/dictionary";
|
||||
|
||||
export default {
|
||||
@@ -153,6 +162,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
activeNames: [""],
|
||||
preViewCode:{},
|
||||
dbform: {
|
||||
dbName: "",
|
||||
tableName: ""
|
||||
@@ -191,11 +201,13 @@ export default {
|
||||
},
|
||||
dialogMiddle: {},
|
||||
bk: {},
|
||||
dialogFlag: false
|
||||
dialogFlag: false,
|
||||
previewFlag:false
|
||||
};
|
||||
},
|
||||
components: {
|
||||
FieldDialog
|
||||
FieldDialog,
|
||||
PreviewCodeDialg
|
||||
},
|
||||
methods: {
|
||||
editAndAddField(item) {
|
||||
@@ -250,7 +262,7 @@ export default {
|
||||
deleteField(index) {
|
||||
this.form.fields.splice(index, 1);
|
||||
},
|
||||
async enterForm() {
|
||||
async enterForm(isPreview) {
|
||||
if (this.form.fields.length <= 0) {
|
||||
this.$message({
|
||||
type: "error",
|
||||
@@ -277,31 +289,38 @@ export default {
|
||||
});
|
||||
return false;
|
||||
}
|
||||
const data = await createTemp(this.form);
|
||||
if (data.headers?.success == "false") {
|
||||
return;
|
||||
} else {
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "自动化代码创建成功,正在下载"
|
||||
});
|
||||
}
|
||||
const blob = new Blob([data]);
|
||||
const fileName = "ginvueadmin.zip";
|
||||
if ("download" in document.createElement("a")) {
|
||||
// 不是IE浏览器
|
||||
let url = window.URL.createObjectURL(blob);
|
||||
let link = document.createElement("a");
|
||||
link.style.display = "none";
|
||||
link.href = url;
|
||||
link.setAttribute("download", fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link); // 下载完成移除元素
|
||||
window.URL.revokeObjectURL(url); // 释放掉blob对象
|
||||
} else {
|
||||
// IE 10+
|
||||
window.navigator.msSaveBlob(blob, fileName);
|
||||
if(isPreview){
|
||||
const data = await preview(this.form);
|
||||
console.log(data.code == 0)
|
||||
this.preViewCode = data.data.autoCode
|
||||
this.previewFlag = true
|
||||
}else{
|
||||
const data = await createTemp(this.form);
|
||||
if (data.headers?.success == "false") {
|
||||
return;
|
||||
} else {
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "自动化代码创建成功,正在下载"
|
||||
});
|
||||
}
|
||||
const blob = new Blob([data]);
|
||||
const fileName = "ginvueadmin.zip";
|
||||
if ("download" in document.createElement("a")) {
|
||||
// 不是IE浏览器
|
||||
let url = window.URL.createObjectURL(blob);
|
||||
let link = document.createElement("a");
|
||||
link.style.display = "none";
|
||||
link.href = url;
|
||||
link.setAttribute("download", fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link); // 下载完成移除元素
|
||||
window.URL.revokeObjectURL(url); // 释放掉blob对象
|
||||
} else {
|
||||
// IE 10+
|
||||
window.navigator.msSaveBlob(blob, fileName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
@@ -373,6 +392,7 @@ export default {
|
||||
.button-box {
|
||||
padding: 10px 20px;
|
||||
.el-button {
|
||||
margin-right: 20px;
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user