Commit ecfe7006e2da521a47a2c4220375cbec68ed0076

Authored by RuoYi
1 parent 9e387dc4

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

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