From d053263f4b93a2a03cb4f0d8f3541441b2852072 Mon Sep 17 00:00:00 2001
From: xiaomaiyun <923782299@qq.com>
Date: Sat, 17 Dec 2022 19:10:03 +0000
Subject: [PATCH] =?UTF-8?q?[bugfix]=E8=A7=A3=E5=86=B3Vue=E4=BD=BF=E7=94=A8?=
=?UTF-8?q?highlight.js=20build=E6=89=93=E5=8C=85=E5=8F=91=E5=B8=83?=
=?UTF-8?q?=E5=90=8E=E6=A0=B7=E5=BC=8F=E6=B6=88=E5=A4=B1=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: xiaomaiyun <923782299@qq.com>
---
snowy-admin-web/src/components/XnHighlightjs/index.vue | 4 ++--
snowy-admin-web/src/snowy.js | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/snowy-admin-web/src/components/XnHighlightjs/index.vue b/snowy-admin-web/src/components/XnHighlightjs/index.vue
index c34c3890..7ec12a3d 100644
--- a/snowy-admin-web/src/components/XnHighlightjs/index.vue
+++ b/snowy-admin-web/src/components/XnHighlightjs/index.vue
@@ -1,7 +1,7 @@
-
+
@@ -13,7 +13,7 @@
const props = defineProps({
language: {
type: String,
- default: () => 'JavaScript'
+ default: () => undefined
},
code: {
type: String,
diff --git a/snowy-admin-web/src/snowy.js b/snowy-admin-web/src/snowy.js
index 61a8d09c..a6362124 100644
--- a/snowy-admin-web/src/snowy.js
+++ b/snowy-admin-web/src/snowy.js
@@ -5,7 +5,7 @@ import { hasPerm } from './utils/permission/index'
import errorHandler from './utils/errorHandler'
import customIcons from './assets/icons/index.js'
import 'highlight.js/styles/atom-one-dark.css'
-import 'highlight.js/lib/common'
+import hljsCommon from 'highlight.js/lib/common'
import hljsVuePlugin from '@highlightjs/vue-plugin'
import STable from './components/Table/index.vue'
import Ellipsis from './components/Ellipsis/index.vue'
@@ -28,6 +28,8 @@ export default {
// 统一注册自定义全局图标
app.use(customIcons)
// 注册代码高亮组件 (博客:https://blog.csdn.net/weixin_41897680/article/details/124925222)
+ // 注意:解决Vue使用highlight.js build打包发布后样式消失问题,原因是webpack在打包的时候没有把未被使用的代码打包进去,因此,在此处引用一下,看似无意义实则有用
+ hljsCommon.highlightAuto('
Highlight.js has been registered successfully!
').value
app.use(hljsVuePlugin)
// 全局代码错误捕捉