From dddbaeb5c0d77de8fb9b24efc09c0ed7bdd12cc3 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Fri, 11 Dec 2020 18:01:44 +0800
Subject: [PATCH] 代码生成预览支持高亮显示
---
ruoyi-ui/package.json | 1 +
ruoyi-ui/src/views/tool/gen/index.vue | 2 +-
ruoyi-ui/src/main.js | 6 +++++-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json
index 8053fd0..4d17502 100644
--- a/ruoyi-ui/package.json
+++ b/ruoyi-ui/package.json
@@ -44,6 +44,7 @@
"element-ui": "2.14.1",
"file-saver": "2.0.4",
"fuse.js": "6.4.3",
+ "highlight.js": "10.4.1",
"js-beautify": "1.13.0",
"js-cookie": "2.2.1",
"jsencrypt": "3.0.0-rc.1",
diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js
index abb0c79..9d680d9 100644
--- a/ruoyi-ui/src/main.js
+++ b/ruoyi-ui/src/main.js
@@ -19,8 +19,11 @@
import { getConfigKey } from "@/api/system/config";
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi";
import Pagination from "@/components/Pagination";
-//自定义表格工具扩展
+// 自定义表格工具扩展
import RightToolbar from "@/components/RightToolbar"
+// 代码高亮插件
+import hljs from 'highlight.js'
+import 'highlight.js/styles/github-gist.css'
// 全局方法挂载
Vue.prototype.getDicts = getDicts
@@ -50,6 +53,7 @@
Vue.component('RightToolbar', RightToolbar)
Vue.use(permission)
+Vue.use(hljs.vuePlugin);
/**
* If you don't want to use mock-server
diff --git a/ruoyi-ui/src/views/tool/gen/index.vue b/ruoyi-ui/src/views/tool/gen/index.vue
index 34adfb9..db4fd27 100644
--- a/ruoyi-ui/src/views/tool/gen/index.vue
+++ b/ruoyi-ui/src/views/tool/gen/index.vue
@@ -165,7 +165,7 @@
:name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
:key="key"
>
- <pre>{{ value }}</pre>
+ <highlightjs autodetect :code="value" />
</el-tab-pane>
</el-tabs>
</el-dialog>
--
Gitblit v1.9.3