作者 RuoYi

修复IE11浏览器报错问题

@@ -44,7 +44,7 @@ @@ -44,7 +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 + "highlight.js": "9.18.5",
48 "js-beautify": "1.13.0", 48 "js-beautify": "1.13.0",
49 "js-cookie": "2.2.1", 49 "js-cookie": "2.2.1",
50 "jsencrypt": "3.0.0-rc.1", 50 "jsencrypt": "3.0.0-rc.1",
@@ -69,8 +69,8 @@ @@ -69,8 +69,8 @@
69 "eslint": "7.15.0", 69 "eslint": "7.15.0",
70 "eslint-plugin-vue": "7.2.0", 70 "eslint-plugin-vue": "7.2.0",
71 "lint-staged": "10.5.3", 71 "lint-staged": "10.5.3",
72 - "sass": "1.30.0",  
73 "runjs": "4.4.2", 72 "runjs": "4.4.2",
  73 + "sass": "1.32.0",
74 "sass-loader": "10.1.0", 74 "sass-loader": "10.1.0",
75 "script-ext-html-webpack-plugin": "2.1.5", 75 "script-ext-html-webpack-plugin": "2.1.5",
76 "svg-sprite-loader": "5.1.1", 76 "svg-sprite-loader": "5.1.1",
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 <script> 20 <script>
21 // fuse is a lightweight fuzzy-search module 21 // fuse is a lightweight fuzzy-search module
22 // make search results more in line with expectations 22 // make search results more in line with expectations
23 -import Fuse from 'fuse.js' 23 +import Fuse from 'fuse.js/dist/fuse.min.js'
24 import path from 'path' 24 import path from 'path'
25 25
26 export default { 26 export default {
@@ -20,9 +20,6 @@ import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, @@ -20,9 +20,6 @@ import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels,
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'  
26 23
27 // 全局方法挂载 24 // 全局方法挂载
28 Vue.prototype.getDicts = getDicts 25 Vue.prototype.getDicts = getDicts
@@ -52,7 +49,6 @@ Vue.component('Pagination', Pagination) @@ -52,7 +49,6 @@ Vue.component('Pagination', Pagination)
52 Vue.component('RightToolbar', RightToolbar) 49 Vue.component('RightToolbar', RightToolbar)
53 50
54 Vue.use(permission) 51 Vue.use(permission)
55 -Vue.use(hljs.vuePlugin);  
56 52
57 /** 53 /**
58 * If you don't want to use mock-server 54 * If you don't want to use mock-server
@@ -169,7 +169,7 @@ @@ -169,7 +169,7 @@
169 :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))" 169 :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
170 :key="key" 170 :key="key"
171 > 171 >
172 - <highlightjs autodetect :code="value" /> 172 + <pre><code class="hljs" v-html="highlightedCode(value, key)"></code></pre>
173 </el-tab-pane> 173 </el-tab-pane>
174 </el-tabs> 174 </el-tabs>
175 </el-dialog> 175 </el-dialog>
@@ -181,6 +181,14 @@ @@ -181,6 +181,14 @@
181 import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; 181 import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
182 import importTable from "./importTable"; 182 import importTable from "./importTable";
183 import { downLoadZip } from "@/utils/zipdownload"; 183 import { downLoadZip } from "@/utils/zipdownload";
  184 +import hljs from "highlight.js/lib/highlight";
  185 +import "highlight.js/styles/github-gist.css";
  186 +hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
  187 +hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml"));
  188 +hljs.registerLanguage("html", require("highlight.js/lib/languages/xml"));
  189 +hljs.registerLanguage("vue", require("highlight.js/lib/languages/xml"));
  190 +hljs.registerLanguage("javascript", require("highlight.js/lib/languages/javascript"));
  191 +hljs.registerLanguage("sql", require("highlight.js/lib/languages/sql"));
184 192
185 export default { 193 export default {
186 name: "Gen", 194 name: "Gen",
@@ -294,6 +302,13 @@ export default { @@ -294,6 +302,13 @@ export default {
294 this.preview.open = true; 302 this.preview.open = true;
295 }); 303 });
296 }, 304 },
  305 + /** 高亮显示 */
  306 + highlightedCode(code, key) {
  307 + const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"));
  308 + var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
  309 + const result = hljs.highlight(language, code || "", true);
  310 + return result.value || '&nbsp;';
  311 + },
297 // 多选框选中数据 312 // 多选框选中数据
298 handleSelectionChange(selection) { 313 handleSelectionChange(selection) {
299 this.ids = selection.map(item => item.tableId); 314 this.ids = selection.map(item => item.tableId);