소스 검색

修复IE11浏览器报错问题

RuoYi 5 년 전
부모
커밋
2b3820223c
4개의 변경된 파일19개의 추가작업 그리고 8개의 파일을 삭제
  1. 2 2
      ruoyi-ui/package.json
  2. 1 1
      ruoyi-ui/src/components/HeaderSearch/index.vue
  3. 0 4
      ruoyi-ui/src/main.js
  4. 16 1
      ruoyi-ui/src/views/tool/gen/index.vue

+ 2 - 2
ruoyi-ui/package.json

@@ -44,7 +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
+    "highlight.js": "9.18.5",
48 48
     "js-beautify": "1.13.0",
49 49
     "js-cookie": "2.2.1",
50 50
     "jsencrypt": "3.0.0-rc.1",
@@ -69,8 +69,8 @@
69 69
     "eslint": "7.15.0",
70 70
     "eslint-plugin-vue": "7.2.0",
71 71
     "lint-staged": "10.5.3",
72
-    "sass": "1.30.0",
73 72
     "runjs": "4.4.2",
73
+    "sass": "1.32.0",
74 74
     "sass-loader": "10.1.0",
75 75
     "script-ext-html-webpack-plugin": "2.1.5",
76 76
     "svg-sprite-loader": "5.1.1",

+ 1 - 1
ruoyi-ui/src/components/HeaderSearch/index.vue

@@ -20,7 +20,7 @@
20 20
 <script>
21 21
 // fuse is a lightweight fuzzy-search module
22 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 24
 import path from 'path'
25 25
 
26 26
 export default {

+ 0 - 4
ruoyi-ui/src/main.js

@@ -21,9 +21,6 @@ import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels,
21 21
 import Pagination from "@/components/Pagination";
22 22
 // 自定义表格工具扩展
23 23
 import RightToolbar from "@/components/RightToolbar"
24
-// 代码高亮插件
25
-import hljs from 'highlight.js'
26
-import 'highlight.js/styles/github-gist.css'
27 24
 
28 25
 // 全局方法挂载
29 26
 Vue.prototype.getDicts = getDicts
@@ -53,7 +50,6 @@ Vue.component('Pagination', Pagination)
53 50
 Vue.component('RightToolbar', RightToolbar)
54 51
 
55 52
 Vue.use(permission)
56
-Vue.use(hljs.vuePlugin);
57 53
 
58 54
 /**
59 55
  * If you don't want to use mock-server

+ 16 - 1
ruoyi-ui/src/views/tool/gen/index.vue

@@ -169,7 +169,7 @@
169 169
           :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
170 170
           :key="key"
171 171
         >
172
-        <highlightjs autodetect :code="value" />
172
+        <pre><code class="hljs" v-html="highlightedCode(value, key)"></code></pre>
173 173
         </el-tab-pane>
174 174
       </el-tabs>
175 175
     </el-dialog>
@@ -181,6 +181,14 @@
181 181
 import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
182 182
 import importTable from "./importTable";
183 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 193
 export default {
186 194
   name: "Gen",
@@ -294,6 +302,13 @@ export default {
294 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 313
     handleSelectionChange(selection) {
299 314
       this.ids = selection.map(item => item.tableId);