mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
升级 highlight 插件的版本
This commit is contained in:
parent
45d203550f
commit
b04db3d6d8
@ -44,7 +44,7 @@
|
|||||||
"element-ui": "2.14.1",
|
"element-ui": "2.14.1",
|
||||||
"file-saver": "2.0.4",
|
"file-saver": "2.0.4",
|
||||||
"fuse.js": "6.4.3",
|
"fuse.js": "6.4.3",
|
||||||
"highlight.js": "10.4.1",
|
"highlight.js": "9.18.5",
|
||||||
"js-beautify": "1.13.0",
|
"js-beautify": "1.13.0",
|
||||||
"js-cookie": "2.2.1",
|
"js-cookie": "2.2.1",
|
||||||
"jsencrypt": "3.0.0-rc.1",
|
"jsencrypt": "3.0.0-rc.1",
|
||||||
|
2
ruoyi-ui/src/api/tool/codegen.js
Normal file
2
ruoyi-ui/src/api/tool/codegen.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
@ -21,8 +21,8 @@ import Pagination from "@/components/Pagination";
|
|||||||
// 自定义表格工具扩展
|
// 自定义表格工具扩展
|
||||||
import RightToolbar from "@/components/RightToolbar"
|
import RightToolbar from "@/components/RightToolbar"
|
||||||
// 代码高亮插件
|
// 代码高亮插件
|
||||||
import hljs from 'highlight.js'
|
// import hljs from 'highlight.js'
|
||||||
import 'highlight.js/styles/github-gist.css'
|
// import 'highlight.js/styles/github-gist.css'
|
||||||
import {DICT_TYPE, getDictDataLabel, getDictDatas} from "@/utils/dict";
|
import {DICT_TYPE, getDictDataLabel, getDictDatas} from "@/utils/dict";
|
||||||
|
|
||||||
// 全局方法挂载
|
// 全局方法挂载
|
||||||
@ -57,7 +57,7 @@ Vue.component('Pagination', Pagination)
|
|||||||
Vue.component('RightToolbar', RightToolbar)
|
Vue.component('RightToolbar', RightToolbar)
|
||||||
|
|
||||||
Vue.use(permission)
|
Vue.use(permission)
|
||||||
Vue.use(hljs.vuePlugin);
|
// Vue.use(hljs.vuePlugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If you don't want to use mock-server
|
* If you don't want to use mock-server
|
||||||
|
@ -90,7 +90,8 @@
|
|||||||
<el-option label="单选框" value="radio" />
|
<el-option label="单选框" value="radio" />
|
||||||
<el-option label="复选框" value="checkbox" />
|
<el-option label="复选框" value="checkbox" />
|
||||||
<el-option label="日期控件" value="datetime" />
|
<el-option label="日期控件" value="datetime" />
|
||||||
<el-option label="上传控件" value="uploadImage" />
|
<el-option label="图片上传" value="imageUpload" />
|
||||||
|
<el-option label="文件上传" value="fileUpload" />
|
||||||
<el-option label="富文本控件" value="editor" />
|
<el-option label="富文本控件" value="editor" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
@ -112,7 +113,7 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="生成信息" name="genInfo">
|
<el-tab-pane label="生成信息" name="genInfo">
|
||||||
<gen-info-form ref="genInfo" :info="info" :menus="menus"/>
|
<gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
<el-form label-width="100px">
|
<el-form label-width="100px">
|
||||||
@ -143,6 +144,8 @@ export default {
|
|||||||
activeName: "cloum",
|
activeName: "cloum",
|
||||||
// 表格的高度
|
// 表格的高度
|
||||||
tableHeight: document.documentElement.scrollHeight - 245 + "px",
|
tableHeight: document.documentElement.scrollHeight - 245 + "px",
|
||||||
|
// 表信息
|
||||||
|
tables: [],
|
||||||
// 表列信息
|
// 表列信息
|
||||||
cloumns: [],
|
cloumns: [],
|
||||||
// 字典信息
|
// 字典信息
|
||||||
@ -160,6 +163,7 @@ export default {
|
|||||||
getGenTable(tableId).then(res => {
|
getGenTable(tableId).then(res => {
|
||||||
this.cloumns = res.data.rows;
|
this.cloumns = res.data.rows;
|
||||||
this.info = res.data.info;
|
this.info = res.data.info;
|
||||||
|
this.tables = res.data.tables;
|
||||||
});
|
});
|
||||||
/** 查询字典下拉列表 */
|
/** 查询字典下拉列表 */
|
||||||
getDictOptionselect().then(response => {
|
getDictOptionselect().then(response => {
|
||||||
@ -167,7 +171,7 @@ export default {
|
|||||||
});
|
});
|
||||||
/** 查询菜单下拉列表 */
|
/** 查询菜单下拉列表 */
|
||||||
getMenuTreeselect().then(response => {
|
getMenuTreeselect().then(response => {
|
||||||
this.menus = this.handleTree(response.data, "id");
|
this.menus = this.handleTree(response.data, "menuId");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -4,9 +4,10 @@
|
|||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item prop="tplCategory">
|
<el-form-item prop="tplCategory">
|
||||||
<span slot="label">生成模板</span>
|
<span slot="label">生成模板</span>
|
||||||
<el-select v-model="info.tplCategory">
|
<el-select v-model="info.tplCategory" @change="tplSelectChange">
|
||||||
<el-option label="单表(增删改查)" value="crud" />
|
<el-option label="单表(增删改查)" value="crud" />
|
||||||
<el-option label="树表(增删改查)" value="tree" />
|
<el-option label="树表(增删改查)" value="tree" />
|
||||||
|
<el-option label="主子表(增删改查)" value="sub" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -126,8 +127,8 @@
|
|||||||
</span>
|
</span>
|
||||||
<el-select v-model="info.treeCode" placeholder="请选择">
|
<el-select v-model="info.treeCode" placeholder="请选择">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="column in info.columns"
|
v-for="(column, index) in info.columns"
|
||||||
:key="column.columnName"
|
:key="index"
|
||||||
:label="column.columnName + ':' + column.columnComment"
|
:label="column.columnName + ':' + column.columnComment"
|
||||||
:value="column.columnName"
|
:value="column.columnName"
|
||||||
></el-option>
|
></el-option>
|
||||||
@ -144,8 +145,8 @@
|
|||||||
</span>
|
</span>
|
||||||
<el-select v-model="info.treeParentCode" placeholder="请选择">
|
<el-select v-model="info.treeParentCode" placeholder="请选择">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="column in info.columns"
|
v-for="(column, index) in info.columns"
|
||||||
:key="column.columnName"
|
:key="index"
|
||||||
:label="column.columnName + ':' + column.columnComment"
|
:label="column.columnName + ':' + column.columnComment"
|
||||||
:value="column.columnName"
|
:value="column.columnName"
|
||||||
></el-option>
|
></el-option>
|
||||||
@ -162,8 +163,47 @@
|
|||||||
</span>
|
</span>
|
||||||
<el-select v-model="info.treeName" placeholder="请选择">
|
<el-select v-model="info.treeName" placeholder="请选择">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="column in info.columns"
|
v-for="(column, index) in info.columns"
|
||||||
:key="column.columnName"
|
:key="index"
|
||||||
|
:label="column.columnName + ':' + column.columnComment"
|
||||||
|
:value="column.columnName"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row v-show="info.tplCategory == 'sub'">
|
||||||
|
<h4 class="form-header">关联信息</h4>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item>
|
||||||
|
<span slot="label">
|
||||||
|
关联子表的表名
|
||||||
|
<el-tooltip content="关联子表的表名, 如:sys_user" placement="top">
|
||||||
|
<i class="el-icon-question"></i>
|
||||||
|
</el-tooltip>
|
||||||
|
</span>
|
||||||
|
<el-select v-model="info.subTableName" placeholder="请选择" @change="subSelectChange">
|
||||||
|
<el-option
|
||||||
|
v-for="(table, index) in tables"
|
||||||
|
:key="index"
|
||||||
|
:label="table.tableName + ':' + table.tableComment"
|
||||||
|
:value="table.tableName"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item>
|
||||||
|
<span slot="label">
|
||||||
|
子表关联的外键名
|
||||||
|
<el-tooltip content="子表关联的外键名, 如:user_id" placement="top">
|
||||||
|
<i class="el-icon-question"></i>
|
||||||
|
</el-tooltip>
|
||||||
|
</span>
|
||||||
|
<el-select v-model="info.subTableFkName" placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="(column, index) in subColumns"
|
||||||
|
:key="index"
|
||||||
:label="column.columnName + ':' + column.columnComment"
|
:label="column.columnName + ':' + column.columnComment"
|
||||||
:value="column.columnName"
|
:value="column.columnName"
|
||||||
></el-option>
|
></el-option>
|
||||||
@ -185,6 +225,10 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
|
tables: {
|
||||||
|
type: Array,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
menus: {
|
menus: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: []
|
default: []
|
||||||
@ -192,6 +236,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
subColumns: [],
|
||||||
rules: {
|
rules: {
|
||||||
tplCategory: [
|
tplCategory: [
|
||||||
{ required: true, message: "请选择生成模板", trigger: "blur" }
|
{ required: true, message: "请选择生成模板", trigger: "blur" }
|
||||||
@ -212,6 +257,11 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {},
|
created() {},
|
||||||
|
watch: {
|
||||||
|
'info.subTableName': function(val) {
|
||||||
|
this.setSubTableColumns(val);
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 转换菜单数据结构 */
|
/** 转换菜单数据结构 */
|
||||||
normalizer(node) {
|
normalizer(node) {
|
||||||
@ -219,10 +269,31 @@ export default {
|
|||||||
delete node.children;
|
delete node.children;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: node.id,
|
id: node.menuId,
|
||||||
label: node.name,
|
label: node.menuName,
|
||||||
children: node.children
|
children: node.children
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
/** 选择子表名触发 */
|
||||||
|
subSelectChange(value) {
|
||||||
|
this.info.subTableFkName = '';
|
||||||
|
},
|
||||||
|
/** 选择生成模板触发 */
|
||||||
|
tplSelectChange(value) {
|
||||||
|
if(value !== 'sub') {
|
||||||
|
this.info.subTableName = '';
|
||||||
|
this.info.subTableFkName = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 设置关联外键 */
|
||||||
|
setSubTableColumns(value) {
|
||||||
|
for (var item in this.tables) {
|
||||||
|
const name = this.tables[item].tableName;
|
||||||
|
if (value === name) {
|
||||||
|
this.subColumns = this.tables[item].columns;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
></el-date-picker>
|
></el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
@ -41,6 +41,7 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
plain
|
||||||
icon="el-icon-download"
|
icon="el-icon-download"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="handleGenTable"
|
@click="handleGenTable"
|
||||||
@ -50,6 +51,7 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="info"
|
type="info"
|
||||||
|
plain
|
||||||
icon="el-icon-upload"
|
icon="el-icon-upload"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="openImportTable"
|
@click="openImportTable"
|
||||||
@ -59,6 +61,7 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="success"
|
type="success"
|
||||||
|
plain
|
||||||
icon="el-icon-edit"
|
icon="el-icon-edit"
|
||||||
size="mini"
|
size="mini"
|
||||||
:disabled="single"
|
:disabled="single"
|
||||||
@ -69,6 +72,7 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
|
plain
|
||||||
icon="el-icon-delete"
|
icon="el-icon-delete"
|
||||||
size="mini"
|
size="mini"
|
||||||
:disabled="multiple"
|
:disabled="multiple"
|
||||||
@ -80,7 +84,7 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55"></el-table-column>
|
<el-table-column type="selection" align="center" width="55"></el-table-column>
|
||||||
<el-table-column label="序号" type="index" width="50" align="center">
|
<el-table-column label="序号" type="index" width="50" align="center">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
|
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
|
||||||
@ -165,7 +169,7 @@
|
|||||||
:name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
:name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
||||||
:key="key"
|
:key="key"
|
||||||
>
|
>
|
||||||
<highlightjs autodetect :code="value" />
|
<pre><code class="hljs" v-html="highlightedCode(value, key)"></code></pre>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@ -177,6 +181,15 @@
|
|||||||
import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
|
import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
|
||||||
import importTable from "./importTable";
|
import importTable from "./importTable";
|
||||||
import { downLoadZip } from "@/utils/zipdownload";
|
import { downLoadZip } from "@/utils/zipdownload";
|
||||||
|
// 代码高亮插件
|
||||||
|
import hljs from "highlight.js/lib/highlight";
|
||||||
|
import "highlight.js/styles/github-gist.css";
|
||||||
|
hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
|
||||||
|
hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml"));
|
||||||
|
hljs.registerLanguage("html", require("highlight.js/lib/languages/xml"));
|
||||||
|
hljs.registerLanguage("vue", require("highlight.js/lib/languages/xml"));
|
||||||
|
hljs.registerLanguage("javascript", require("highlight.js/lib/languages/javascript"));
|
||||||
|
hljs.registerLanguage("sql", require("highlight.js/lib/languages/sql"));
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Gen",
|
name: "Gen",
|
||||||
@ -290,6 +303,13 @@ export default {
|
|||||||
this.preview.open = true;
|
this.preview.open = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/** 高亮显示 */
|
||||||
|
highlightedCode(code, key) {
|
||||||
|
const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"));
|
||||||
|
var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
|
||||||
|
const result = hljs.highlight(language, code || "", true);
|
||||||
|
return result.value || ' ';
|
||||||
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
this.ids = selection.map(item => item.tableId);
|
this.ids = selection.map(item => item.tableId);
|
||||||
@ -318,4 +338,4 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user