作者 RuoYi

代码生成预览支持高亮显示

@@ -44,6 +44,7 @@ @@ -44,6 +44,7 @@
44 "element-ui": "2.14.1", 44 "element-ui": "2.14.1",
45 "file-saver": "2.0.4", 45 "file-saver": "2.0.4",
46 "fuse.js": "6.4.3", 46 "fuse.js": "6.4.3",
  47 + "highlight.js": "10.4.1",
47 "js-beautify": "1.13.0", 48 "js-beautify": "1.13.0",
48 "js-cookie": "2.2.1", 49 "js-cookie": "2.2.1",
49 "jsencrypt": "3.0.0-rc.1", 50 "jsencrypt": "3.0.0-rc.1",
@@ -18,8 +18,11 @@ import { getDicts } from "@/api/system/dict/data"; @@ -18,8 +18,11 @@ import { getDicts } from "@/api/system/dict/data";
18 import { getConfigKey } from "@/api/system/config"; 18 import { getConfigKey } from "@/api/system/config";
19 import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi"; 19 import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi";
20 import Pagination from "@/components/Pagination"; 20 import Pagination from "@/components/Pagination";
21 -//自定义表格工具扩展 21 +// 自定义表格工具扩展
22 import RightToolbar from "@/components/RightToolbar" 22 import RightToolbar from "@/components/RightToolbar"
  23 +// 代码高亮插件
  24 +import hljs from 'highlight.js'
  25 +import 'highlight.js/styles/github-gist.css'
23 26
24 // 全局方法挂载 27 // 全局方法挂载
25 Vue.prototype.getDicts = getDicts 28 Vue.prototype.getDicts = getDicts
@@ -49,6 +52,7 @@ Vue.component('Pagination', Pagination) @@ -49,6 +52,7 @@ Vue.component('Pagination', Pagination)
49 Vue.component('RightToolbar', RightToolbar) 52 Vue.component('RightToolbar', RightToolbar)
50 53
51 Vue.use(permission) 54 Vue.use(permission)
  55 +Vue.use(hljs.vuePlugin);
52 56
53 /** 57 /**
54 * If you don't want to use mock-server 58 * If you don't want to use mock-server
@@ -165,7 +165,7 @@ @@ -165,7 +165,7 @@
165 :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))" 165 :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
166 :key="key" 166 :key="key"
167 > 167 >
168 - <pre>{{ value }}</pre> 168 + <highlightjs autodetect :code="value" />
169 </el-tab-pane> 169 </el-tab-pane>
170 </el-tabs> 170 </el-tabs>
171 </el-dialog> 171 </el-dialog>
@@ -177,6 +177,7 @@ @@ -177,6 +177,7 @@
177 import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; 177 import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
178 import importTable from "./importTable"; 178 import importTable from "./importTable";
179 import { downLoadZip } from "@/utils/zipdownload"; 179 import { downLoadZip } from "@/utils/zipdownload";
  180 +
180 export default { 181 export default {
181 name: "Gen", 182 name: "Gen",
182 components: { importTable }, 183 components: { importTable },